changes
This commit is contained in:
parent
37ffd941b0
commit
3aeda6d214
33
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/string.js
generated
vendored
Normal file
33
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/string.js
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
module.exports = {
|
||||
'camelCase': require('./camelCase'),
|
||||
'capitalize': require('./capitalize'),
|
||||
'deburr': require('./deburr'),
|
||||
'endsWith': require('./endsWith'),
|
||||
'escape': require('./escape'),
|
||||
'escapeRegExp': require('./escapeRegExp'),
|
||||
'kebabCase': require('./kebabCase'),
|
||||
'lowerCase': require('./lowerCase'),
|
||||
'lowerFirst': require('./lowerFirst'),
|
||||
'pad': require('./pad'),
|
||||
'padEnd': require('./padEnd'),
|
||||
'padStart': require('./padStart'),
|
||||
'parseInt': require('./parseInt'),
|
||||
'repeat': require('./repeat'),
|
||||
'replace': require('./replace'),
|
||||
'snakeCase': require('./snakeCase'),
|
||||
'split': require('./split'),
|
||||
'startCase': require('./startCase'),
|
||||
'startsWith': require('./startsWith'),
|
||||
'template': require('./template'),
|
||||
'templateSettings': require('./templateSettings'),
|
||||
'toLower': require('./toLower'),
|
||||
'toUpper': require('./toUpper'),
|
||||
'trim': require('./trim'),
|
||||
'trimEnd': require('./trimEnd'),
|
||||
'trimStart': require('./trimStart'),
|
||||
'truncate': require('./truncate'),
|
||||
'unescape': require('./unescape'),
|
||||
'upperCase': require('./upperCase'),
|
||||
'upperFirst': require('./upperFirst'),
|
||||
'words': require('./words')
|
||||
};
|
23
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/stubArray.js
generated
vendored
Normal file
23
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/stubArray.js
generated
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* This method returns a new empty array.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.13.0
|
||||
* @category Util
|
||||
* @returns {Array} Returns the new empty array.
|
||||
* @example
|
||||
*
|
||||
* var arrays = _.times(2, _.stubArray);
|
||||
*
|
||||
* console.log(arrays);
|
||||
* // => [[], []]
|
||||
*
|
||||
* console.log(arrays[0] === arrays[1]);
|
||||
* // => false
|
||||
*/
|
||||
function stubArray() {
|
||||
return [];
|
||||
}
|
||||
|
||||
module.exports = stubArray;
|
18
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/stubFalse.js
generated
vendored
Normal file
18
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/stubFalse.js
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* This method returns `false`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.13.0
|
||||
* @category Util
|
||||
* @returns {boolean} Returns `false`.
|
||||
* @example
|
||||
*
|
||||
* _.times(2, _.stubFalse);
|
||||
* // => [false, false]
|
||||
*/
|
||||
function stubFalse() {
|
||||
return false;
|
||||
}
|
||||
|
||||
module.exports = stubFalse;
|
23
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/stubObject.js
generated
vendored
Normal file
23
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/stubObject.js
generated
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* This method returns a new empty object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.13.0
|
||||
* @category Util
|
||||
* @returns {Object} Returns the new empty object.
|
||||
* @example
|
||||
*
|
||||
* var objects = _.times(2, _.stubObject);
|
||||
*
|
||||
* console.log(objects);
|
||||
* // => [{}, {}]
|
||||
*
|
||||
* console.log(objects[0] === objects[1]);
|
||||
* // => false
|
||||
*/
|
||||
function stubObject() {
|
||||
return {};
|
||||
}
|
||||
|
||||
module.exports = stubObject;
|
18
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/stubString.js
generated
vendored
Normal file
18
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/stubString.js
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* This method returns an empty string.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.13.0
|
||||
* @category Util
|
||||
* @returns {string} Returns the empty string.
|
||||
* @example
|
||||
*
|
||||
* _.times(2, _.stubString);
|
||||
* // => ['', '']
|
||||
*/
|
||||
function stubString() {
|
||||
return '';
|
||||
}
|
||||
|
||||
module.exports = stubString;
|
18
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/stubTrue.js
generated
vendored
Normal file
18
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/stubTrue.js
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* This method returns `true`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.13.0
|
||||
* @category Util
|
||||
* @returns {boolean} Returns `true`.
|
||||
* @example
|
||||
*
|
||||
* _.times(2, _.stubTrue);
|
||||
* // => [true, true]
|
||||
*/
|
||||
function stubTrue() {
|
||||
return true;
|
||||
}
|
||||
|
||||
module.exports = stubTrue;
|
22
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/subtract.js
generated
vendored
Normal file
22
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/subtract.js
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
var createMathOperation = require('./_createMathOperation');
|
||||
|
||||
/**
|
||||
* Subtract two numbers.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Math
|
||||
* @param {number} minuend The first number in a subtraction.
|
||||
* @param {number} subtrahend The second number in a subtraction.
|
||||
* @returns {number} Returns the difference.
|
||||
* @example
|
||||
*
|
||||
* _.subtract(6, 4);
|
||||
* // => 2
|
||||
*/
|
||||
var subtract = createMathOperation(function(minuend, subtrahend) {
|
||||
return minuend - subtrahend;
|
||||
}, 0);
|
||||
|
||||
module.exports = subtract;
|
24
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/sum.js
generated
vendored
Normal file
24
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/sum.js
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
var baseSum = require('./_baseSum'),
|
||||
identity = require('./identity');
|
||||
|
||||
/**
|
||||
* Computes the sum of the values in `array`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.4.0
|
||||
* @category Math
|
||||
* @param {Array} array The array to iterate over.
|
||||
* @returns {number} Returns the sum.
|
||||
* @example
|
||||
*
|
||||
* _.sum([4, 2, 8, 6]);
|
||||
* // => 20
|
||||
*/
|
||||
function sum(array) {
|
||||
return (array && array.length)
|
||||
? baseSum(array, identity)
|
||||
: 0;
|
||||
}
|
||||
|
||||
module.exports = sum;
|
33
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/sumBy.js
generated
vendored
Normal file
33
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/sumBy.js
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
var baseIteratee = require('./_baseIteratee'),
|
||||
baseSum = require('./_baseSum');
|
||||
|
||||
/**
|
||||
* This method is like `_.sum` except that it accepts `iteratee` which is
|
||||
* invoked for each element in `array` to generate the value to be summed.
|
||||
* The iteratee is invoked with one argument: (value).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Math
|
||||
* @param {Array} array The array to iterate over.
|
||||
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
|
||||
* @returns {number} Returns the sum.
|
||||
* @example
|
||||
*
|
||||
* var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
|
||||
*
|
||||
* _.sumBy(objects, function(o) { return o.n; });
|
||||
* // => 20
|
||||
*
|
||||
* // The `_.property` iteratee shorthand.
|
||||
* _.sumBy(objects, 'n');
|
||||
* // => 20
|
||||
*/
|
||||
function sumBy(array, iteratee) {
|
||||
return (array && array.length)
|
||||
? baseSum(array, baseIteratee(iteratee, 2))
|
||||
: 0;
|
||||
}
|
||||
|
||||
module.exports = sumBy;
|
22
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/tail.js
generated
vendored
Normal file
22
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/tail.js
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
var baseSlice = require('./_baseSlice');
|
||||
|
||||
/**
|
||||
* Gets all but the first element of `array`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Array
|
||||
* @param {Array} array The array to query.
|
||||
* @returns {Array} Returns the slice of `array`.
|
||||
* @example
|
||||
*
|
||||
* _.tail([1, 2, 3]);
|
||||
* // => [2, 3]
|
||||
*/
|
||||
function tail(array) {
|
||||
var length = array == null ? 0 : array.length;
|
||||
return length ? baseSlice(array, 1, length) : [];
|
||||
}
|
||||
|
||||
module.exports = tail;
|
37
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/take.js
generated
vendored
Normal file
37
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/take.js
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
var baseSlice = require('./_baseSlice'),
|
||||
toInteger = require('./toInteger');
|
||||
|
||||
/**
|
||||
* Creates a slice of `array` with `n` elements taken from the beginning.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @category Array
|
||||
* @param {Array} array The array to query.
|
||||
* @param {number} [n=1] The number of elements to take.
|
||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
|
||||
* @returns {Array} Returns the slice of `array`.
|
||||
* @example
|
||||
*
|
||||
* _.take([1, 2, 3]);
|
||||
* // => [1]
|
||||
*
|
||||
* _.take([1, 2, 3], 2);
|
||||
* // => [1, 2]
|
||||
*
|
||||
* _.take([1, 2, 3], 5);
|
||||
* // => [1, 2, 3]
|
||||
*
|
||||
* _.take([1, 2, 3], 0);
|
||||
* // => []
|
||||
*/
|
||||
function take(array, n, guard) {
|
||||
if (!(array && array.length)) {
|
||||
return [];
|
||||
}
|
||||
n = (guard || n === undefined) ? 1 : toInteger(n);
|
||||
return baseSlice(array, 0, n < 0 ? 0 : n);
|
||||
}
|
||||
|
||||
module.exports = take;
|
39
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/takeRight.js
generated
vendored
Normal file
39
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/takeRight.js
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
var baseSlice = require('./_baseSlice'),
|
||||
toInteger = require('./toInteger');
|
||||
|
||||
/**
|
||||
* Creates a slice of `array` with `n` elements taken from the end.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.0.0
|
||||
* @category Array
|
||||
* @param {Array} array The array to query.
|
||||
* @param {number} [n=1] The number of elements to take.
|
||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
|
||||
* @returns {Array} Returns the slice of `array`.
|
||||
* @example
|
||||
*
|
||||
* _.takeRight([1, 2, 3]);
|
||||
* // => [3]
|
||||
*
|
||||
* _.takeRight([1, 2, 3], 2);
|
||||
* // => [2, 3]
|
||||
*
|
||||
* _.takeRight([1, 2, 3], 5);
|
||||
* // => [1, 2, 3]
|
||||
*
|
||||
* _.takeRight([1, 2, 3], 0);
|
||||
* // => []
|
||||
*/
|
||||
function takeRight(array, n, guard) {
|
||||
var length = array == null ? 0 : array.length;
|
||||
if (!length) {
|
||||
return [];
|
||||
}
|
||||
n = (guard || n === undefined) ? 1 : toInteger(n);
|
||||
n = length - n;
|
||||
return baseSlice(array, n < 0 ? 0 : n, length);
|
||||
}
|
||||
|
||||
module.exports = takeRight;
|
45
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/takeRightWhile.js
generated
vendored
Normal file
45
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/takeRightWhile.js
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
var baseIteratee = require('./_baseIteratee'),
|
||||
baseWhile = require('./_baseWhile');
|
||||
|
||||
/**
|
||||
* Creates a slice of `array` with elements taken from the end. Elements are
|
||||
* taken until `predicate` returns falsey. The predicate is invoked with
|
||||
* three arguments: (value, index, array).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.0.0
|
||||
* @category Array
|
||||
* @param {Array} array The array to query.
|
||||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
||||
* @returns {Array} Returns the slice of `array`.
|
||||
* @example
|
||||
*
|
||||
* var users = [
|
||||
* { 'user': 'barney', 'active': true },
|
||||
* { 'user': 'fred', 'active': false },
|
||||
* { 'user': 'pebbles', 'active': false }
|
||||
* ];
|
||||
*
|
||||
* _.takeRightWhile(users, function(o) { return !o.active; });
|
||||
* // => objects for ['fred', 'pebbles']
|
||||
*
|
||||
* // The `_.matches` iteratee shorthand.
|
||||
* _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
|
||||
* // => objects for ['pebbles']
|
||||
*
|
||||
* // The `_.matchesProperty` iteratee shorthand.
|
||||
* _.takeRightWhile(users, ['active', false]);
|
||||
* // => objects for ['fred', 'pebbles']
|
||||
*
|
||||
* // The `_.property` iteratee shorthand.
|
||||
* _.takeRightWhile(users, 'active');
|
||||
* // => []
|
||||
*/
|
||||
function takeRightWhile(array, predicate) {
|
||||
return (array && array.length)
|
||||
? baseWhile(array, baseIteratee(predicate, 3), false, true)
|
||||
: [];
|
||||
}
|
||||
|
||||
module.exports = takeRightWhile;
|
45
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/takeWhile.js
generated
vendored
Normal file
45
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/takeWhile.js
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
var baseIteratee = require('./_baseIteratee'),
|
||||
baseWhile = require('./_baseWhile');
|
||||
|
||||
/**
|
||||
* Creates a slice of `array` with elements taken from the beginning. Elements
|
||||
* are taken until `predicate` returns falsey. The predicate is invoked with
|
||||
* three arguments: (value, index, array).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.0.0
|
||||
* @category Array
|
||||
* @param {Array} array The array to query.
|
||||
* @param {Function} [predicate=_.identity] The function invoked per iteration.
|
||||
* @returns {Array} Returns the slice of `array`.
|
||||
* @example
|
||||
*
|
||||
* var users = [
|
||||
* { 'user': 'barney', 'active': false },
|
||||
* { 'user': 'fred', 'active': false },
|
||||
* { 'user': 'pebbles', 'active': true }
|
||||
* ];
|
||||
*
|
||||
* _.takeWhile(users, function(o) { return !o.active; });
|
||||
* // => objects for ['barney', 'fred']
|
||||
*
|
||||
* // The `_.matches` iteratee shorthand.
|
||||
* _.takeWhile(users, { 'user': 'barney', 'active': false });
|
||||
* // => objects for ['barney']
|
||||
*
|
||||
* // The `_.matchesProperty` iteratee shorthand.
|
||||
* _.takeWhile(users, ['active', false]);
|
||||
* // => objects for ['barney', 'fred']
|
||||
*
|
||||
* // The `_.property` iteratee shorthand.
|
||||
* _.takeWhile(users, 'active');
|
||||
* // => []
|
||||
*/
|
||||
function takeWhile(array, predicate) {
|
||||
return (array && array.length)
|
||||
? baseWhile(array, baseIteratee(predicate, 3))
|
||||
: [];
|
||||
}
|
||||
|
||||
module.exports = takeWhile;
|
29
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/tap.js
generated
vendored
Normal file
29
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/tap.js
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
* This method invokes `interceptor` and returns `value`. The interceptor
|
||||
* is invoked with one argument; (value). The purpose of this method is to
|
||||
* "tap into" a method chain sequence in order to modify intermediate results.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @category Seq
|
||||
* @param {*} value The value to provide to `interceptor`.
|
||||
* @param {Function} interceptor The function to invoke.
|
||||
* @returns {*} Returns `value`.
|
||||
* @example
|
||||
*
|
||||
* _([1, 2, 3])
|
||||
* .tap(function(array) {
|
||||
* // Mutate input array.
|
||||
* array.pop();
|
||||
* })
|
||||
* .reverse()
|
||||
* .value();
|
||||
* // => [2, 1]
|
||||
*/
|
||||
function tap(value, interceptor) {
|
||||
interceptor(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
module.exports = tap;
|
272
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/template.js
generated
vendored
Normal file
272
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/template.js
generated
vendored
Normal file
|
@ -0,0 +1,272 @@
|
|||
var assignInWith = require('./assignInWith'),
|
||||
attempt = require('./attempt'),
|
||||
baseValues = require('./_baseValues'),
|
||||
customDefaultsAssignIn = require('./_customDefaultsAssignIn'),
|
||||
escapeStringChar = require('./_escapeStringChar'),
|
||||
isError = require('./isError'),
|
||||
isIterateeCall = require('./_isIterateeCall'),
|
||||
keys = require('./keys'),
|
||||
reInterpolate = require('./_reInterpolate'),
|
||||
templateSettings = require('./templateSettings'),
|
||||
toString = require('./toString');
|
||||
|
||||
/** Error message constants. */
|
||||
var INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';
|
||||
|
||||
/** Used to match empty string literals in compiled template source. */
|
||||
var reEmptyStringLeading = /\b__p \+= '';/g,
|
||||
reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
|
||||
reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
|
||||
|
||||
/**
|
||||
* Used to validate the `validate` option in `_.template` variable.
|
||||
*
|
||||
* Forbids characters which could potentially change the meaning of the function argument definition:
|
||||
* - "()," (modification of function parameters)
|
||||
* - "=" (default value)
|
||||
* - "[]{}" (destructuring of function parameters)
|
||||
* - "/" (beginning of a comment)
|
||||
* - whitespace
|
||||
*/
|
||||
var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
|
||||
|
||||
/**
|
||||
* Used to match
|
||||
* [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
|
||||
*/
|
||||
var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
|
||||
|
||||
/** Used to ensure capturing order of template delimiters. */
|
||||
var reNoMatch = /($^)/;
|
||||
|
||||
/** Used to match unescaped characters in compiled string literals. */
|
||||
var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* Creates a compiled template function that can interpolate data properties
|
||||
* in "interpolate" delimiters, HTML-escape interpolated data properties in
|
||||
* "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
|
||||
* properties may be accessed as free variables in the template. If a setting
|
||||
* object is given, it takes precedence over `_.templateSettings` values.
|
||||
*
|
||||
* **Note:** In the development build `_.template` utilizes
|
||||
* [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
|
||||
* for easier debugging.
|
||||
*
|
||||
* For more information on precompiling templates see
|
||||
* [lodash's custom builds documentation](https://lodash.com/custom-builds).
|
||||
*
|
||||
* For more information on Chrome extension sandboxes see
|
||||
* [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
|
||||
*
|
||||
* @static
|
||||
* @since 0.1.0
|
||||
* @memberOf _
|
||||
* @category String
|
||||
* @param {string} [string=''] The template string.
|
||||
* @param {Object} [options={}] The options object.
|
||||
* @param {RegExp} [options.escape=_.templateSettings.escape]
|
||||
* The HTML "escape" delimiter.
|
||||
* @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
|
||||
* The "evaluate" delimiter.
|
||||
* @param {Object} [options.imports=_.templateSettings.imports]
|
||||
* An object to import into the template as free variables.
|
||||
* @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
|
||||
* The "interpolate" delimiter.
|
||||
* @param {string} [options.sourceURL='templateSources[n]']
|
||||
* The sourceURL of the compiled template.
|
||||
* @param {string} [options.variable='obj']
|
||||
* The data object variable name.
|
||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
|
||||
* @returns {Function} Returns the compiled template function.
|
||||
* @example
|
||||
*
|
||||
* // Use the "interpolate" delimiter to create a compiled template.
|
||||
* var compiled = _.template('hello <%= user %>!');
|
||||
* compiled({ 'user': 'fred' });
|
||||
* // => 'hello fred!'
|
||||
*
|
||||
* // Use the HTML "escape" delimiter to escape data property values.
|
||||
* var compiled = _.template('<b><%- value %></b>');
|
||||
* compiled({ 'value': '<script>' });
|
||||
* // => '<b><script></b>'
|
||||
*
|
||||
* // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
|
||||
* var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
|
||||
* compiled({ 'users': ['fred', 'barney'] });
|
||||
* // => '<li>fred</li><li>barney</li>'
|
||||
*
|
||||
* // Use the internal `print` function in "evaluate" delimiters.
|
||||
* var compiled = _.template('<% print("hello " + user); %>!');
|
||||
* compiled({ 'user': 'barney' });
|
||||
* // => 'hello barney!'
|
||||
*
|
||||
* // Use the ES template literal delimiter as an "interpolate" delimiter.
|
||||
* // Disable support by replacing the "interpolate" delimiter.
|
||||
* var compiled = _.template('hello ${ user }!');
|
||||
* compiled({ 'user': 'pebbles' });
|
||||
* // => 'hello pebbles!'
|
||||
*
|
||||
* // Use backslashes to treat delimiters as plain text.
|
||||
* var compiled = _.template('<%= "\\<%- value %\\>" %>');
|
||||
* compiled({ 'value': 'ignored' });
|
||||
* // => '<%- value %>'
|
||||
*
|
||||
* // Use the `imports` option to import `jQuery` as `jq`.
|
||||
* var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
|
||||
* var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
|
||||
* compiled({ 'users': ['fred', 'barney'] });
|
||||
* // => '<li>fred</li><li>barney</li>'
|
||||
*
|
||||
* // Use the `sourceURL` option to specify a custom sourceURL for the template.
|
||||
* var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
|
||||
* compiled(data);
|
||||
* // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
|
||||
*
|
||||
* // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
|
||||
* var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
|
||||
* compiled.source;
|
||||
* // => function(data) {
|
||||
* // var __t, __p = '';
|
||||
* // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
|
||||
* // return __p;
|
||||
* // }
|
||||
*
|
||||
* // Use custom template delimiters.
|
||||
* _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
|
||||
* var compiled = _.template('hello {{ user }}!');
|
||||
* compiled({ 'user': 'mustache' });
|
||||
* // => 'hello mustache!'
|
||||
*
|
||||
* // Use the `source` property to inline compiled templates for meaningful
|
||||
* // line numbers in error messages and stack traces.
|
||||
* fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
|
||||
* var JST = {\
|
||||
* "main": ' + _.template(mainText).source + '\
|
||||
* };\
|
||||
* ');
|
||||
*/
|
||||
function template(string, options, guard) {
|
||||
// Based on John Resig's `tmpl` implementation
|
||||
// (http://ejohn.org/blog/javascript-micro-templating/)
|
||||
// and Laura Doktorova's doT.js (https://github.com/olado/doT).
|
||||
var settings = templateSettings.imports._.templateSettings || templateSettings;
|
||||
|
||||
if (guard && isIterateeCall(string, options, guard)) {
|
||||
options = undefined;
|
||||
}
|
||||
string = toString(string);
|
||||
options = assignInWith({}, options, settings, customDefaultsAssignIn);
|
||||
|
||||
var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
|
||||
importsKeys = keys(imports),
|
||||
importsValues = baseValues(imports, importsKeys);
|
||||
|
||||
var isEscaping,
|
||||
isEvaluating,
|
||||
index = 0,
|
||||
interpolate = options.interpolate || reNoMatch,
|
||||
source = "__p += '";
|
||||
|
||||
// Compile the regexp to match each delimiter.
|
||||
var reDelimiters = RegExp(
|
||||
(options.escape || reNoMatch).source + '|' +
|
||||
interpolate.source + '|' +
|
||||
(interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
|
||||
(options.evaluate || reNoMatch).source + '|$'
|
||||
, 'g');
|
||||
|
||||
// Use a sourceURL for easier debugging.
|
||||
// The sourceURL gets injected into the source that's eval-ed, so be careful
|
||||
// to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in
|
||||
// and escape the comment, thus injecting code that gets evaled.
|
||||
var sourceURL = hasOwnProperty.call(options, 'sourceURL')
|
||||
? ('//# sourceURL=' +
|
||||
(options.sourceURL + '').replace(/\s/g, ' ') +
|
||||
'\n')
|
||||
: '';
|
||||
|
||||
string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
|
||||
interpolateValue || (interpolateValue = esTemplateValue);
|
||||
|
||||
// Escape characters that can't be included in string literals.
|
||||
source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
|
||||
|
||||
// Replace delimiters with snippets.
|
||||
if (escapeValue) {
|
||||
isEscaping = true;
|
||||
source += "' +\n__e(" + escapeValue + ") +\n'";
|
||||
}
|
||||
if (evaluateValue) {
|
||||
isEvaluating = true;
|
||||
source += "';\n" + evaluateValue + ";\n__p += '";
|
||||
}
|
||||
if (interpolateValue) {
|
||||
source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
|
||||
}
|
||||
index = offset + match.length;
|
||||
|
||||
// The JS engine embedded in Adobe products needs `match` returned in
|
||||
// order to produce the correct `offset` value.
|
||||
return match;
|
||||
});
|
||||
|
||||
source += "';\n";
|
||||
|
||||
// If `variable` is not specified wrap a with-statement around the generated
|
||||
// code to add the data object to the top of the scope chain.
|
||||
var variable = hasOwnProperty.call(options, 'variable') && options.variable;
|
||||
if (!variable) {
|
||||
source = 'with (obj) {\n' + source + '\n}\n';
|
||||
}
|
||||
// Throw an error if a forbidden character was found in `variable`, to prevent
|
||||
// potential command injection attacks.
|
||||
else if (reForbiddenIdentifierChars.test(variable)) {
|
||||
throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT);
|
||||
}
|
||||
|
||||
// Cleanup code by stripping empty strings.
|
||||
source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
|
||||
.replace(reEmptyStringMiddle, '$1')
|
||||
.replace(reEmptyStringTrailing, '$1;');
|
||||
|
||||
// Frame code as the function body.
|
||||
source = 'function(' + (variable || 'obj') + ') {\n' +
|
||||
(variable
|
||||
? ''
|
||||
: 'obj || (obj = {});\n'
|
||||
) +
|
||||
"var __t, __p = ''" +
|
||||
(isEscaping
|
||||
? ', __e = _.escape'
|
||||
: ''
|
||||
) +
|
||||
(isEvaluating
|
||||
? ', __j = Array.prototype.join;\n' +
|
||||
"function print() { __p += __j.call(arguments, '') }\n"
|
||||
: ';\n'
|
||||
) +
|
||||
source +
|
||||
'return __p\n}';
|
||||
|
||||
var result = attempt(function() {
|
||||
return Function(importsKeys, sourceURL + 'return ' + source)
|
||||
.apply(undefined, importsValues);
|
||||
});
|
||||
|
||||
// Provide the compiled function's source by its `toString` method or
|
||||
// the `source` property as a convenience for inlining compiled templates.
|
||||
result.source = source;
|
||||
if (isError(result)) {
|
||||
throw result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = template;
|
67
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/templateSettings.js
generated
vendored
Normal file
67
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/templateSettings.js
generated
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
var escape = require('./escape'),
|
||||
reEscape = require('./_reEscape'),
|
||||
reEvaluate = require('./_reEvaluate'),
|
||||
reInterpolate = require('./_reInterpolate');
|
||||
|
||||
/**
|
||||
* By default, the template delimiters used by lodash are like those in
|
||||
* embedded Ruby (ERB) as well as ES2015 template strings. Change the
|
||||
* following template settings to use alternative delimiters.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @type {Object}
|
||||
*/
|
||||
var templateSettings = {
|
||||
|
||||
/**
|
||||
* Used to detect `data` property values to be HTML-escaped.
|
||||
*
|
||||
* @memberOf _.templateSettings
|
||||
* @type {RegExp}
|
||||
*/
|
||||
'escape': reEscape,
|
||||
|
||||
/**
|
||||
* Used to detect code to be evaluated.
|
||||
*
|
||||
* @memberOf _.templateSettings
|
||||
* @type {RegExp}
|
||||
*/
|
||||
'evaluate': reEvaluate,
|
||||
|
||||
/**
|
||||
* Used to detect `data` property values to inject.
|
||||
*
|
||||
* @memberOf _.templateSettings
|
||||
* @type {RegExp}
|
||||
*/
|
||||
'interpolate': reInterpolate,
|
||||
|
||||
/**
|
||||
* Used to reference the data object in the template text.
|
||||
*
|
||||
* @memberOf _.templateSettings
|
||||
* @type {string}
|
||||
*/
|
||||
'variable': '',
|
||||
|
||||
/**
|
||||
* Used to import variables into the compiled template.
|
||||
*
|
||||
* @memberOf _.templateSettings
|
||||
* @type {Object}
|
||||
*/
|
||||
'imports': {
|
||||
|
||||
/**
|
||||
* A reference to the `lodash` function.
|
||||
*
|
||||
* @memberOf _.templateSettings.imports
|
||||
* @type {Function}
|
||||
*/
|
||||
'_': { 'escape': escape }
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = templateSettings;
|
69
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/throttle.js
generated
vendored
Normal file
69
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/throttle.js
generated
vendored
Normal file
|
@ -0,0 +1,69 @@
|
|||
var debounce = require('./debounce'),
|
||||
isObject = require('./isObject');
|
||||
|
||||
/** Error message constants. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/**
|
||||
* Creates a throttled function that only invokes `func` at most once per
|
||||
* every `wait` milliseconds. The throttled function comes with a `cancel`
|
||||
* method to cancel delayed `func` invocations and a `flush` method to
|
||||
* immediately invoke them. Provide `options` to indicate whether `func`
|
||||
* should be invoked on the leading and/or trailing edge of the `wait`
|
||||
* timeout. The `func` is invoked with the last arguments provided to the
|
||||
* throttled function. Subsequent calls to the throttled function return the
|
||||
* result of the last `func` invocation.
|
||||
*
|
||||
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
||||
* invoked on the trailing edge of the timeout only if the throttled function
|
||||
* is invoked more than once during the `wait` timeout.
|
||||
*
|
||||
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
||||
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
|
||||
*
|
||||
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
||||
* for details over the differences between `_.throttle` and `_.debounce`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @category Function
|
||||
* @param {Function} func The function to throttle.
|
||||
* @param {number} [wait=0] The number of milliseconds to throttle invocations to.
|
||||
* @param {Object} [options={}] The options object.
|
||||
* @param {boolean} [options.leading=true]
|
||||
* Specify invoking on the leading edge of the timeout.
|
||||
* @param {boolean} [options.trailing=true]
|
||||
* Specify invoking on the trailing edge of the timeout.
|
||||
* @returns {Function} Returns the new throttled function.
|
||||
* @example
|
||||
*
|
||||
* // Avoid excessively updating the position while scrolling.
|
||||
* jQuery(window).on('scroll', _.throttle(updatePosition, 100));
|
||||
*
|
||||
* // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
|
||||
* var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
|
||||
* jQuery(element).on('click', throttled);
|
||||
*
|
||||
* // Cancel the trailing throttled invocation.
|
||||
* jQuery(window).on('popstate', throttled.cancel);
|
||||
*/
|
||||
function throttle(func, wait, options) {
|
||||
var leading = true,
|
||||
trailing = true;
|
||||
|
||||
if (typeof func != 'function') {
|
||||
throw new TypeError(FUNC_ERROR_TEXT);
|
||||
}
|
||||
if (isObject(options)) {
|
||||
leading = 'leading' in options ? !!options.leading : leading;
|
||||
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
||||
}
|
||||
return debounce(func, wait, {
|
||||
'leading': leading,
|
||||
'maxWait': wait,
|
||||
'trailing': trailing
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = throttle;
|
28
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/thru.js
generated
vendored
Normal file
28
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/thru.js
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* This method is like `_.tap` except that it returns the result of `interceptor`.
|
||||
* The purpose of this method is to "pass thru" values replacing intermediate
|
||||
* results in a method chain sequence.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.0.0
|
||||
* @category Seq
|
||||
* @param {*} value The value to provide to `interceptor`.
|
||||
* @param {Function} interceptor The function to invoke.
|
||||
* @returns {*} Returns the result of `interceptor`.
|
||||
* @example
|
||||
*
|
||||
* _(' abc ')
|
||||
* .chain()
|
||||
* .trim()
|
||||
* .thru(function(value) {
|
||||
* return [value];
|
||||
* })
|
||||
* .value();
|
||||
* // => ['abc']
|
||||
*/
|
||||
function thru(value, interceptor) {
|
||||
return interceptor(value);
|
||||
}
|
||||
|
||||
module.exports = thru;
|
51
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/times.js
generated
vendored
Normal file
51
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/times.js
generated
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
var baseTimes = require('./_baseTimes'),
|
||||
castFunction = require('./_castFunction'),
|
||||
toInteger = require('./toInteger');
|
||||
|
||||
/** Used as references for various `Number` constants. */
|
||||
var MAX_SAFE_INTEGER = 9007199254740991;
|
||||
|
||||
/** Used as references for the maximum length and index of an array. */
|
||||
var MAX_ARRAY_LENGTH = 4294967295;
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
var nativeMin = Math.min;
|
||||
|
||||
/**
|
||||
* Invokes the iteratee `n` times, returning an array of the results of
|
||||
* each invocation. The iteratee is invoked with one argument; (index).
|
||||
*
|
||||
* @static
|
||||
* @since 0.1.0
|
||||
* @memberOf _
|
||||
* @category Util
|
||||
* @param {number} n The number of times to invoke `iteratee`.
|
||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||||
* @returns {Array} Returns the array of results.
|
||||
* @example
|
||||
*
|
||||
* _.times(3, String);
|
||||
* // => ['0', '1', '2']
|
||||
*
|
||||
* _.times(4, _.constant(0));
|
||||
* // => [0, 0, 0, 0]
|
||||
*/
|
||||
function times(n, iteratee) {
|
||||
n = toInteger(n);
|
||||
if (n < 1 || n > MAX_SAFE_INTEGER) {
|
||||
return [];
|
||||
}
|
||||
var index = MAX_ARRAY_LENGTH,
|
||||
length = nativeMin(n, MAX_ARRAY_LENGTH);
|
||||
|
||||
iteratee = castFunction(iteratee);
|
||||
n -= MAX_ARRAY_LENGTH;
|
||||
|
||||
var result = baseTimes(length, iteratee);
|
||||
while (++index < n) {
|
||||
iteratee(index);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = times;
|
58
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toArray.js
generated
vendored
Normal file
58
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toArray.js
generated
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
var Symbol = require('./_Symbol'),
|
||||
copyArray = require('./_copyArray'),
|
||||
getTag = require('./_getTag'),
|
||||
isArrayLike = require('./isArrayLike'),
|
||||
isString = require('./isString'),
|
||||
iteratorToArray = require('./_iteratorToArray'),
|
||||
mapToArray = require('./_mapToArray'),
|
||||
setToArray = require('./_setToArray'),
|
||||
stringToArray = require('./_stringToArray'),
|
||||
values = require('./values');
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var mapTag = '[object Map]',
|
||||
setTag = '[object Set]';
|
||||
|
||||
/** Built-in value references. */
|
||||
var symIterator = Symbol ? Symbol.iterator : undefined;
|
||||
|
||||
/**
|
||||
* Converts `value` to an array.
|
||||
*
|
||||
* @static
|
||||
* @since 0.1.0
|
||||
* @memberOf _
|
||||
* @category Lang
|
||||
* @param {*} value The value to convert.
|
||||
* @returns {Array} Returns the converted array.
|
||||
* @example
|
||||
*
|
||||
* _.toArray({ 'a': 1, 'b': 2 });
|
||||
* // => [1, 2]
|
||||
*
|
||||
* _.toArray('abc');
|
||||
* // => ['a', 'b', 'c']
|
||||
*
|
||||
* _.toArray(1);
|
||||
* // => []
|
||||
*
|
||||
* _.toArray(null);
|
||||
* // => []
|
||||
*/
|
||||
function toArray(value) {
|
||||
if (!value) {
|
||||
return [];
|
||||
}
|
||||
if (isArrayLike(value)) {
|
||||
return isString(value) ? stringToArray(value) : copyArray(value);
|
||||
}
|
||||
if (symIterator && value[symIterator]) {
|
||||
return iteratorToArray(value[symIterator]());
|
||||
}
|
||||
var tag = getTag(value),
|
||||
func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
|
||||
|
||||
return func(value);
|
||||
}
|
||||
|
||||
module.exports = toArray;
|
42
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toFinite.js
generated
vendored
Normal file
42
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toFinite.js
generated
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
var toNumber = require('./toNumber');
|
||||
|
||||
/** Used as references for various `Number` constants. */
|
||||
var INFINITY = 1 / 0,
|
||||
MAX_INTEGER = 1.7976931348623157e+308;
|
||||
|
||||
/**
|
||||
* Converts `value` to a finite number.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.12.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to convert.
|
||||
* @returns {number} Returns the converted number.
|
||||
* @example
|
||||
*
|
||||
* _.toFinite(3.2);
|
||||
* // => 3.2
|
||||
*
|
||||
* _.toFinite(Number.MIN_VALUE);
|
||||
* // => 5e-324
|
||||
*
|
||||
* _.toFinite(Infinity);
|
||||
* // => 1.7976931348623157e+308
|
||||
*
|
||||
* _.toFinite('3.2');
|
||||
* // => 3.2
|
||||
*/
|
||||
function toFinite(value) {
|
||||
if (!value) {
|
||||
return value === 0 ? value : 0;
|
||||
}
|
||||
value = toNumber(value);
|
||||
if (value === INFINITY || value === -INFINITY) {
|
||||
var sign = (value < 0 ? -1 : 1);
|
||||
return sign * MAX_INTEGER;
|
||||
}
|
||||
return value === value ? value : 0;
|
||||
}
|
||||
|
||||
module.exports = toFinite;
|
36
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toInteger.js
generated
vendored
Normal file
36
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toInteger.js
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
var toFinite = require('./toFinite');
|
||||
|
||||
/**
|
||||
* Converts `value` to an integer.
|
||||
*
|
||||
* **Note:** This method is loosely based on
|
||||
* [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to convert.
|
||||
* @returns {number} Returns the converted integer.
|
||||
* @example
|
||||
*
|
||||
* _.toInteger(3.2);
|
||||
* // => 3
|
||||
*
|
||||
* _.toInteger(Number.MIN_VALUE);
|
||||
* // => 0
|
||||
*
|
||||
* _.toInteger(Infinity);
|
||||
* // => 1.7976931348623157e+308
|
||||
*
|
||||
* _.toInteger('3.2');
|
||||
* // => 3
|
||||
*/
|
||||
function toInteger(value) {
|
||||
var result = toFinite(value),
|
||||
remainder = result % 1;
|
||||
|
||||
return result === result ? (remainder ? result - remainder : result) : 0;
|
||||
}
|
||||
|
||||
module.exports = toInteger;
|
23
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toIterator.js
generated
vendored
Normal file
23
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toIterator.js
generated
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* Enables the wrapper to be iterable.
|
||||
*
|
||||
* @name Symbol.iterator
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Seq
|
||||
* @returns {Object} Returns the wrapper object.
|
||||
* @example
|
||||
*
|
||||
* var wrapped = _([1, 2]);
|
||||
*
|
||||
* wrapped[Symbol.iterator]() === wrapped;
|
||||
* // => true
|
||||
*
|
||||
* Array.from(wrapped);
|
||||
* // => [1, 2]
|
||||
*/
|
||||
function wrapperToIterator() {
|
||||
return this;
|
||||
}
|
||||
|
||||
module.exports = wrapperToIterator;
|
1
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toJSON.js
generated
vendored
Normal file
1
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toJSON.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
module.exports = require('./wrapperValue');
|
38
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toLength.js
generated
vendored
Normal file
38
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toLength.js
generated
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
var baseClamp = require('./_baseClamp'),
|
||||
toInteger = require('./toInteger');
|
||||
|
||||
/** Used as references for the maximum length and index of an array. */
|
||||
var MAX_ARRAY_LENGTH = 4294967295;
|
||||
|
||||
/**
|
||||
* Converts `value` to an integer suitable for use as the length of an
|
||||
* array-like object.
|
||||
*
|
||||
* **Note:** This method is based on
|
||||
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to convert.
|
||||
* @returns {number} Returns the converted integer.
|
||||
* @example
|
||||
*
|
||||
* _.toLength(3.2);
|
||||
* // => 3
|
||||
*
|
||||
* _.toLength(Number.MIN_VALUE);
|
||||
* // => 0
|
||||
*
|
||||
* _.toLength(Infinity);
|
||||
* // => 4294967295
|
||||
*
|
||||
* _.toLength('3.2');
|
||||
* // => 3
|
||||
*/
|
||||
function toLength(value) {
|
||||
return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
|
||||
}
|
||||
|
||||
module.exports = toLength;
|
28
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toLower.js
generated
vendored
Normal file
28
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toLower.js
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
var toString = require('./toString');
|
||||
|
||||
/**
|
||||
* Converts `string`, as a whole, to lower case just like
|
||||
* [String#toLowerCase](https://mdn.io/toLowerCase).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category String
|
||||
* @param {string} [string=''] The string to convert.
|
||||
* @returns {string} Returns the lower cased string.
|
||||
* @example
|
||||
*
|
||||
* _.toLower('--Foo-Bar--');
|
||||
* // => '--foo-bar--'
|
||||
*
|
||||
* _.toLower('fooBar');
|
||||
* // => 'foobar'
|
||||
*
|
||||
* _.toLower('__FOO_BAR__');
|
||||
* // => '__foo_bar__'
|
||||
*/
|
||||
function toLower(value) {
|
||||
return toString(value).toLowerCase();
|
||||
}
|
||||
|
||||
module.exports = toLower;
|
64
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toNumber.js
generated
vendored
Normal file
64
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toNumber.js
generated
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
var baseTrim = require('./_baseTrim'),
|
||||
isObject = require('./isObject'),
|
||||
isSymbol = require('./isSymbol');
|
||||
|
||||
/** Used as references for various `Number` constants. */
|
||||
var NAN = 0 / 0;
|
||||
|
||||
/** Used to detect bad signed hexadecimal string values. */
|
||||
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
||||
|
||||
/** Used to detect binary string values. */
|
||||
var reIsBinary = /^0b[01]+$/i;
|
||||
|
||||
/** Used to detect octal string values. */
|
||||
var reIsOctal = /^0o[0-7]+$/i;
|
||||
|
||||
/** Built-in method references without a dependency on `root`. */
|
||||
var freeParseInt = parseInt;
|
||||
|
||||
/**
|
||||
* Converts `value` to a number.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to process.
|
||||
* @returns {number} Returns the number.
|
||||
* @example
|
||||
*
|
||||
* _.toNumber(3.2);
|
||||
* // => 3.2
|
||||
*
|
||||
* _.toNumber(Number.MIN_VALUE);
|
||||
* // => 5e-324
|
||||
*
|
||||
* _.toNumber(Infinity);
|
||||
* // => Infinity
|
||||
*
|
||||
* _.toNumber('3.2');
|
||||
* // => 3.2
|
||||
*/
|
||||
function toNumber(value) {
|
||||
if (typeof value == 'number') {
|
||||
return value;
|
||||
}
|
||||
if (isSymbol(value)) {
|
||||
return NAN;
|
||||
}
|
||||
if (isObject(value)) {
|
||||
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
|
||||
value = isObject(other) ? (other + '') : other;
|
||||
}
|
||||
if (typeof value != 'string') {
|
||||
return value === 0 ? value : +value;
|
||||
}
|
||||
value = baseTrim(value);
|
||||
var isBinary = reIsBinary.test(value);
|
||||
return (isBinary || reIsOctal.test(value))
|
||||
? freeParseInt(value.slice(2), isBinary ? 2 : 8)
|
||||
: (reIsBadHex.test(value) ? NAN : +value);
|
||||
}
|
||||
|
||||
module.exports = toNumber;
|
30
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toPairs.js
generated
vendored
Normal file
30
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toPairs.js
generated
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
var createToPairs = require('./_createToPairs'),
|
||||
keys = require('./keys');
|
||||
|
||||
/**
|
||||
* Creates an array of own enumerable string keyed-value pairs for `object`
|
||||
* which can be consumed by `_.fromPairs`. If `object` is a map or set, its
|
||||
* entries are returned.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @alias entries
|
||||
* @category Object
|
||||
* @param {Object} object The object to query.
|
||||
* @returns {Array} Returns the key-value pairs.
|
||||
* @example
|
||||
*
|
||||
* function Foo() {
|
||||
* this.a = 1;
|
||||
* this.b = 2;
|
||||
* }
|
||||
*
|
||||
* Foo.prototype.c = 3;
|
||||
*
|
||||
* _.toPairs(new Foo);
|
||||
* // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
|
||||
*/
|
||||
var toPairs = createToPairs(keys);
|
||||
|
||||
module.exports = toPairs;
|
30
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toPairsIn.js
generated
vendored
Normal file
30
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toPairsIn.js
generated
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
var createToPairs = require('./_createToPairs'),
|
||||
keysIn = require('./keysIn');
|
||||
|
||||
/**
|
||||
* Creates an array of own and inherited enumerable string keyed-value pairs
|
||||
* for `object` which can be consumed by `_.fromPairs`. If `object` is a map
|
||||
* or set, its entries are returned.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @alias entriesIn
|
||||
* @category Object
|
||||
* @param {Object} object The object to query.
|
||||
* @returns {Array} Returns the key-value pairs.
|
||||
* @example
|
||||
*
|
||||
* function Foo() {
|
||||
* this.a = 1;
|
||||
* this.b = 2;
|
||||
* }
|
||||
*
|
||||
* Foo.prototype.c = 3;
|
||||
*
|
||||
* _.toPairsIn(new Foo);
|
||||
* // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
|
||||
*/
|
||||
var toPairsIn = createToPairs(keysIn);
|
||||
|
||||
module.exports = toPairsIn;
|
33
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toPath.js
generated
vendored
Normal file
33
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toPath.js
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
var arrayMap = require('./_arrayMap'),
|
||||
copyArray = require('./_copyArray'),
|
||||
isArray = require('./isArray'),
|
||||
isSymbol = require('./isSymbol'),
|
||||
stringToPath = require('./_stringToPath'),
|
||||
toKey = require('./_toKey'),
|
||||
toString = require('./toString');
|
||||
|
||||
/**
|
||||
* Converts `value` to a property path array.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Util
|
||||
* @param {*} value The value to convert.
|
||||
* @returns {Array} Returns the new property path array.
|
||||
* @example
|
||||
*
|
||||
* _.toPath('a.b.c');
|
||||
* // => ['a', 'b', 'c']
|
||||
*
|
||||
* _.toPath('a[0].b.c');
|
||||
* // => ['a', '0', 'b', 'c']
|
||||
*/
|
||||
function toPath(value) {
|
||||
if (isArray(value)) {
|
||||
return arrayMap(value, toKey);
|
||||
}
|
||||
return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
|
||||
}
|
||||
|
||||
module.exports = toPath;
|
32
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toPlainObject.js
generated
vendored
Normal file
32
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toPlainObject.js
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
var copyObject = require('./_copyObject'),
|
||||
keysIn = require('./keysIn');
|
||||
|
||||
/**
|
||||
* Converts `value` to a plain object flattening inherited enumerable string
|
||||
* keyed properties of `value` to own properties of the plain object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.0.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to convert.
|
||||
* @returns {Object} Returns the converted plain object.
|
||||
* @example
|
||||
*
|
||||
* function Foo() {
|
||||
* this.b = 2;
|
||||
* }
|
||||
*
|
||||
* Foo.prototype.c = 3;
|
||||
*
|
||||
* _.assign({ 'a': 1 }, new Foo);
|
||||
* // => { 'a': 1, 'b': 2 }
|
||||
*
|
||||
* _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
|
||||
* // => { 'a': 1, 'b': 2, 'c': 3 }
|
||||
*/
|
||||
function toPlainObject(value) {
|
||||
return copyObject(value, keysIn(value));
|
||||
}
|
||||
|
||||
module.exports = toPlainObject;
|
37
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toSafeInteger.js
generated
vendored
Normal file
37
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toSafeInteger.js
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
var baseClamp = require('./_baseClamp'),
|
||||
toInteger = require('./toInteger');
|
||||
|
||||
/** Used as references for various `Number` constants. */
|
||||
var MAX_SAFE_INTEGER = 9007199254740991;
|
||||
|
||||
/**
|
||||
* Converts `value` to a safe integer. A safe integer can be compared and
|
||||
* represented correctly.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to convert.
|
||||
* @returns {number} Returns the converted integer.
|
||||
* @example
|
||||
*
|
||||
* _.toSafeInteger(3.2);
|
||||
* // => 3
|
||||
*
|
||||
* _.toSafeInteger(Number.MIN_VALUE);
|
||||
* // => 0
|
||||
*
|
||||
* _.toSafeInteger(Infinity);
|
||||
* // => 9007199254740991
|
||||
*
|
||||
* _.toSafeInteger('3.2');
|
||||
* // => 3
|
||||
*/
|
||||
function toSafeInteger(value) {
|
||||
return value
|
||||
? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
|
||||
: (value === 0 ? value : 0);
|
||||
}
|
||||
|
||||
module.exports = toSafeInteger;
|
28
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toString.js
generated
vendored
Normal file
28
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toString.js
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
var baseToString = require('./_baseToString');
|
||||
|
||||
/**
|
||||
* Converts `value` to a string. An empty string is returned for `null`
|
||||
* and `undefined` values. The sign of `-0` is preserved.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to convert.
|
||||
* @returns {string} Returns the converted string.
|
||||
* @example
|
||||
*
|
||||
* _.toString(null);
|
||||
* // => ''
|
||||
*
|
||||
* _.toString(-0);
|
||||
* // => '-0'
|
||||
*
|
||||
* _.toString([1, 2, 3]);
|
||||
* // => '1,2,3'
|
||||
*/
|
||||
function toString(value) {
|
||||
return value == null ? '' : baseToString(value);
|
||||
}
|
||||
|
||||
module.exports = toString;
|
28
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toUpper.js
generated
vendored
Normal file
28
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/toUpper.js
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
var toString = require('./toString');
|
||||
|
||||
/**
|
||||
* Converts `string`, as a whole, to upper case just like
|
||||
* [String#toUpperCase](https://mdn.io/toUpperCase).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category String
|
||||
* @param {string} [string=''] The string to convert.
|
||||
* @returns {string} Returns the upper cased string.
|
||||
* @example
|
||||
*
|
||||
* _.toUpper('--foo-bar--');
|
||||
* // => '--FOO-BAR--'
|
||||
*
|
||||
* _.toUpper('fooBar');
|
||||
* // => 'FOOBAR'
|
||||
*
|
||||
* _.toUpper('__foo_bar__');
|
||||
* // => '__FOO_BAR__'
|
||||
*/
|
||||
function toUpper(value) {
|
||||
return toString(value).toUpperCase();
|
||||
}
|
||||
|
||||
module.exports = toUpper;
|
65
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/transform.js
generated
vendored
Normal file
65
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/transform.js
generated
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
var arrayEach = require('./_arrayEach'),
|
||||
baseCreate = require('./_baseCreate'),
|
||||
baseForOwn = require('./_baseForOwn'),
|
||||
baseIteratee = require('./_baseIteratee'),
|
||||
getPrototype = require('./_getPrototype'),
|
||||
isArray = require('./isArray'),
|
||||
isBuffer = require('./isBuffer'),
|
||||
isFunction = require('./isFunction'),
|
||||
isObject = require('./isObject'),
|
||||
isTypedArray = require('./isTypedArray');
|
||||
|
||||
/**
|
||||
* An alternative to `_.reduce`; this method transforms `object` to a new
|
||||
* `accumulator` object which is the result of running each of its own
|
||||
* enumerable string keyed properties thru `iteratee`, with each invocation
|
||||
* potentially mutating the `accumulator` object. If `accumulator` is not
|
||||
* provided, a new object with the same `[[Prototype]]` will be used. The
|
||||
* iteratee is invoked with four arguments: (accumulator, value, key, object).
|
||||
* Iteratee functions may exit iteration early by explicitly returning `false`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 1.3.0
|
||||
* @category Object
|
||||
* @param {Object} object The object to iterate over.
|
||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||||
* @param {*} [accumulator] The custom accumulator value.
|
||||
* @returns {*} Returns the accumulated value.
|
||||
* @example
|
||||
*
|
||||
* _.transform([2, 3, 4], function(result, n) {
|
||||
* result.push(n *= n);
|
||||
* return n % 2 == 0;
|
||||
* }, []);
|
||||
* // => [4, 9]
|
||||
*
|
||||
* _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
|
||||
* (result[value] || (result[value] = [])).push(key);
|
||||
* }, {});
|
||||
* // => { '1': ['a', 'c'], '2': ['b'] }
|
||||
*/
|
||||
function transform(object, iteratee, accumulator) {
|
||||
var isArr = isArray(object),
|
||||
isArrLike = isArr || isBuffer(object) || isTypedArray(object);
|
||||
|
||||
iteratee = baseIteratee(iteratee, 4);
|
||||
if (accumulator == null) {
|
||||
var Ctor = object && object.constructor;
|
||||
if (isArrLike) {
|
||||
accumulator = isArr ? new Ctor : [];
|
||||
}
|
||||
else if (isObject(object)) {
|
||||
accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
|
||||
}
|
||||
else {
|
||||
accumulator = {};
|
||||
}
|
||||
}
|
||||
(isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
|
||||
return iteratee(accumulator, value, index, object);
|
||||
});
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
module.exports = transform;
|
47
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/trim.js
generated
vendored
Normal file
47
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/trim.js
generated
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
var baseToString = require('./_baseToString'),
|
||||
baseTrim = require('./_baseTrim'),
|
||||
castSlice = require('./_castSlice'),
|
||||
charsEndIndex = require('./_charsEndIndex'),
|
||||
charsStartIndex = require('./_charsStartIndex'),
|
||||
stringToArray = require('./_stringToArray'),
|
||||
toString = require('./toString');
|
||||
|
||||
/**
|
||||
* Removes leading and trailing whitespace or specified characters from `string`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.0.0
|
||||
* @category String
|
||||
* @param {string} [string=''] The string to trim.
|
||||
* @param {string} [chars=whitespace] The characters to trim.
|
||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
|
||||
* @returns {string} Returns the trimmed string.
|
||||
* @example
|
||||
*
|
||||
* _.trim(' abc ');
|
||||
* // => 'abc'
|
||||
*
|
||||
* _.trim('-_-abc-_-', '_-');
|
||||
* // => 'abc'
|
||||
*
|
||||
* _.map([' foo ', ' bar '], _.trim);
|
||||
* // => ['foo', 'bar']
|
||||
*/
|
||||
function trim(string, chars, guard) {
|
||||
string = toString(string);
|
||||
if (string && (guard || chars === undefined)) {
|
||||
return baseTrim(string);
|
||||
}
|
||||
if (!string || !(chars = baseToString(chars))) {
|
||||
return string;
|
||||
}
|
||||
var strSymbols = stringToArray(string),
|
||||
chrSymbols = stringToArray(chars),
|
||||
start = charsStartIndex(strSymbols, chrSymbols),
|
||||
end = charsEndIndex(strSymbols, chrSymbols) + 1;
|
||||
|
||||
return castSlice(strSymbols, start, end).join('');
|
||||
}
|
||||
|
||||
module.exports = trim;
|
41
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/trimEnd.js
generated
vendored
Normal file
41
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/trimEnd.js
generated
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
var baseToString = require('./_baseToString'),
|
||||
castSlice = require('./_castSlice'),
|
||||
charsEndIndex = require('./_charsEndIndex'),
|
||||
stringToArray = require('./_stringToArray'),
|
||||
toString = require('./toString'),
|
||||
trimmedEndIndex = require('./_trimmedEndIndex');
|
||||
|
||||
/**
|
||||
* Removes trailing whitespace or specified characters from `string`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category String
|
||||
* @param {string} [string=''] The string to trim.
|
||||
* @param {string} [chars=whitespace] The characters to trim.
|
||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
|
||||
* @returns {string} Returns the trimmed string.
|
||||
* @example
|
||||
*
|
||||
* _.trimEnd(' abc ');
|
||||
* // => ' abc'
|
||||
*
|
||||
* _.trimEnd('-_-abc-_-', '_-');
|
||||
* // => '-_-abc'
|
||||
*/
|
||||
function trimEnd(string, chars, guard) {
|
||||
string = toString(string);
|
||||
if (string && (guard || chars === undefined)) {
|
||||
return string.slice(0, trimmedEndIndex(string) + 1);
|
||||
}
|
||||
if (!string || !(chars = baseToString(chars))) {
|
||||
return string;
|
||||
}
|
||||
var strSymbols = stringToArray(string),
|
||||
end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
|
||||
|
||||
return castSlice(strSymbols, 0, end).join('');
|
||||
}
|
||||
|
||||
module.exports = trimEnd;
|
43
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/trimStart.js
generated
vendored
Normal file
43
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/trimStart.js
generated
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
var baseToString = require('./_baseToString'),
|
||||
castSlice = require('./_castSlice'),
|
||||
charsStartIndex = require('./_charsStartIndex'),
|
||||
stringToArray = require('./_stringToArray'),
|
||||
toString = require('./toString');
|
||||
|
||||
/** Used to match leading whitespace. */
|
||||
var reTrimStart = /^\s+/;
|
||||
|
||||
/**
|
||||
* Removes leading whitespace or specified characters from `string`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category String
|
||||
* @param {string} [string=''] The string to trim.
|
||||
* @param {string} [chars=whitespace] The characters to trim.
|
||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
|
||||
* @returns {string} Returns the trimmed string.
|
||||
* @example
|
||||
*
|
||||
* _.trimStart(' abc ');
|
||||
* // => 'abc '
|
||||
*
|
||||
* _.trimStart('-_-abc-_-', '_-');
|
||||
* // => 'abc-_-'
|
||||
*/
|
||||
function trimStart(string, chars, guard) {
|
||||
string = toString(string);
|
||||
if (string && (guard || chars === undefined)) {
|
||||
return string.replace(reTrimStart, '');
|
||||
}
|
||||
if (!string || !(chars = baseToString(chars))) {
|
||||
return string;
|
||||
}
|
||||
var strSymbols = stringToArray(string),
|
||||
start = charsStartIndex(strSymbols, stringToArray(chars));
|
||||
|
||||
return castSlice(strSymbols, start).join('');
|
||||
}
|
||||
|
||||
module.exports = trimStart;
|
111
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/truncate.js
generated
vendored
Normal file
111
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/truncate.js
generated
vendored
Normal file
|
@ -0,0 +1,111 @@
|
|||
var baseToString = require('./_baseToString'),
|
||||
castSlice = require('./_castSlice'),
|
||||
hasUnicode = require('./_hasUnicode'),
|
||||
isObject = require('./isObject'),
|
||||
isRegExp = require('./isRegExp'),
|
||||
stringSize = require('./_stringSize'),
|
||||
stringToArray = require('./_stringToArray'),
|
||||
toInteger = require('./toInteger'),
|
||||
toString = require('./toString');
|
||||
|
||||
/** Used as default options for `_.truncate`. */
|
||||
var DEFAULT_TRUNC_LENGTH = 30,
|
||||
DEFAULT_TRUNC_OMISSION = '...';
|
||||
|
||||
/** Used to match `RegExp` flags from their coerced string values. */
|
||||
var reFlags = /\w*$/;
|
||||
|
||||
/**
|
||||
* Truncates `string` if it's longer than the given maximum string length.
|
||||
* The last characters of the truncated string are replaced with the omission
|
||||
* string which defaults to "...".
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category String
|
||||
* @param {string} [string=''] The string to truncate.
|
||||
* @param {Object} [options={}] The options object.
|
||||
* @param {number} [options.length=30] The maximum string length.
|
||||
* @param {string} [options.omission='...'] The string to indicate text is omitted.
|
||||
* @param {RegExp|string} [options.separator] The separator pattern to truncate to.
|
||||
* @returns {string} Returns the truncated string.
|
||||
* @example
|
||||
*
|
||||
* _.truncate('hi-diddly-ho there, neighborino');
|
||||
* // => 'hi-diddly-ho there, neighbo...'
|
||||
*
|
||||
* _.truncate('hi-diddly-ho there, neighborino', {
|
||||
* 'length': 24,
|
||||
* 'separator': ' '
|
||||
* });
|
||||
* // => 'hi-diddly-ho there,...'
|
||||
*
|
||||
* _.truncate('hi-diddly-ho there, neighborino', {
|
||||
* 'length': 24,
|
||||
* 'separator': /,? +/
|
||||
* });
|
||||
* // => 'hi-diddly-ho there...'
|
||||
*
|
||||
* _.truncate('hi-diddly-ho there, neighborino', {
|
||||
* 'omission': ' [...]'
|
||||
* });
|
||||
* // => 'hi-diddly-ho there, neig [...]'
|
||||
*/
|
||||
function truncate(string, options) {
|
||||
var length = DEFAULT_TRUNC_LENGTH,
|
||||
omission = DEFAULT_TRUNC_OMISSION;
|
||||
|
||||
if (isObject(options)) {
|
||||
var separator = 'separator' in options ? options.separator : separator;
|
||||
length = 'length' in options ? toInteger(options.length) : length;
|
||||
omission = 'omission' in options ? baseToString(options.omission) : omission;
|
||||
}
|
||||
string = toString(string);
|
||||
|
||||
var strLength = string.length;
|
||||
if (hasUnicode(string)) {
|
||||
var strSymbols = stringToArray(string);
|
||||
strLength = strSymbols.length;
|
||||
}
|
||||
if (length >= strLength) {
|
||||
return string;
|
||||
}
|
||||
var end = length - stringSize(omission);
|
||||
if (end < 1) {
|
||||
return omission;
|
||||
}
|
||||
var result = strSymbols
|
||||
? castSlice(strSymbols, 0, end).join('')
|
||||
: string.slice(0, end);
|
||||
|
||||
if (separator === undefined) {
|
||||
return result + omission;
|
||||
}
|
||||
if (strSymbols) {
|
||||
end += (result.length - end);
|
||||
}
|
||||
if (isRegExp(separator)) {
|
||||
if (string.slice(end).search(separator)) {
|
||||
var match,
|
||||
substring = result;
|
||||
|
||||
if (!separator.global) {
|
||||
separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
|
||||
}
|
||||
separator.lastIndex = 0;
|
||||
while ((match = separator.exec(substring))) {
|
||||
var newEnd = match.index;
|
||||
}
|
||||
result = result.slice(0, newEnd === undefined ? end : newEnd);
|
||||
}
|
||||
} else if (string.indexOf(baseToString(separator), end) != end) {
|
||||
var index = result.lastIndexOf(separator);
|
||||
if (index > -1) {
|
||||
result = result.slice(0, index);
|
||||
}
|
||||
}
|
||||
return result + omission;
|
||||
}
|
||||
|
||||
module.exports = truncate;
|
22
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/unary.js
generated
vendored
Normal file
22
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/unary.js
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
var ary = require('./ary');
|
||||
|
||||
/**
|
||||
* Creates a function that accepts up to one argument, ignoring any
|
||||
* additional arguments.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Function
|
||||
* @param {Function} func The function to cap arguments for.
|
||||
* @returns {Function} Returns the new capped function.
|
||||
* @example
|
||||
*
|
||||
* _.map(['6', '8', '10'], _.unary(parseInt));
|
||||
* // => [6, 8, 10]
|
||||
*/
|
||||
function unary(func) {
|
||||
return ary(func, 1);
|
||||
}
|
||||
|
||||
module.exports = unary;
|
34
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/unescape.js
generated
vendored
Normal file
34
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/unescape.js
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
var toString = require('./toString'),
|
||||
unescapeHtmlChar = require('./_unescapeHtmlChar');
|
||||
|
||||
/** Used to match HTML entities and HTML characters. */
|
||||
var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
|
||||
reHasEscapedHtml = RegExp(reEscapedHtml.source);
|
||||
|
||||
/**
|
||||
* The inverse of `_.escape`; this method converts the HTML entities
|
||||
* `&`, `<`, `>`, `"`, and `'` in `string` to
|
||||
* their corresponding characters.
|
||||
*
|
||||
* **Note:** No other HTML entities are unescaped. To unescape additional
|
||||
* HTML entities use a third-party library like [_he_](https://mths.be/he).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.6.0
|
||||
* @category String
|
||||
* @param {string} [string=''] The string to unescape.
|
||||
* @returns {string} Returns the unescaped string.
|
||||
* @example
|
||||
*
|
||||
* _.unescape('fred, barney, & pebbles');
|
||||
* // => 'fred, barney, & pebbles'
|
||||
*/
|
||||
function unescape(string) {
|
||||
string = toString(string);
|
||||
return (string && reHasEscapedHtml.test(string))
|
||||
? string.replace(reEscapedHtml, unescapeHtmlChar)
|
||||
: string;
|
||||
}
|
||||
|
||||
module.exports = unescape;
|
26
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/union.js
generated
vendored
Normal file
26
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/union.js
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
var baseFlatten = require('./_baseFlatten'),
|
||||
baseRest = require('./_baseRest'),
|
||||
baseUniq = require('./_baseUniq'),
|
||||
isArrayLikeObject = require('./isArrayLikeObject');
|
||||
|
||||
/**
|
||||
* Creates an array of unique values, in order, from all given arrays using
|
||||
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
||||
* for equality comparisons.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @category Array
|
||||
* @param {...Array} [arrays] The arrays to inspect.
|
||||
* @returns {Array} Returns the new array of combined values.
|
||||
* @example
|
||||
*
|
||||
* _.union([2], [1, 2]);
|
||||
* // => [2, 1]
|
||||
*/
|
||||
var union = baseRest(function(arrays) {
|
||||
return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
|
||||
});
|
||||
|
||||
module.exports = union;
|
39
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/unionBy.js
generated
vendored
Normal file
39
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/unionBy.js
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
var baseFlatten = require('./_baseFlatten'),
|
||||
baseIteratee = require('./_baseIteratee'),
|
||||
baseRest = require('./_baseRest'),
|
||||
baseUniq = require('./_baseUniq'),
|
||||
isArrayLikeObject = require('./isArrayLikeObject'),
|
||||
last = require('./last');
|
||||
|
||||
/**
|
||||
* This method is like `_.union` except that it accepts `iteratee` which is
|
||||
* invoked for each element of each `arrays` to generate the criterion by
|
||||
* which uniqueness is computed. Result values are chosen from the first
|
||||
* array in which the value occurs. The iteratee is invoked with one argument:
|
||||
* (value).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Array
|
||||
* @param {...Array} [arrays] The arrays to inspect.
|
||||
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
|
||||
* @returns {Array} Returns the new array of combined values.
|
||||
* @example
|
||||
*
|
||||
* _.unionBy([2.1], [1.2, 2.3], Math.floor);
|
||||
* // => [2.1, 1.2]
|
||||
*
|
||||
* // The `_.property` iteratee shorthand.
|
||||
* _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
|
||||
* // => [{ 'x': 1 }, { 'x': 2 }]
|
||||
*/
|
||||
var unionBy = baseRest(function(arrays) {
|
||||
var iteratee = last(arrays);
|
||||
if (isArrayLikeObject(iteratee)) {
|
||||
iteratee = undefined;
|
||||
}
|
||||
return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), baseIteratee(iteratee, 2));
|
||||
});
|
||||
|
||||
module.exports = unionBy;
|
34
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/unionWith.js
generated
vendored
Normal file
34
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/unionWith.js
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
var baseFlatten = require('./_baseFlatten'),
|
||||
baseRest = require('./_baseRest'),
|
||||
baseUniq = require('./_baseUniq'),
|
||||
isArrayLikeObject = require('./isArrayLikeObject'),
|
||||
last = require('./last');
|
||||
|
||||
/**
|
||||
* This method is like `_.union` except that it accepts `comparator` which
|
||||
* is invoked to compare elements of `arrays`. Result values are chosen from
|
||||
* the first array in which the value occurs. The comparator is invoked
|
||||
* with two arguments: (arrVal, othVal).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Array
|
||||
* @param {...Array} [arrays] The arrays to inspect.
|
||||
* @param {Function} [comparator] The comparator invoked per element.
|
||||
* @returns {Array} Returns the new array of combined values.
|
||||
* @example
|
||||
*
|
||||
* var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
|
||||
* var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
|
||||
*
|
||||
* _.unionWith(objects, others, _.isEqual);
|
||||
* // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
|
||||
*/
|
||||
var unionWith = baseRest(function(arrays) {
|
||||
var comparator = last(arrays);
|
||||
comparator = typeof comparator == 'function' ? comparator : undefined;
|
||||
return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
|
||||
});
|
||||
|
||||
module.exports = unionWith;
|
25
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/uniq.js
generated
vendored
Normal file
25
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/uniq.js
generated
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
var baseUniq = require('./_baseUniq');
|
||||
|
||||
/**
|
||||
* Creates a duplicate-free version of an array, using
|
||||
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
||||
* for equality comparisons, in which only the first occurrence of each element
|
||||
* is kept. The order of result values is determined by the order they occur
|
||||
* in the array.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @category Array
|
||||
* @param {Array} array The array to inspect.
|
||||
* @returns {Array} Returns the new duplicate free array.
|
||||
* @example
|
||||
*
|
||||
* _.uniq([2, 1, 2]);
|
||||
* // => [2, 1]
|
||||
*/
|
||||
function uniq(array) {
|
||||
return (array && array.length) ? baseUniq(array) : [];
|
||||
}
|
||||
|
||||
module.exports = uniq;
|
31
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/uniqBy.js
generated
vendored
Normal file
31
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/uniqBy.js
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
var baseIteratee = require('./_baseIteratee'),
|
||||
baseUniq = require('./_baseUniq');
|
||||
|
||||
/**
|
||||
* This method is like `_.uniq` except that it accepts `iteratee` which is
|
||||
* invoked for each element in `array` to generate the criterion by which
|
||||
* uniqueness is computed. The order of result values is determined by the
|
||||
* order they occur in the array. The iteratee is invoked with one argument:
|
||||
* (value).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Array
|
||||
* @param {Array} array The array to inspect.
|
||||
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
|
||||
* @returns {Array} Returns the new duplicate free array.
|
||||
* @example
|
||||
*
|
||||
* _.uniqBy([2.1, 1.2, 2.3], Math.floor);
|
||||
* // => [2.1, 1.2]
|
||||
*
|
||||
* // The `_.property` iteratee shorthand.
|
||||
* _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
|
||||
* // => [{ 'x': 1 }, { 'x': 2 }]
|
||||
*/
|
||||
function uniqBy(array, iteratee) {
|
||||
return (array && array.length) ? baseUniq(array, baseIteratee(iteratee, 2)) : [];
|
||||
}
|
||||
|
||||
module.exports = uniqBy;
|
28
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/uniqWith.js
generated
vendored
Normal file
28
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/uniqWith.js
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
var baseUniq = require('./_baseUniq');
|
||||
|
||||
/**
|
||||
* This method is like `_.uniq` except that it accepts `comparator` which
|
||||
* is invoked to compare elements of `array`. The order of result values is
|
||||
* determined by the order they occur in the array.The comparator is invoked
|
||||
* with two arguments: (arrVal, othVal).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Array
|
||||
* @param {Array} array The array to inspect.
|
||||
* @param {Function} [comparator] The comparator invoked per element.
|
||||
* @returns {Array} Returns the new duplicate free array.
|
||||
* @example
|
||||
*
|
||||
* var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
|
||||
*
|
||||
* _.uniqWith(objects, _.isEqual);
|
||||
* // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
|
||||
*/
|
||||
function uniqWith(array, comparator) {
|
||||
comparator = typeof comparator == 'function' ? comparator : undefined;
|
||||
return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
|
||||
}
|
||||
|
||||
module.exports = uniqWith;
|
28
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/uniqueId.js
generated
vendored
Normal file
28
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/uniqueId.js
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
var toString = require('./toString');
|
||||
|
||||
/** Used to generate unique IDs. */
|
||||
var idCounter = 0;
|
||||
|
||||
/**
|
||||
* Generates a unique ID. If `prefix` is given, the ID is appended to it.
|
||||
*
|
||||
* @static
|
||||
* @since 0.1.0
|
||||
* @memberOf _
|
||||
* @category Util
|
||||
* @param {string} [prefix=''] The value to prefix the ID with.
|
||||
* @returns {string} Returns the unique ID.
|
||||
* @example
|
||||
*
|
||||
* _.uniqueId('contact_');
|
||||
* // => 'contact_104'
|
||||
*
|
||||
* _.uniqueId();
|
||||
* // => '105'
|
||||
*/
|
||||
function uniqueId(prefix) {
|
||||
var id = ++idCounter;
|
||||
return toString(prefix) + id;
|
||||
}
|
||||
|
||||
module.exports = uniqueId;
|
34
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/unset.js
generated
vendored
Normal file
34
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/unset.js
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
var baseUnset = require('./_baseUnset');
|
||||
|
||||
/**
|
||||
* Removes the property at `path` of `object`.
|
||||
*
|
||||
* **Note:** This method mutates `object`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Object
|
||||
* @param {Object} object The object to modify.
|
||||
* @param {Array|string} path The path of the property to unset.
|
||||
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': [{ 'b': { 'c': 7 } }] };
|
||||
* _.unset(object, 'a[0].b.c');
|
||||
* // => true
|
||||
*
|
||||
* console.log(object);
|
||||
* // => { 'a': [{ 'b': {} }] };
|
||||
*
|
||||
* _.unset(object, ['a', '0', 'b', 'c']);
|
||||
* // => true
|
||||
*
|
||||
* console.log(object);
|
||||
* // => { 'a': [{ 'b': {} }] };
|
||||
*/
|
||||
function unset(object, path) {
|
||||
return object == null ? true : baseUnset(object, path);
|
||||
}
|
||||
|
||||
module.exports = unset;
|
45
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/unzip.js
generated
vendored
Normal file
45
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/unzip.js
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
var arrayFilter = require('./_arrayFilter'),
|
||||
arrayMap = require('./_arrayMap'),
|
||||
baseProperty = require('./_baseProperty'),
|
||||
baseTimes = require('./_baseTimes'),
|
||||
isArrayLikeObject = require('./isArrayLikeObject');
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
var nativeMax = Math.max;
|
||||
|
||||
/**
|
||||
* This method is like `_.zip` except that it accepts an array of grouped
|
||||
* elements and creates an array regrouping the elements to their pre-zip
|
||||
* configuration.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 1.2.0
|
||||
* @category Array
|
||||
* @param {Array} array The array of grouped elements to process.
|
||||
* @returns {Array} Returns the new array of regrouped elements.
|
||||
* @example
|
||||
*
|
||||
* var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
|
||||
* // => [['a', 1, true], ['b', 2, false]]
|
||||
*
|
||||
* _.unzip(zipped);
|
||||
* // => [['a', 'b'], [1, 2], [true, false]]
|
||||
*/
|
||||
function unzip(array) {
|
||||
if (!(array && array.length)) {
|
||||
return [];
|
||||
}
|
||||
var length = 0;
|
||||
array = arrayFilter(array, function(group) {
|
||||
if (isArrayLikeObject(group)) {
|
||||
length = nativeMax(group.length, length);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return baseTimes(length, function(index) {
|
||||
return arrayMap(array, baseProperty(index));
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = unzip;
|
39
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/unzipWith.js
generated
vendored
Normal file
39
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/unzipWith.js
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
var apply = require('./_apply'),
|
||||
arrayMap = require('./_arrayMap'),
|
||||
unzip = require('./unzip');
|
||||
|
||||
/**
|
||||
* This method is like `_.unzip` except that it accepts `iteratee` to specify
|
||||
* how regrouped values should be combined. The iteratee is invoked with the
|
||||
* elements of each group: (...group).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.8.0
|
||||
* @category Array
|
||||
* @param {Array} array The array of grouped elements to process.
|
||||
* @param {Function} [iteratee=_.identity] The function to combine
|
||||
* regrouped values.
|
||||
* @returns {Array} Returns the new array of regrouped elements.
|
||||
* @example
|
||||
*
|
||||
* var zipped = _.zip([1, 2], [10, 20], [100, 200]);
|
||||
* // => [[1, 10, 100], [2, 20, 200]]
|
||||
*
|
||||
* _.unzipWith(zipped, _.add);
|
||||
* // => [3, 30, 300]
|
||||
*/
|
||||
function unzipWith(array, iteratee) {
|
||||
if (!(array && array.length)) {
|
||||
return [];
|
||||
}
|
||||
var result = unzip(array);
|
||||
if (iteratee == null) {
|
||||
return result;
|
||||
}
|
||||
return arrayMap(result, function(group) {
|
||||
return apply(iteratee, undefined, group);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = unzipWith;
|
35
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/update.js
generated
vendored
Normal file
35
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/update.js
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
var baseUpdate = require('./_baseUpdate'),
|
||||
castFunction = require('./_castFunction');
|
||||
|
||||
/**
|
||||
* This method is like `_.set` except that accepts `updater` to produce the
|
||||
* value to set. Use `_.updateWith` to customize `path` creation. The `updater`
|
||||
* is invoked with one argument: (value).
|
||||
*
|
||||
* **Note:** This method mutates `object`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.6.0
|
||||
* @category Object
|
||||
* @param {Object} object The object to modify.
|
||||
* @param {Array|string} path The path of the property to set.
|
||||
* @param {Function} updater The function to produce the updated value.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
|
||||
*
|
||||
* _.update(object, 'a[0].b.c', function(n) { return n * n; });
|
||||
* console.log(object.a[0].b.c);
|
||||
* // => 9
|
||||
*
|
||||
* _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
|
||||
* console.log(object.x[0].y.z);
|
||||
* // => 0
|
||||
*/
|
||||
function update(object, path, updater) {
|
||||
return object == null ? object : baseUpdate(object, path, castFunction(updater));
|
||||
}
|
||||
|
||||
module.exports = update;
|
33
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/updateWith.js
generated
vendored
Normal file
33
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/updateWith.js
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
var baseUpdate = require('./_baseUpdate'),
|
||||
castFunction = require('./_castFunction');
|
||||
|
||||
/**
|
||||
* This method is like `_.update` except that it accepts `customizer` which is
|
||||
* invoked to produce the objects of `path`. If `customizer` returns `undefined`
|
||||
* path creation is handled by the method instead. The `customizer` is invoked
|
||||
* with three arguments: (nsValue, key, nsObject).
|
||||
*
|
||||
* **Note:** This method mutates `object`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.6.0
|
||||
* @category Object
|
||||
* @param {Object} object The object to modify.
|
||||
* @param {Array|string} path The path of the property to set.
|
||||
* @param {Function} updater The function to produce the updated value.
|
||||
* @param {Function} [customizer] The function to customize assigned values.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @example
|
||||
*
|
||||
* var object = {};
|
||||
*
|
||||
* _.updateWith(object, '[0][1]', _.constant('a'), Object);
|
||||
* // => { '0': { '1': 'a' } }
|
||||
*/
|
||||
function updateWith(object, path, updater, customizer) {
|
||||
customizer = typeof customizer == 'function' ? customizer : undefined;
|
||||
return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
|
||||
}
|
||||
|
||||
module.exports = updateWith;
|
27
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/upperCase.js
generated
vendored
Normal file
27
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/upperCase.js
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
var createCompounder = require('./_createCompounder');
|
||||
|
||||
/**
|
||||
* Converts `string`, as space separated words, to upper case.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category String
|
||||
* @param {string} [string=''] The string to convert.
|
||||
* @returns {string} Returns the upper cased string.
|
||||
* @example
|
||||
*
|
||||
* _.upperCase('--foo-bar');
|
||||
* // => 'FOO BAR'
|
||||
*
|
||||
* _.upperCase('fooBar');
|
||||
* // => 'FOO BAR'
|
||||
*
|
||||
* _.upperCase('__foo_bar__');
|
||||
* // => 'FOO BAR'
|
||||
*/
|
||||
var upperCase = createCompounder(function(result, word, index) {
|
||||
return result + (index ? ' ' : '') + word.toUpperCase();
|
||||
});
|
||||
|
||||
module.exports = upperCase;
|
22
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/upperFirst.js
generated
vendored
Normal file
22
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/upperFirst.js
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
var createCaseFirst = require('./_createCaseFirst');
|
||||
|
||||
/**
|
||||
* Converts the first character of `string` to upper case.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category String
|
||||
* @param {string} [string=''] The string to convert.
|
||||
* @returns {string} Returns the converted string.
|
||||
* @example
|
||||
*
|
||||
* _.upperFirst('fred');
|
||||
* // => 'Fred'
|
||||
*
|
||||
* _.upperFirst('FRED');
|
||||
* // => 'FRED'
|
||||
*/
|
||||
var upperFirst = createCaseFirst('toUpperCase');
|
||||
|
||||
module.exports = upperFirst;
|
34
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/util.js
generated
vendored
Normal file
34
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/util.js
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
module.exports = {
|
||||
'attempt': require('./attempt'),
|
||||
'bindAll': require('./bindAll'),
|
||||
'cond': require('./cond'),
|
||||
'conforms': require('./conforms'),
|
||||
'constant': require('./constant'),
|
||||
'defaultTo': require('./defaultTo'),
|
||||
'flow': require('./flow'),
|
||||
'flowRight': require('./flowRight'),
|
||||
'identity': require('./identity'),
|
||||
'iteratee': require('./iteratee'),
|
||||
'matches': require('./matches'),
|
||||
'matchesProperty': require('./matchesProperty'),
|
||||
'method': require('./method'),
|
||||
'methodOf': require('./methodOf'),
|
||||
'mixin': require('./mixin'),
|
||||
'noop': require('./noop'),
|
||||
'nthArg': require('./nthArg'),
|
||||
'over': require('./over'),
|
||||
'overEvery': require('./overEvery'),
|
||||
'overSome': require('./overSome'),
|
||||
'property': require('./property'),
|
||||
'propertyOf': require('./propertyOf'),
|
||||
'range': require('./range'),
|
||||
'rangeRight': require('./rangeRight'),
|
||||
'stubArray': require('./stubArray'),
|
||||
'stubFalse': require('./stubFalse'),
|
||||
'stubObject': require('./stubObject'),
|
||||
'stubString': require('./stubString'),
|
||||
'stubTrue': require('./stubTrue'),
|
||||
'times': require('./times'),
|
||||
'toPath': require('./toPath'),
|
||||
'uniqueId': require('./uniqueId')
|
||||
};
|
1
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/value.js
generated
vendored
Normal file
1
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/value.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
module.exports = require('./wrapperValue');
|
1
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/valueOf.js
generated
vendored
Normal file
1
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/valueOf.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
module.exports = require('./wrapperValue');
|
34
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/values.js
generated
vendored
Normal file
34
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/values.js
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
var baseValues = require('./_baseValues'),
|
||||
keys = require('./keys');
|
||||
|
||||
/**
|
||||
* Creates an array of the own enumerable string keyed property values of `object`.
|
||||
*
|
||||
* **Note:** Non-object values are coerced to objects.
|
||||
*
|
||||
* @static
|
||||
* @since 0.1.0
|
||||
* @memberOf _
|
||||
* @category Object
|
||||
* @param {Object} object The object to query.
|
||||
* @returns {Array} Returns the array of property values.
|
||||
* @example
|
||||
*
|
||||
* function Foo() {
|
||||
* this.a = 1;
|
||||
* this.b = 2;
|
||||
* }
|
||||
*
|
||||
* Foo.prototype.c = 3;
|
||||
*
|
||||
* _.values(new Foo);
|
||||
* // => [1, 2] (iteration order is not guaranteed)
|
||||
*
|
||||
* _.values('hi');
|
||||
* // => ['h', 'i']
|
||||
*/
|
||||
function values(object) {
|
||||
return object == null ? [] : baseValues(object, keys(object));
|
||||
}
|
||||
|
||||
module.exports = values;
|
32
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/valuesIn.js
generated
vendored
Normal file
32
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/valuesIn.js
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
var baseValues = require('./_baseValues'),
|
||||
keysIn = require('./keysIn');
|
||||
|
||||
/**
|
||||
* Creates an array of the own and inherited enumerable string keyed property
|
||||
* values of `object`.
|
||||
*
|
||||
* **Note:** Non-object values are coerced to objects.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.0.0
|
||||
* @category Object
|
||||
* @param {Object} object The object to query.
|
||||
* @returns {Array} Returns the array of property values.
|
||||
* @example
|
||||
*
|
||||
* function Foo() {
|
||||
* this.a = 1;
|
||||
* this.b = 2;
|
||||
* }
|
||||
*
|
||||
* Foo.prototype.c = 3;
|
||||
*
|
||||
* _.valuesIn(new Foo);
|
||||
* // => [1, 2, 3] (iteration order is not guaranteed)
|
||||
*/
|
||||
function valuesIn(object) {
|
||||
return object == null ? [] : baseValues(object, keysIn(object));
|
||||
}
|
||||
|
||||
module.exports = valuesIn;
|
31
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/without.js
generated
vendored
Normal file
31
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/without.js
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
var baseDifference = require('./_baseDifference'),
|
||||
baseRest = require('./_baseRest'),
|
||||
isArrayLikeObject = require('./isArrayLikeObject');
|
||||
|
||||
/**
|
||||
* Creates an array excluding all given values using
|
||||
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
||||
* for equality comparisons.
|
||||
*
|
||||
* **Note:** Unlike `_.pull`, this method returns a new array.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @category Array
|
||||
* @param {Array} array The array to inspect.
|
||||
* @param {...*} [values] The values to exclude.
|
||||
* @returns {Array} Returns the new array of filtered values.
|
||||
* @see _.difference, _.xor
|
||||
* @example
|
||||
*
|
||||
* _.without([2, 1, 2, 3], 1, 2);
|
||||
* // => [3]
|
||||
*/
|
||||
var without = baseRest(function(array, values) {
|
||||
return isArrayLikeObject(array)
|
||||
? baseDifference(array, values)
|
||||
: [];
|
||||
});
|
||||
|
||||
module.exports = without;
|
35
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/words.js
generated
vendored
Normal file
35
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/words.js
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
var asciiWords = require('./_asciiWords'),
|
||||
hasUnicodeWord = require('./_hasUnicodeWord'),
|
||||
toString = require('./toString'),
|
||||
unicodeWords = require('./_unicodeWords');
|
||||
|
||||
/**
|
||||
* Splits `string` into an array of its words.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.0.0
|
||||
* @category String
|
||||
* @param {string} [string=''] The string to inspect.
|
||||
* @param {RegExp|string} [pattern] The pattern to match words.
|
||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
|
||||
* @returns {Array} Returns the words of `string`.
|
||||
* @example
|
||||
*
|
||||
* _.words('fred, barney, & pebbles');
|
||||
* // => ['fred', 'barney', 'pebbles']
|
||||
*
|
||||
* _.words('fred, barney, & pebbles', /[^, ]+/g);
|
||||
* // => ['fred', 'barney', '&', 'pebbles']
|
||||
*/
|
||||
function words(string, pattern, guard) {
|
||||
string = toString(string);
|
||||
pattern = guard ? undefined : pattern;
|
||||
|
||||
if (pattern === undefined) {
|
||||
return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
|
||||
}
|
||||
return string.match(pattern) || [];
|
||||
}
|
||||
|
||||
module.exports = words;
|
30
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/wrap.js
generated
vendored
Normal file
30
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/wrap.js
generated
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
var castFunction = require('./_castFunction'),
|
||||
partial = require('./partial');
|
||||
|
||||
/**
|
||||
* Creates a function that provides `value` to `wrapper` as its first
|
||||
* argument. Any additional arguments provided to the function are appended
|
||||
* to those provided to the `wrapper`. The wrapper is invoked with the `this`
|
||||
* binding of the created function.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @category Function
|
||||
* @param {*} value The value to wrap.
|
||||
* @param {Function} [wrapper=identity] The wrapper function.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
* var p = _.wrap(_.escape, function(func, text) {
|
||||
* return '<p>' + func(text) + '</p>';
|
||||
* });
|
||||
*
|
||||
* p('fred, barney, & pebbles');
|
||||
* // => '<p>fred, barney, & pebbles</p>'
|
||||
*/
|
||||
function wrap(value, wrapper) {
|
||||
return partial(castFunction(wrapper), value);
|
||||
}
|
||||
|
||||
module.exports = wrap;
|
48
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/wrapperAt.js
generated
vendored
Normal file
48
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/wrapperAt.js
generated
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
var LazyWrapper = require('./_LazyWrapper'),
|
||||
LodashWrapper = require('./_LodashWrapper'),
|
||||
baseAt = require('./_baseAt'),
|
||||
flatRest = require('./_flatRest'),
|
||||
isIndex = require('./_isIndex'),
|
||||
thru = require('./thru');
|
||||
|
||||
/**
|
||||
* This method is the wrapper version of `_.at`.
|
||||
*
|
||||
* @name at
|
||||
* @memberOf _
|
||||
* @since 1.0.0
|
||||
* @category Seq
|
||||
* @param {...(string|string[])} [paths] The property paths to pick.
|
||||
* @returns {Object} Returns the new `lodash` wrapper instance.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
|
||||
*
|
||||
* _(object).at(['a[0].b.c', 'a[1]']).value();
|
||||
* // => [3, 4]
|
||||
*/
|
||||
var wrapperAt = flatRest(function(paths) {
|
||||
var length = paths.length,
|
||||
start = length ? paths[0] : 0,
|
||||
value = this.__wrapped__,
|
||||
interceptor = function(object) { return baseAt(object, paths); };
|
||||
|
||||
if (length > 1 || this.__actions__.length ||
|
||||
!(value instanceof LazyWrapper) || !isIndex(start)) {
|
||||
return this.thru(interceptor);
|
||||
}
|
||||
value = value.slice(start, +start + (length ? 1 : 0));
|
||||
value.__actions__.push({
|
||||
'func': thru,
|
||||
'args': [interceptor],
|
||||
'thisArg': undefined
|
||||
});
|
||||
return new LodashWrapper(value, this.__chain__).thru(function(array) {
|
||||
if (length && !array.length) {
|
||||
array.push(undefined);
|
||||
}
|
||||
return array;
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = wrapperAt;
|
34
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/wrapperChain.js
generated
vendored
Normal file
34
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/wrapperChain.js
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
var chain = require('./chain');
|
||||
|
||||
/**
|
||||
* Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
|
||||
*
|
||||
* @name chain
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @category Seq
|
||||
* @returns {Object} Returns the new `lodash` wrapper instance.
|
||||
* @example
|
||||
*
|
||||
* var users = [
|
||||
* { 'user': 'barney', 'age': 36 },
|
||||
* { 'user': 'fred', 'age': 40 }
|
||||
* ];
|
||||
*
|
||||
* // A sequence without explicit chaining.
|
||||
* _(users).head();
|
||||
* // => { 'user': 'barney', 'age': 36 }
|
||||
*
|
||||
* // A sequence with explicit chaining.
|
||||
* _(users)
|
||||
* .chain()
|
||||
* .head()
|
||||
* .pick('user')
|
||||
* .value();
|
||||
* // => { 'user': 'barney' }
|
||||
*/
|
||||
function wrapperChain() {
|
||||
return chain(this);
|
||||
}
|
||||
|
||||
module.exports = wrapperChain;
|
147
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/wrapperLodash.js
generated
vendored
Normal file
147
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/wrapperLodash.js
generated
vendored
Normal file
|
@ -0,0 +1,147 @@
|
|||
var LazyWrapper = require('./_LazyWrapper'),
|
||||
LodashWrapper = require('./_LodashWrapper'),
|
||||
baseLodash = require('./_baseLodash'),
|
||||
isArray = require('./isArray'),
|
||||
isObjectLike = require('./isObjectLike'),
|
||||
wrapperClone = require('./_wrapperClone');
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* Creates a `lodash` object which wraps `value` to enable implicit method
|
||||
* chain sequences. Methods that operate on and return arrays, collections,
|
||||
* and functions can be chained together. Methods that retrieve a single value
|
||||
* or may return a primitive value will automatically end the chain sequence
|
||||
* and return the unwrapped value. Otherwise, the value must be unwrapped
|
||||
* with `_#value`.
|
||||
*
|
||||
* Explicit chain sequences, which must be unwrapped with `_#value`, may be
|
||||
* enabled using `_.chain`.
|
||||
*
|
||||
* The execution of chained methods is lazy, that is, it's deferred until
|
||||
* `_#value` is implicitly or explicitly called.
|
||||
*
|
||||
* Lazy evaluation allows several methods to support shortcut fusion.
|
||||
* Shortcut fusion is an optimization to merge iteratee calls; this avoids
|
||||
* the creation of intermediate arrays and can greatly reduce the number of
|
||||
* iteratee executions. Sections of a chain sequence qualify for shortcut
|
||||
* fusion if the section is applied to an array and iteratees accept only
|
||||
* one argument. The heuristic for whether a section qualifies for shortcut
|
||||
* fusion is subject to change.
|
||||
*
|
||||
* Chaining is supported in custom builds as long as the `_#value` method is
|
||||
* directly or indirectly included in the build.
|
||||
*
|
||||
* In addition to lodash methods, wrappers have `Array` and `String` methods.
|
||||
*
|
||||
* The wrapper `Array` methods are:
|
||||
* `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
|
||||
*
|
||||
* The wrapper `String` methods are:
|
||||
* `replace` and `split`
|
||||
*
|
||||
* The wrapper methods that support shortcut fusion are:
|
||||
* `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
|
||||
* `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
|
||||
* `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
|
||||
*
|
||||
* The chainable wrapper methods are:
|
||||
* `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
|
||||
* `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
|
||||
* `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
|
||||
* `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
|
||||
* `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
|
||||
* `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
|
||||
* `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
|
||||
* `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
|
||||
* `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
|
||||
* `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
|
||||
* `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
|
||||
* `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
|
||||
* `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
|
||||
* `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
|
||||
* `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
|
||||
* `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
|
||||
* `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
|
||||
* `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
|
||||
* `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
|
||||
* `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
|
||||
* `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
|
||||
* `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
|
||||
* `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
|
||||
* `zipObject`, `zipObjectDeep`, and `zipWith`
|
||||
*
|
||||
* The wrapper methods that are **not** chainable by default are:
|
||||
* `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
|
||||
* `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
|
||||
* `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
|
||||
* `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
|
||||
* `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
|
||||
* `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
|
||||
* `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
|
||||
* `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
|
||||
* `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
|
||||
* `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
|
||||
* `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
|
||||
* `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
|
||||
* `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
|
||||
* `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
|
||||
* `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
|
||||
* `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
|
||||
* `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
|
||||
* `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
|
||||
* `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
|
||||
* `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
|
||||
* `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
|
||||
* `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
|
||||
* `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
|
||||
* `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
|
||||
* `upperFirst`, `value`, and `words`
|
||||
*
|
||||
* @name _
|
||||
* @constructor
|
||||
* @category Seq
|
||||
* @param {*} value The value to wrap in a `lodash` instance.
|
||||
* @returns {Object} Returns the new `lodash` wrapper instance.
|
||||
* @example
|
||||
*
|
||||
* function square(n) {
|
||||
* return n * n;
|
||||
* }
|
||||
*
|
||||
* var wrapped = _([1, 2, 3]);
|
||||
*
|
||||
* // Returns an unwrapped value.
|
||||
* wrapped.reduce(_.add);
|
||||
* // => 6
|
||||
*
|
||||
* // Returns a wrapped value.
|
||||
* var squares = wrapped.map(square);
|
||||
*
|
||||
* _.isArray(squares);
|
||||
* // => false
|
||||
*
|
||||
* _.isArray(squares.value());
|
||||
* // => true
|
||||
*/
|
||||
function lodash(value) {
|
||||
if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
|
||||
if (value instanceof LodashWrapper) {
|
||||
return value;
|
||||
}
|
||||
if (hasOwnProperty.call(value, '__wrapped__')) {
|
||||
return wrapperClone(value);
|
||||
}
|
||||
}
|
||||
return new LodashWrapper(value);
|
||||
}
|
||||
|
||||
// Ensure wrappers are instances of `baseLodash`.
|
||||
lodash.prototype = baseLodash.prototype;
|
||||
lodash.prototype.constructor = lodash;
|
||||
|
||||
module.exports = lodash;
|
44
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/wrapperReverse.js
generated
vendored
Normal file
44
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/wrapperReverse.js
generated
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
var LazyWrapper = require('./_LazyWrapper'),
|
||||
LodashWrapper = require('./_LodashWrapper'),
|
||||
reverse = require('./reverse'),
|
||||
thru = require('./thru');
|
||||
|
||||
/**
|
||||
* This method is the wrapper version of `_.reverse`.
|
||||
*
|
||||
* **Note:** This method mutates the wrapped array.
|
||||
*
|
||||
* @name reverse
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @category Seq
|
||||
* @returns {Object} Returns the new `lodash` wrapper instance.
|
||||
* @example
|
||||
*
|
||||
* var array = [1, 2, 3];
|
||||
*
|
||||
* _(array).reverse().value()
|
||||
* // => [3, 2, 1]
|
||||
*
|
||||
* console.log(array);
|
||||
* // => [3, 2, 1]
|
||||
*/
|
||||
function wrapperReverse() {
|
||||
var value = this.__wrapped__;
|
||||
if (value instanceof LazyWrapper) {
|
||||
var wrapped = value;
|
||||
if (this.__actions__.length) {
|
||||
wrapped = new LazyWrapper(this);
|
||||
}
|
||||
wrapped = wrapped.reverse();
|
||||
wrapped.__actions__.push({
|
||||
'func': thru,
|
||||
'args': [reverse],
|
||||
'thisArg': undefined
|
||||
});
|
||||
return new LodashWrapper(wrapped, this.__chain__);
|
||||
}
|
||||
return this.thru(reverse);
|
||||
}
|
||||
|
||||
module.exports = wrapperReverse;
|
21
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/wrapperValue.js
generated
vendored
Normal file
21
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/wrapperValue.js
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
var baseWrapperValue = require('./_baseWrapperValue');
|
||||
|
||||
/**
|
||||
* Executes the chain sequence to resolve the unwrapped value.
|
||||
*
|
||||
* @name value
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @alias toJSON, valueOf
|
||||
* @category Seq
|
||||
* @returns {*} Returns the resolved unwrapped value.
|
||||
* @example
|
||||
*
|
||||
* _([1, 2, 3]).value();
|
||||
* // => [1, 2, 3]
|
||||
*/
|
||||
function wrapperValue() {
|
||||
return baseWrapperValue(this.__wrapped__, this.__actions__);
|
||||
}
|
||||
|
||||
module.exports = wrapperValue;
|
28
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/xor.js
generated
vendored
Normal file
28
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/xor.js
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
var arrayFilter = require('./_arrayFilter'),
|
||||
baseRest = require('./_baseRest'),
|
||||
baseXor = require('./_baseXor'),
|
||||
isArrayLikeObject = require('./isArrayLikeObject');
|
||||
|
||||
/**
|
||||
* Creates an array of unique values that is the
|
||||
* [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
|
||||
* of the given arrays. The order of result values is determined by the order
|
||||
* they occur in the arrays.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 2.4.0
|
||||
* @category Array
|
||||
* @param {...Array} [arrays] The arrays to inspect.
|
||||
* @returns {Array} Returns the new array of filtered values.
|
||||
* @see _.difference, _.without
|
||||
* @example
|
||||
*
|
||||
* _.xor([2, 1], [2, 3]);
|
||||
* // => [1, 3]
|
||||
*/
|
||||
var xor = baseRest(function(arrays) {
|
||||
return baseXor(arrayFilter(arrays, isArrayLikeObject));
|
||||
});
|
||||
|
||||
module.exports = xor;
|
39
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/xorBy.js
generated
vendored
Normal file
39
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/xorBy.js
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
var arrayFilter = require('./_arrayFilter'),
|
||||
baseIteratee = require('./_baseIteratee'),
|
||||
baseRest = require('./_baseRest'),
|
||||
baseXor = require('./_baseXor'),
|
||||
isArrayLikeObject = require('./isArrayLikeObject'),
|
||||
last = require('./last');
|
||||
|
||||
/**
|
||||
* This method is like `_.xor` except that it accepts `iteratee` which is
|
||||
* invoked for each element of each `arrays` to generate the criterion by
|
||||
* which by which they're compared. The order of result values is determined
|
||||
* by the order they occur in the arrays. The iteratee is invoked with one
|
||||
* argument: (value).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Array
|
||||
* @param {...Array} [arrays] The arrays to inspect.
|
||||
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
|
||||
* @returns {Array} Returns the new array of filtered values.
|
||||
* @example
|
||||
*
|
||||
* _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
|
||||
* // => [1.2, 3.4]
|
||||
*
|
||||
* // The `_.property` iteratee shorthand.
|
||||
* _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
|
||||
* // => [{ 'x': 2 }]
|
||||
*/
|
||||
var xorBy = baseRest(function(arrays) {
|
||||
var iteratee = last(arrays);
|
||||
if (isArrayLikeObject(iteratee)) {
|
||||
iteratee = undefined;
|
||||
}
|
||||
return baseXor(arrayFilter(arrays, isArrayLikeObject), baseIteratee(iteratee, 2));
|
||||
});
|
||||
|
||||
module.exports = xorBy;
|
34
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/xorWith.js
generated
vendored
Normal file
34
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/xorWith.js
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
var arrayFilter = require('./_arrayFilter'),
|
||||
baseRest = require('./_baseRest'),
|
||||
baseXor = require('./_baseXor'),
|
||||
isArrayLikeObject = require('./isArrayLikeObject'),
|
||||
last = require('./last');
|
||||
|
||||
/**
|
||||
* This method is like `_.xor` except that it accepts `comparator` which is
|
||||
* invoked to compare elements of `arrays`. The order of result values is
|
||||
* determined by the order they occur in the arrays. The comparator is invoked
|
||||
* with two arguments: (arrVal, othVal).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Array
|
||||
* @param {...Array} [arrays] The arrays to inspect.
|
||||
* @param {Function} [comparator] The comparator invoked per element.
|
||||
* @returns {Array} Returns the new array of filtered values.
|
||||
* @example
|
||||
*
|
||||
* var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
|
||||
* var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
|
||||
*
|
||||
* _.xorWith(objects, others, _.isEqual);
|
||||
* // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
|
||||
*/
|
||||
var xorWith = baseRest(function(arrays) {
|
||||
var comparator = last(arrays);
|
||||
comparator = typeof comparator == 'function' ? comparator : undefined;
|
||||
return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
|
||||
});
|
||||
|
||||
module.exports = xorWith;
|
22
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/zip.js
generated
vendored
Normal file
22
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/zip.js
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
var baseRest = require('./_baseRest'),
|
||||
unzip = require('./unzip');
|
||||
|
||||
/**
|
||||
* Creates an array of grouped elements, the first of which contains the
|
||||
* first elements of the given arrays, the second of which contains the
|
||||
* second elements of the given arrays, and so on.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @category Array
|
||||
* @param {...Array} [arrays] The arrays to process.
|
||||
* @returns {Array} Returns the new array of grouped elements.
|
||||
* @example
|
||||
*
|
||||
* _.zip(['a', 'b'], [1, 2], [true, false]);
|
||||
* // => [['a', 1, true], ['b', 2, false]]
|
||||
*/
|
||||
var zip = baseRest(unzip);
|
||||
|
||||
module.exports = zip;
|
24
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/zipObject.js
generated
vendored
Normal file
24
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/zipObject.js
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
var assignValue = require('./_assignValue'),
|
||||
baseZipObject = require('./_baseZipObject');
|
||||
|
||||
/**
|
||||
* This method is like `_.fromPairs` except that it accepts two arrays,
|
||||
* one of property identifiers and one of corresponding values.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.4.0
|
||||
* @category Array
|
||||
* @param {Array} [props=[]] The property identifiers.
|
||||
* @param {Array} [values=[]] The property values.
|
||||
* @returns {Object} Returns the new object.
|
||||
* @example
|
||||
*
|
||||
* _.zipObject(['a', 'b'], [1, 2]);
|
||||
* // => { 'a': 1, 'b': 2 }
|
||||
*/
|
||||
function zipObject(props, values) {
|
||||
return baseZipObject(props || [], values || [], assignValue);
|
||||
}
|
||||
|
||||
module.exports = zipObject;
|
23
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/zipObjectDeep.js
generated
vendored
Normal file
23
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/zipObjectDeep.js
generated
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
var baseSet = require('./_baseSet'),
|
||||
baseZipObject = require('./_baseZipObject');
|
||||
|
||||
/**
|
||||
* This method is like `_.zipObject` except that it supports property paths.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.1.0
|
||||
* @category Array
|
||||
* @param {Array} [props=[]] The property identifiers.
|
||||
* @param {Array} [values=[]] The property values.
|
||||
* @returns {Object} Returns the new object.
|
||||
* @example
|
||||
*
|
||||
* _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
|
||||
* // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
|
||||
*/
|
||||
function zipObjectDeep(props, values) {
|
||||
return baseZipObject(props || [], values || [], baseSet);
|
||||
}
|
||||
|
||||
module.exports = zipObjectDeep;
|
32
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/zipWith.js
generated
vendored
Normal file
32
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lodash/zipWith.js
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
var baseRest = require('./_baseRest'),
|
||||
unzipWith = require('./unzipWith');
|
||||
|
||||
/**
|
||||
* This method is like `_.zip` except that it accepts `iteratee` to specify
|
||||
* how grouped values should be combined. The iteratee is invoked with the
|
||||
* elements of each group: (...group).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.8.0
|
||||
* @category Array
|
||||
* @param {...Array} [arrays] The arrays to process.
|
||||
* @param {Function} [iteratee=_.identity] The function to combine
|
||||
* grouped values.
|
||||
* @returns {Array} Returns the new array of grouped elements.
|
||||
* @example
|
||||
*
|
||||
* _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
|
||||
* return a + b + c;
|
||||
* });
|
||||
* // => [111, 222]
|
||||
*/
|
||||
var zipWith = baseRest(function(arrays) {
|
||||
var length = arrays.length,
|
||||
iteratee = length > 1 ? arrays[length - 1] : undefined;
|
||||
|
||||
iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
|
||||
return unzipWith(arrays, iteratee);
|
||||
});
|
||||
|
||||
module.exports = zipWith;
|
21
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/longest/LICENSE
generated
vendored
Normal file
21
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/longest/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2015, Jon Schlinkert.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
65
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/longest/README.md
generated
vendored
Normal file
65
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/longest/README.md
generated
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
# longest [![NPM version](https://badge.fury.io/js/longest.svg)](http://badge.fury.io/js/longest) [![Build Status](https://travis-ci.org/jonschlinkert/longest.svg)](https://travis-ci.org/jonschlinkert/longest)
|
||||
|
||||
> Get the longest item in an array.
|
||||
|
||||
## Install with [npm](npmjs.org)
|
||||
|
||||
```bash
|
||||
npm i longest --save
|
||||
```
|
||||
### Install with [bower](https://github.com/bower/bower)
|
||||
|
||||
```bash
|
||||
bower install longest --save
|
||||
```
|
||||
|
||||
## Running tests
|
||||
Install dev dependencies.
|
||||
|
||||
```bash
|
||||
npm i -d && npm test
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var longest = require('longest');
|
||||
longest(['a', 'abcde', 'abc']);
|
||||
//=> 'abcde'
|
||||
|
||||
longest(['a', 'abcde', 'abc']).length;
|
||||
//=> 5
|
||||
```
|
||||
|
||||
## Related projects
|
||||
* [longest-value](https://github.com/jonschlinkert/longest-value): Get the longest value for the given property from an array of objects. Useful for aligning values.
|
||||
* [right-align-values](https://github.com/jonschlinkert/right-align-values): Right align the values of a given property for each object in an array. Useful for creating text columns or tables.
|
||||
* [right-pad-values](https://github.com/jonschlinkert/right-pad-values): Right pad the values of a given property for each object in an array. Useful for creating text columns or tables.
|
||||
* [repeat-string](https://github.com/jonschlinkert/repeat-string): Repeat the given string n times. Fastest implementation for repeating a string.
|
||||
* [pad-right](https://github.com/jonschlinkert/pad-right): Right pad a string with zeros or a specified string. Fastest implementation.
|
||||
* [pad-left](https://github.com/jonschlinkert/pad-left): Left pad a string with zeros or a specified string. Fastest implementation.
|
||||
|
||||
## Running tests
|
||||
Install dev dependencies.
|
||||
|
||||
```bash
|
||||
npm i -d && npm test
|
||||
```
|
||||
|
||||
## Contributing
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/longest/issues)
|
||||
|
||||
## Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
+ [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
|
||||
|
||||
## License
|
||||
Copyright (c) 2015 Jon Schlinkert
|
||||
Released under the MIT license
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 31, 2015._
|
37
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/longest/index.js
generated
vendored
Normal file
37
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/longest/index.js
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*!
|
||||
* longest <https://github.com/jonschlinkert/longest>
|
||||
*
|
||||
* Copyright (c) 2014-2015, Jon Schlinkert.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = function(arr) {
|
||||
if (!arr) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var len = arr.length;
|
||||
if (!len) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var c = 0;
|
||||
var i = 0;
|
||||
var ele;
|
||||
var elen;
|
||||
var res;
|
||||
|
||||
for (; i < len; i++) {
|
||||
ele = arr[i].toString();
|
||||
elen = ele.length;
|
||||
|
||||
if (elen > c) {
|
||||
res = ele;
|
||||
c = elen;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
43
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/longest/package.json
generated
vendored
Normal file
43
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/longest/package.json
generated
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"name": "longest",
|
||||
"description": "Get the longest item in an array.",
|
||||
"version": "1.0.1",
|
||||
"homepage": "https://github.com/jonschlinkert/longest",
|
||||
"author": {
|
||||
"name": "Jon Schlinkert",
|
||||
"url": "https://github.com/jonschlinkert"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jonschlinkert/longest.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/longest/issues"
|
||||
},
|
||||
"license": {
|
||||
"type": "MIT",
|
||||
"url": "https://github.com/jonschlinkert/longest/blob/master/LICENSE"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"devDependencies": {
|
||||
"fill-range": "^2.1.0",
|
||||
"mocha": "*"
|
||||
},
|
||||
"keywords": [
|
||||
"array",
|
||||
"element",
|
||||
"item",
|
||||
"long",
|
||||
"length",
|
||||
"longest"
|
||||
]
|
||||
}
|
15
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lru-cache/LICENSE
generated
vendored
Normal file
15
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lru-cache/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
158
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lru-cache/README.md
generated
vendored
Normal file
158
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lru-cache/README.md
generated
vendored
Normal file
|
@ -0,0 +1,158 @@
|
|||
# lru cache
|
||||
|
||||
A cache object that deletes the least-recently-used items.
|
||||
|
||||
[![Build Status](https://travis-ci.org/isaacs/node-lru-cache.svg?branch=master)](https://travis-ci.org/isaacs/node-lru-cache) [![Coverage Status](https://coveralls.io/repos/isaacs/node-lru-cache/badge.svg?service=github)](https://coveralls.io/github/isaacs/node-lru-cache)
|
||||
|
||||
## Installation:
|
||||
|
||||
```javascript
|
||||
npm install lru-cache --save
|
||||
```
|
||||
|
||||
## Usage:
|
||||
|
||||
```javascript
|
||||
var LRU = require("lru-cache")
|
||||
, options = { max: 500
|
||||
, length: function (n, key) { return n * 2 + key.length }
|
||||
, dispose: function (key, n) { n.close() }
|
||||
, maxAge: 1000 * 60 * 60 }
|
||||
, cache = LRU(options)
|
||||
, otherCache = LRU(50) // sets just the max size
|
||||
|
||||
cache.set("key", "value")
|
||||
cache.get("key") // "value"
|
||||
|
||||
// non-string keys ARE fully supported
|
||||
// but note that it must be THE SAME object, not
|
||||
// just a JSON-equivalent object.
|
||||
var someObject = { a: 1 }
|
||||
cache.set(someObject, 'a value')
|
||||
// Object keys are not toString()-ed
|
||||
cache.set('[object Object]', 'a different value')
|
||||
assert.equal(cache.get(someObject), 'a value')
|
||||
// A similar object with same keys/values won't work,
|
||||
// because it's a different object identity
|
||||
assert.equal(cache.get({ a: 1 }), undefined)
|
||||
|
||||
cache.reset() // empty the cache
|
||||
```
|
||||
|
||||
If you put more stuff in it, then items will fall out.
|
||||
|
||||
If you try to put an oversized thing in it, then it'll fall out right
|
||||
away.
|
||||
|
||||
## Options
|
||||
|
||||
* `max` The maximum size of the cache, checked by applying the length
|
||||
function to all values in the cache. Not setting this is kind of
|
||||
silly, since that's the whole purpose of this lib, but it defaults
|
||||
to `Infinity`.
|
||||
* `maxAge` Maximum age in ms. Items are not pro-actively pruned out
|
||||
as they age, but if you try to get an item that is too old, it'll
|
||||
drop it and return undefined instead of giving it to you.
|
||||
* `length` Function that is used to calculate the length of stored
|
||||
items. If you're storing strings or buffers, then you probably want
|
||||
to do something like `function(n, key){return n.length}`. The default is
|
||||
`function(){return 1}`, which is fine if you want to store `max`
|
||||
like-sized things. The item is passed as the first argument, and
|
||||
the key is passed as the second argumnet.
|
||||
* `dispose` Function that is called on items when they are dropped
|
||||
from the cache. This can be handy if you want to close file
|
||||
descriptors or do other cleanup tasks when items are no longer
|
||||
accessible. Called with `key, value`. It's called *before*
|
||||
actually removing the item from the internal cache, so if you want
|
||||
to immediately put it back in, you'll have to do that in a
|
||||
`nextTick` or `setTimeout` callback or it won't do anything.
|
||||
* `stale` By default, if you set a `maxAge`, it'll only actually pull
|
||||
stale items out of the cache when you `get(key)`. (That is, it's
|
||||
not pre-emptively doing a `setTimeout` or anything.) If you set
|
||||
`stale:true`, it'll return the stale value before deleting it. If
|
||||
you don't set this, then it'll return `undefined` when you try to
|
||||
get a stale entry, as if it had already been deleted.
|
||||
* `noDisposeOnSet` By default, if you set a `dispose()` method, then
|
||||
it'll be called whenever a `set()` operation overwrites an existing
|
||||
key. If you set this option, `dispose()` will only be called when a
|
||||
key falls out of the cache, not when it is overwritten.
|
||||
|
||||
## API
|
||||
|
||||
* `set(key, value, maxAge)`
|
||||
* `get(key) => value`
|
||||
|
||||
Both of these will update the "recently used"-ness of the key.
|
||||
They do what you think. `maxAge` is optional and overrides the
|
||||
cache `maxAge` option if provided.
|
||||
|
||||
If the key is not found, `get()` will return `undefined`.
|
||||
|
||||
The key and val can be any value.
|
||||
|
||||
* `peek(key)`
|
||||
|
||||
Returns the key value (or `undefined` if not found) without
|
||||
updating the "recently used"-ness of the key.
|
||||
|
||||
(If you find yourself using this a lot, you *might* be using the
|
||||
wrong sort of data structure, but there are some use cases where
|
||||
it's handy.)
|
||||
|
||||
* `del(key)`
|
||||
|
||||
Deletes a key out of the cache.
|
||||
|
||||
* `reset()`
|
||||
|
||||
Clear the cache entirely, throwing away all values.
|
||||
|
||||
* `has(key)`
|
||||
|
||||
Check if a key is in the cache, without updating the recent-ness
|
||||
or deleting it for being stale.
|
||||
|
||||
* `forEach(function(value,key,cache), [thisp])`
|
||||
|
||||
Just like `Array.prototype.forEach`. Iterates over all the keys
|
||||
in the cache, in order of recent-ness. (Ie, more recently used
|
||||
items are iterated over first.)
|
||||
|
||||
* `rforEach(function(value,key,cache), [thisp])`
|
||||
|
||||
The same as `cache.forEach(...)` but items are iterated over in
|
||||
reverse order. (ie, less recently used items are iterated over
|
||||
first.)
|
||||
|
||||
* `keys()`
|
||||
|
||||
Return an array of the keys in the cache.
|
||||
|
||||
* `values()`
|
||||
|
||||
Return an array of the values in the cache.
|
||||
|
||||
* `length`
|
||||
|
||||
Return total length of objects in cache taking into account
|
||||
`length` options function.
|
||||
|
||||
* `itemCount`
|
||||
|
||||
Return total quantity of objects currently in cache. Note, that
|
||||
`stale` (see options) items are returned as part of this item
|
||||
count.
|
||||
|
||||
* `dump()`
|
||||
|
||||
Return an array of the cache entries ready for serialization and usage
|
||||
with 'destinationCache.load(arr)`.
|
||||
|
||||
* `load(cacheEntriesArray)`
|
||||
|
||||
Loads another cache entries array, obtained with `sourceCache.dump()`,
|
||||
into the cache. The destination cache is reset before loading new entries
|
||||
|
||||
* `prune()`
|
||||
|
||||
Manually iterates over the entire cache proactively pruning old entries
|
468
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lru-cache/index.js
generated
vendored
Normal file
468
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lru-cache/index.js
generated
vendored
Normal file
|
@ -0,0 +1,468 @@
|
|||
'use strict'
|
||||
|
||||
module.exports = LRUCache
|
||||
|
||||
// This will be a proper iterable 'Map' in engines that support it,
|
||||
// or a fakey-fake PseudoMap in older versions.
|
||||
var Map = require('pseudomap')
|
||||
var util = require('util')
|
||||
|
||||
// A linked list to keep track of recently-used-ness
|
||||
var Yallist = require('yallist')
|
||||
|
||||
// use symbols if possible, otherwise just _props
|
||||
var hasSymbol = typeof Symbol === 'function' && process.env._nodeLRUCacheForceNoSymbol !== '1'
|
||||
var makeSymbol
|
||||
if (hasSymbol) {
|
||||
makeSymbol = function (key) {
|
||||
return Symbol(key)
|
||||
}
|
||||
} else {
|
||||
makeSymbol = function (key) {
|
||||
return '_' + key
|
||||
}
|
||||
}
|
||||
|
||||
var MAX = makeSymbol('max')
|
||||
var LENGTH = makeSymbol('length')
|
||||
var LENGTH_CALCULATOR = makeSymbol('lengthCalculator')
|
||||
var ALLOW_STALE = makeSymbol('allowStale')
|
||||
var MAX_AGE = makeSymbol('maxAge')
|
||||
var DISPOSE = makeSymbol('dispose')
|
||||
var NO_DISPOSE_ON_SET = makeSymbol('noDisposeOnSet')
|
||||
var LRU_LIST = makeSymbol('lruList')
|
||||
var CACHE = makeSymbol('cache')
|
||||
|
||||
function naiveLength () { return 1 }
|
||||
|
||||
// lruList is a yallist where the head is the youngest
|
||||
// item, and the tail is the oldest. the list contains the Hit
|
||||
// objects as the entries.
|
||||
// Each Hit object has a reference to its Yallist.Node. This
|
||||
// never changes.
|
||||
//
|
||||
// cache is a Map (or PseudoMap) that matches the keys to
|
||||
// the Yallist.Node object.
|
||||
function LRUCache (options) {
|
||||
if (!(this instanceof LRUCache)) {
|
||||
return new LRUCache(options)
|
||||
}
|
||||
|
||||
if (typeof options === 'number') {
|
||||
options = { max: options }
|
||||
}
|
||||
|
||||
if (!options) {
|
||||
options = {}
|
||||
}
|
||||
|
||||
var max = this[MAX] = options.max
|
||||
// Kind of weird to have a default max of Infinity, but oh well.
|
||||
if (!max ||
|
||||
!(typeof max === 'number') ||
|
||||
max <= 0) {
|
||||
this[MAX] = Infinity
|
||||
}
|
||||
|
||||
var lc = options.length || naiveLength
|
||||
if (typeof lc !== 'function') {
|
||||
lc = naiveLength
|
||||
}
|
||||
this[LENGTH_CALCULATOR] = lc
|
||||
|
||||
this[ALLOW_STALE] = options.stale || false
|
||||
this[MAX_AGE] = options.maxAge || 0
|
||||
this[DISPOSE] = options.dispose
|
||||
this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false
|
||||
this.reset()
|
||||
}
|
||||
|
||||
// resize the cache when the max changes.
|
||||
Object.defineProperty(LRUCache.prototype, 'max', {
|
||||
set: function (mL) {
|
||||
if (!mL || !(typeof mL === 'number') || mL <= 0) {
|
||||
mL = Infinity
|
||||
}
|
||||
this[MAX] = mL
|
||||
trim(this)
|
||||
},
|
||||
get: function () {
|
||||
return this[MAX]
|
||||
},
|
||||
enumerable: true
|
||||
})
|
||||
|
||||
Object.defineProperty(LRUCache.prototype, 'allowStale', {
|
||||
set: function (allowStale) {
|
||||
this[ALLOW_STALE] = !!allowStale
|
||||
},
|
||||
get: function () {
|
||||
return this[ALLOW_STALE]
|
||||
},
|
||||
enumerable: true
|
||||
})
|
||||
|
||||
Object.defineProperty(LRUCache.prototype, 'maxAge', {
|
||||
set: function (mA) {
|
||||
if (!mA || !(typeof mA === 'number') || mA < 0) {
|
||||
mA = 0
|
||||
}
|
||||
this[MAX_AGE] = mA
|
||||
trim(this)
|
||||
},
|
||||
get: function () {
|
||||
return this[MAX_AGE]
|
||||
},
|
||||
enumerable: true
|
||||
})
|
||||
|
||||
// resize the cache when the lengthCalculator changes.
|
||||
Object.defineProperty(LRUCache.prototype, 'lengthCalculator', {
|
||||
set: function (lC) {
|
||||
if (typeof lC !== 'function') {
|
||||
lC = naiveLength
|
||||
}
|
||||
if (lC !== this[LENGTH_CALCULATOR]) {
|
||||
this[LENGTH_CALCULATOR] = lC
|
||||
this[LENGTH] = 0
|
||||
this[LRU_LIST].forEach(function (hit) {
|
||||
hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key)
|
||||
this[LENGTH] += hit.length
|
||||
}, this)
|
||||
}
|
||||
trim(this)
|
||||
},
|
||||
get: function () { return this[LENGTH_CALCULATOR] },
|
||||
enumerable: true
|
||||
})
|
||||
|
||||
Object.defineProperty(LRUCache.prototype, 'length', {
|
||||
get: function () { return this[LENGTH] },
|
||||
enumerable: true
|
||||
})
|
||||
|
||||
Object.defineProperty(LRUCache.prototype, 'itemCount', {
|
||||
get: function () { return this[LRU_LIST].length },
|
||||
enumerable: true
|
||||
})
|
||||
|
||||
LRUCache.prototype.rforEach = function (fn, thisp) {
|
||||
thisp = thisp || this
|
||||
for (var walker = this[LRU_LIST].tail; walker !== null;) {
|
||||
var prev = walker.prev
|
||||
forEachStep(this, fn, walker, thisp)
|
||||
walker = prev
|
||||
}
|
||||
}
|
||||
|
||||
function forEachStep (self, fn, node, thisp) {
|
||||
var hit = node.value
|
||||
if (isStale(self, hit)) {
|
||||
del(self, node)
|
||||
if (!self[ALLOW_STALE]) {
|
||||
hit = undefined
|
||||
}
|
||||
}
|
||||
if (hit) {
|
||||
fn.call(thisp, hit.value, hit.key, self)
|
||||
}
|
||||
}
|
||||
|
||||
LRUCache.prototype.forEach = function (fn, thisp) {
|
||||
thisp = thisp || this
|
||||
for (var walker = this[LRU_LIST].head; walker !== null;) {
|
||||
var next = walker.next
|
||||
forEachStep(this, fn, walker, thisp)
|
||||
walker = next
|
||||
}
|
||||
}
|
||||
|
||||
LRUCache.prototype.keys = function () {
|
||||
return this[LRU_LIST].toArray().map(function (k) {
|
||||
return k.key
|
||||
}, this)
|
||||
}
|
||||
|
||||
LRUCache.prototype.values = function () {
|
||||
return this[LRU_LIST].toArray().map(function (k) {
|
||||
return k.value
|
||||
}, this)
|
||||
}
|
||||
|
||||
LRUCache.prototype.reset = function () {
|
||||
if (this[DISPOSE] &&
|
||||
this[LRU_LIST] &&
|
||||
this[LRU_LIST].length) {
|
||||
this[LRU_LIST].forEach(function (hit) {
|
||||
this[DISPOSE](hit.key, hit.value)
|
||||
}, this)
|
||||
}
|
||||
|
||||
this[CACHE] = new Map() // hash of items by key
|
||||
this[LRU_LIST] = new Yallist() // list of items in order of use recency
|
||||
this[LENGTH] = 0 // length of items in the list
|
||||
}
|
||||
|
||||
LRUCache.prototype.dump = function () {
|
||||
return this[LRU_LIST].map(function (hit) {
|
||||
if (!isStale(this, hit)) {
|
||||
return {
|
||||
k: hit.key,
|
||||
v: hit.value,
|
||||
e: hit.now + (hit.maxAge || 0)
|
||||
}
|
||||
}
|
||||
}, this).toArray().filter(function (h) {
|
||||
return h
|
||||
})
|
||||
}
|
||||
|
||||
LRUCache.prototype.dumpLru = function () {
|
||||
return this[LRU_LIST]
|
||||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
LRUCache.prototype.inspect = function (n, opts) {
|
||||
var str = 'LRUCache {'
|
||||
var extras = false
|
||||
|
||||
var as = this[ALLOW_STALE]
|
||||
if (as) {
|
||||
str += '\n allowStale: true'
|
||||
extras = true
|
||||
}
|
||||
|
||||
var max = this[MAX]
|
||||
if (max && max !== Infinity) {
|
||||
if (extras) {
|
||||
str += ','
|
||||
}
|
||||
str += '\n max: ' + util.inspect(max, opts)
|
||||
extras = true
|
||||
}
|
||||
|
||||
var maxAge = this[MAX_AGE]
|
||||
if (maxAge) {
|
||||
if (extras) {
|
||||
str += ','
|
||||
}
|
||||
str += '\n maxAge: ' + util.inspect(maxAge, opts)
|
||||
extras = true
|
||||
}
|
||||
|
||||
var lc = this[LENGTH_CALCULATOR]
|
||||
if (lc && lc !== naiveLength) {
|
||||
if (extras) {
|
||||
str += ','
|
||||
}
|
||||
str += '\n length: ' + util.inspect(this[LENGTH], opts)
|
||||
extras = true
|
||||
}
|
||||
|
||||
var didFirst = false
|
||||
this[LRU_LIST].forEach(function (item) {
|
||||
if (didFirst) {
|
||||
str += ',\n '
|
||||
} else {
|
||||
if (extras) {
|
||||
str += ',\n'
|
||||
}
|
||||
didFirst = true
|
||||
str += '\n '
|
||||
}
|
||||
var key = util.inspect(item.key).split('\n').join('\n ')
|
||||
var val = { value: item.value }
|
||||
if (item.maxAge !== maxAge) {
|
||||
val.maxAge = item.maxAge
|
||||
}
|
||||
if (lc !== naiveLength) {
|
||||
val.length = item.length
|
||||
}
|
||||
if (isStale(this, item)) {
|
||||
val.stale = true
|
||||
}
|
||||
|
||||
val = util.inspect(val, opts).split('\n').join('\n ')
|
||||
str += key + ' => ' + val
|
||||
})
|
||||
|
||||
if (didFirst || extras) {
|
||||
str += '\n'
|
||||
}
|
||||
str += '}'
|
||||
|
||||
return str
|
||||
}
|
||||
|
||||
LRUCache.prototype.set = function (key, value, maxAge) {
|
||||
maxAge = maxAge || this[MAX_AGE]
|
||||
|
||||
var now = maxAge ? Date.now() : 0
|
||||
var len = this[LENGTH_CALCULATOR](value, key)
|
||||
|
||||
if (this[CACHE].has(key)) {
|
||||
if (len > this[MAX]) {
|
||||
del(this, this[CACHE].get(key))
|
||||
return false
|
||||
}
|
||||
|
||||
var node = this[CACHE].get(key)
|
||||
var item = node.value
|
||||
|
||||
// dispose of the old one before overwriting
|
||||
// split out into 2 ifs for better coverage tracking
|
||||
if (this[DISPOSE]) {
|
||||
if (!this[NO_DISPOSE_ON_SET]) {
|
||||
this[DISPOSE](key, item.value)
|
||||
}
|
||||
}
|
||||
|
||||
item.now = now
|
||||
item.maxAge = maxAge
|
||||
item.value = value
|
||||
this[LENGTH] += len - item.length
|
||||
item.length = len
|
||||
this.get(key)
|
||||
trim(this)
|
||||
return true
|
||||
}
|
||||
|
||||
var hit = new Entry(key, value, len, now, maxAge)
|
||||
|
||||
// oversized objects fall out of cache automatically.
|
||||
if (hit.length > this[MAX]) {
|
||||
if (this[DISPOSE]) {
|
||||
this[DISPOSE](key, value)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
this[LENGTH] += hit.length
|
||||
this[LRU_LIST].unshift(hit)
|
||||
this[CACHE].set(key, this[LRU_LIST].head)
|
||||
trim(this)
|
||||
return true
|
||||
}
|
||||
|
||||
LRUCache.prototype.has = function (key) {
|
||||
if (!this[CACHE].has(key)) return false
|
||||
var hit = this[CACHE].get(key).value
|
||||
if (isStale(this, hit)) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
LRUCache.prototype.get = function (key) {
|
||||
return get(this, key, true)
|
||||
}
|
||||
|
||||
LRUCache.prototype.peek = function (key) {
|
||||
return get(this, key, false)
|
||||
}
|
||||
|
||||
LRUCache.prototype.pop = function () {
|
||||
var node = this[LRU_LIST].tail
|
||||
if (!node) return null
|
||||
del(this, node)
|
||||
return node.value
|
||||
}
|
||||
|
||||
LRUCache.prototype.del = function (key) {
|
||||
del(this, this[CACHE].get(key))
|
||||
}
|
||||
|
||||
LRUCache.prototype.load = function (arr) {
|
||||
// reset the cache
|
||||
this.reset()
|
||||
|
||||
var now = Date.now()
|
||||
// A previous serialized cache has the most recent items first
|
||||
for (var l = arr.length - 1; l >= 0; l--) {
|
||||
var hit = arr[l]
|
||||
var expiresAt = hit.e || 0
|
||||
if (expiresAt === 0) {
|
||||
// the item was created without expiration in a non aged cache
|
||||
this.set(hit.k, hit.v)
|
||||
} else {
|
||||
var maxAge = expiresAt - now
|
||||
// dont add already expired items
|
||||
if (maxAge > 0) {
|
||||
this.set(hit.k, hit.v, maxAge)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LRUCache.prototype.prune = function () {
|
||||
var self = this
|
||||
this[CACHE].forEach(function (value, key) {
|
||||
get(self, key, false)
|
||||
})
|
||||
}
|
||||
|
||||
function get (self, key, doUse) {
|
||||
var node = self[CACHE].get(key)
|
||||
if (node) {
|
||||
var hit = node.value
|
||||
if (isStale(self, hit)) {
|
||||
del(self, node)
|
||||
if (!self[ALLOW_STALE]) hit = undefined
|
||||
} else {
|
||||
if (doUse) {
|
||||
self[LRU_LIST].unshiftNode(node)
|
||||
}
|
||||
}
|
||||
if (hit) hit = hit.value
|
||||
}
|
||||
return hit
|
||||
}
|
||||
|
||||
function isStale (self, hit) {
|
||||
if (!hit || (!hit.maxAge && !self[MAX_AGE])) {
|
||||
return false
|
||||
}
|
||||
var stale = false
|
||||
var diff = Date.now() - hit.now
|
||||
if (hit.maxAge) {
|
||||
stale = diff > hit.maxAge
|
||||
} else {
|
||||
stale = self[MAX_AGE] && (diff > self[MAX_AGE])
|
||||
}
|
||||
return stale
|
||||
}
|
||||
|
||||
function trim (self) {
|
||||
if (self[LENGTH] > self[MAX]) {
|
||||
for (var walker = self[LRU_LIST].tail;
|
||||
self[LENGTH] > self[MAX] && walker !== null;) {
|
||||
// We know that we're about to delete this one, and also
|
||||
// what the next least recently used key will be, so just
|
||||
// go ahead and set it now.
|
||||
var prev = walker.prev
|
||||
del(self, walker)
|
||||
walker = prev
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function del (self, node) {
|
||||
if (node) {
|
||||
var hit = node.value
|
||||
if (self[DISPOSE]) {
|
||||
self[DISPOSE](hit.key, hit.value)
|
||||
}
|
||||
self[LENGTH] -= hit.length
|
||||
self[CACHE].delete(hit.key)
|
||||
self[LRU_LIST].removeNode(node)
|
||||
}
|
||||
}
|
||||
|
||||
// classy, since V8 prefers predictable objects.
|
||||
function Entry (key, value, length, now, maxAge) {
|
||||
this.key = key
|
||||
this.value = value
|
||||
this.length = length
|
||||
this.now = now
|
||||
this.maxAge = maxAge || 0
|
||||
}
|
36
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lru-cache/package.json
generated
vendored
Normal file
36
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/lru-cache/package.json
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"name": "lru-cache",
|
||||
"description": "A cache object that deletes the least-recently-used items.",
|
||||
"version": "4.1.5",
|
||||
"author": "Isaac Z. Schlueter <i@izs.me>",
|
||||
"keywords": [
|
||||
"mru",
|
||||
"lru",
|
||||
"cache"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "tap test/*.js --100 -J",
|
||||
"snap": "TAP_SNAPSHOT=1 tap test/*.js -J",
|
||||
"posttest": "standard test/*.js index.js",
|
||||
"coveragerport": "tap --coverage-report=html",
|
||||
"lintfix": "standard --fix test/*.js index.js",
|
||||
"preversion": "npm test",
|
||||
"postversion": "npm publish --tag=legacy",
|
||||
"postpublish": "git push origin --all; git push origin --tags"
|
||||
},
|
||||
"main": "index.js",
|
||||
"repository": "git://github.com/isaacs/node-lru-cache.git",
|
||||
"devDependencies": {
|
||||
"benchmark": "^2.1.4",
|
||||
"standard": "^12.0.1",
|
||||
"tap": "^12.1.0"
|
||||
},
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"pseudomap": "^1.0.2",
|
||||
"yallist": "^2.1.2"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
]
|
||||
}
|
21
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/map-cache/LICENSE
generated
vendored
Normal file
21
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/map-cache/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-2016, Jon Schlinkert.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
145
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/map-cache/README.md
generated
vendored
Normal file
145
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/map-cache/README.md
generated
vendored
Normal file
|
@ -0,0 +1,145 @@
|
|||
# map-cache [![NPM version](https://img.shields.io/npm/v/map-cache.svg?style=flat)](https://www.npmjs.com/package/map-cache) [![NPM downloads](https://img.shields.io/npm/dm/map-cache.svg?style=flat)](https://npmjs.org/package/map-cache) [![Build Status](https://img.shields.io/travis/jonschlinkert/map-cache.svg?style=flat)](https://travis-ci.org/jonschlinkert/map-cache)
|
||||
|
||||
Basic cache object for storing key-value pairs.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm install map-cache --save
|
||||
```
|
||||
|
||||
Based on MapCache in Lo-dash v3.0. [MIT License](https://github.com/lodash/lodash/blob/master/LICENSE.txt)
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var MapCache = require('map-cache');
|
||||
var mapCache = new MapCache();
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### [MapCache](index.js#L28)
|
||||
|
||||
Creates a cache object to store key/value pairs.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
var cache = new MapCache();
|
||||
```
|
||||
|
||||
### [.set](index.js#L45)
|
||||
|
||||
Adds `value` to `key` on the cache.
|
||||
|
||||
**Params**
|
||||
|
||||
* `key` **{String}**: The key of the value to cache.
|
||||
* `value` **{any}**: The value to cache.
|
||||
* `returns` **{Object}**: Returns the `Cache` object for chaining.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
cache.set('foo', 'bar');
|
||||
```
|
||||
|
||||
### [.get](index.js#L65)
|
||||
|
||||
Gets the cached value for `key`.
|
||||
|
||||
**Params**
|
||||
|
||||
* `key` **{String}**: The key of the value to get.
|
||||
* `returns` **{any}**: Returns the cached value.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
cache.get('foo');
|
||||
//=> 'bar'
|
||||
```
|
||||
|
||||
### [.has](index.js#L82)
|
||||
|
||||
Checks if a cached value for `key` exists.
|
||||
|
||||
**Params**
|
||||
|
||||
* `key` **{String}**: The key of the entry to check.
|
||||
* `returns` **{Boolean}**: Returns `true` if an entry for `key` exists, else `false`.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
cache.has('foo');
|
||||
//=> true
|
||||
```
|
||||
|
||||
### [.del](index.js#L98)
|
||||
|
||||
Removes `key` and its value from the cache.
|
||||
|
||||
**Params**
|
||||
|
||||
* `key` **{String}**: The key of the value to remove.
|
||||
* `returns` **{Boolean}**: Returns `true` if the entry was removed successfully, else `false`.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
cache.del('foo');
|
||||
```
|
||||
|
||||
## Related projects
|
||||
|
||||
You might also be interested in these projects:
|
||||
|
||||
* [cache-base](https://www.npmjs.com/package/cache-base): Basic object cache with `get`, `set`, `del`, and `has` methods for node.js/javascript projects. | [homepage](https://github.com/jonschlinkert/cache-base)
|
||||
* [config-cache](https://www.npmjs.com/package/config-cache): General purpose JavaScript object storage methods. | [homepage](https://github.com/jonschlinkert/config-cache)
|
||||
* [option-cache](https://www.npmjs.com/package/option-cache): Simple API for managing options in JavaScript applications. | [homepage](https://github.com/jonschlinkert/option-cache)
|
||||
|
||||
## Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/map-cache/issues/new).
|
||||
|
||||
## Building docs
|
||||
|
||||
Generate readme and API documentation with [verb](https://github.com/verbose/verb):
|
||||
|
||||
```sh
|
||||
$ npm install verb && npm run docs
|
||||
```
|
||||
|
||||
Or, if [verb](https://github.com/verbose/verb) is installed globally:
|
||||
|
||||
```sh
|
||||
$ verb
|
||||
```
|
||||
|
||||
## Running tests
|
||||
|
||||
Install dev dependencies:
|
||||
|
||||
```sh
|
||||
$ npm install -d && npm test
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
|
||||
|
||||
## License
|
||||
|
||||
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||
Released under the [MIT license](https://github.com/jonschlinkert/map-cache/blob/master/LICENSE).
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on May 10, 2016._
|
100
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/map-cache/index.js
generated
vendored
Normal file
100
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/map-cache/index.js
generated
vendored
Normal file
|
@ -0,0 +1,100 @@
|
|||
/*!
|
||||
* map-cache <https://github.com/jonschlinkert/map-cache>
|
||||
*
|
||||
* Copyright (c) 2015, Jon Schlinkert.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var hasOwn = Object.prototype.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* Expose `MapCache`
|
||||
*/
|
||||
|
||||
module.exports = MapCache;
|
||||
|
||||
/**
|
||||
* Creates a cache object to store key/value pairs.
|
||||
*
|
||||
* ```js
|
||||
* var cache = new MapCache();
|
||||
* ```
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function MapCache(data) {
|
||||
this.__data__ = data || {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds `value` to `key` on the cache.
|
||||
*
|
||||
* ```js
|
||||
* cache.set('foo', 'bar');
|
||||
* ```
|
||||
*
|
||||
* @param {String} `key` The key of the value to cache.
|
||||
* @param {*} `value` The value to cache.
|
||||
* @returns {Object} Returns the `Cache` object for chaining.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
MapCache.prototype.set = function mapSet(key, value) {
|
||||
if (key !== '__proto__') {
|
||||
this.__data__[key] = value;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the cached value for `key`.
|
||||
*
|
||||
* ```js
|
||||
* cache.get('foo');
|
||||
* //=> 'bar'
|
||||
* ```
|
||||
*
|
||||
* @param {String} `key` The key of the value to get.
|
||||
* @returns {*} Returns the cached value.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
MapCache.prototype.get = function mapGet(key) {
|
||||
return key === '__proto__' ? undefined : this.__data__[key];
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if a cached value for `key` exists.
|
||||
*
|
||||
* ```js
|
||||
* cache.has('foo');
|
||||
* //=> true
|
||||
* ```
|
||||
*
|
||||
* @param {String} `key` The key of the entry to check.
|
||||
* @returns {Boolean} Returns `true` if an entry for `key` exists, else `false`.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
MapCache.prototype.has = function mapHas(key) {
|
||||
return key !== '__proto__' && hasOwn.call(this.__data__, key);
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes `key` and its value from the cache.
|
||||
*
|
||||
* ```js
|
||||
* cache.del('foo');
|
||||
* ```
|
||||
* @title .del
|
||||
* @param {String} `key` The key of the value to remove.
|
||||
* @returns {Boolean} Returns `true` if the entry was removed successfully, else `false`.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
MapCache.prototype.del = function mapDelete(key) {
|
||||
return this.has(key) && delete this.__data__[key];
|
||||
};
|
59
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/map-cache/package.json
generated
vendored
Normal file
59
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/map-cache/package.json
generated
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
{
|
||||
"name": "map-cache",
|
||||
"description": "Basic cache object for storing key-value pairs.",
|
||||
"version": "0.2.2",
|
||||
"homepage": "https://github.com/jonschlinkert/map-cache",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"repository": "jonschlinkert/map-cache",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/map-cache/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gulp-format-md": "^0.1.9",
|
||||
"should": "^8.3.1"
|
||||
},
|
||||
"keywords": [
|
||||
"cache",
|
||||
"get",
|
||||
"has",
|
||||
"object",
|
||||
"set",
|
||||
"storage",
|
||||
"store"
|
||||
],
|
||||
"verb": {
|
||||
"run": true,
|
||||
"toc": false,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"related": {
|
||||
"list": [
|
||||
"config-cache",
|
||||
"option-cache",
|
||||
"cache-base"
|
||||
]
|
||||
},
|
||||
"reflinks": [
|
||||
"verb"
|
||||
],
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
}
|
||||
}
|
||||
}
|
21
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/map-visit/LICENSE
generated
vendored
Normal file
21
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/map-visit/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-2017, Jon Schlinkert
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
155
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/map-visit/README.md
generated
vendored
Normal file
155
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/map-visit/README.md
generated
vendored
Normal file
|
@ -0,0 +1,155 @@
|
|||
# map-visit [![NPM version](https://img.shields.io/npm/v/map-visit.svg?style=flat)](https://www.npmjs.com/package/map-visit) [![NPM monthly downloads](https://img.shields.io/npm/dm/map-visit.svg?style=flat)](https://npmjs.org/package/map-visit) [![NPM total downloads](https://img.shields.io/npm/dt/map-visit.svg?style=flat)](https://npmjs.org/package/map-visit) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/map-visit.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/map-visit)
|
||||
|
||||
> Map `visit` over an array of objects.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm install --save map-visit
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var mapVisit = require('map-visit');
|
||||
```
|
||||
|
||||
## What does this do?
|
||||
|
||||
**Assign/Merge/Extend vs. Visit**
|
||||
|
||||
Let's say you want to add a `set` method to your application that will:
|
||||
|
||||
* set key-value pairs on a `data` object
|
||||
* extend objects onto the `data` object
|
||||
* extend arrays of objects onto the data object
|
||||
|
||||
**Example using `extend`**
|
||||
|
||||
Here is one way to accomplish this using Lo-Dash's `extend` (comparable to `Object.assign`):
|
||||
|
||||
```js
|
||||
var _ = require('lodash');
|
||||
|
||||
var obj = {
|
||||
data: {},
|
||||
set: function (key, value) {
|
||||
if (Array.isArray(key)) {
|
||||
_.extend.apply(_, [obj.data].concat(key));
|
||||
} else if (typeof key === 'object') {
|
||||
_.extend(obj.data, key);
|
||||
} else {
|
||||
obj.data[key] = value;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
obj.set('a', 'a');
|
||||
obj.set([{b: 'b'}, {c: 'c'}]);
|
||||
obj.set({d: {e: 'f'}});
|
||||
|
||||
console.log(obj.data);
|
||||
//=> {a: 'a', b: 'b', c: 'c', d: { e: 'f' }}
|
||||
```
|
||||
|
||||
The above approach works fine for most use cases. However, **if you also want to emit an event** each time a property is added to the `data` object, or you want more control over what happens as the object is extended, a better approach would be to use `visit`.
|
||||
|
||||
**Example using `visit`**
|
||||
|
||||
In this approach:
|
||||
|
||||
* when an array is passed to `set`, the `mapVisit` library calls the `set` method on each object in the array.
|
||||
* when an object is passed, `visit` calls `set` on each property in the object.
|
||||
|
||||
As a result, the `data` event will be emitted every time a property is added to `data` (events are just an example, you can use this approach to perform any necessary logic every time the method is called).
|
||||
|
||||
```js
|
||||
var mapVisit = require('map-visit');
|
||||
var visit = require('object-visit');
|
||||
|
||||
var obj = {
|
||||
data: {},
|
||||
set: function (key, value) {
|
||||
if (Array.isArray(key)) {
|
||||
mapVisit(obj, 'set', key);
|
||||
} else if (typeof key === 'object') {
|
||||
visit(obj, 'set', key);
|
||||
} else {
|
||||
// simulate an event-emitter
|
||||
console.log('emit', key, value);
|
||||
obj.data[key] = value;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
obj.set('a', 'a');
|
||||
obj.set([{b: 'b'}, {c: 'c'}]);
|
||||
obj.set({d: {e: 'f'}});
|
||||
obj.set({g: 'h', i: 'j', k: 'l'});
|
||||
|
||||
console.log(obj.data);
|
||||
//=> {a: 'a', b: 'b', c: 'c', d: { e: 'f' }, g: 'h', i: 'j', k: 'l'}
|
||||
|
||||
// events would look something like:
|
||||
// emit a a
|
||||
// emit b b
|
||||
// emit c c
|
||||
// emit d { e: 'f' }
|
||||
// emit g h
|
||||
// emit i j
|
||||
// emit k l
|
||||
```
|
||||
|
||||
## About
|
||||
|
||||
### Related projects
|
||||
|
||||
* [collection-visit](https://www.npmjs.com/package/collection-visit): Visit a method over the items in an object, or map visit over the objects… [more](https://github.com/jonschlinkert/collection-visit) | [homepage](https://github.com/jonschlinkert/collection-visit "Visit a method over the items in an object, or map visit over the objects in an array.")
|
||||
* [object-visit](https://www.npmjs.com/package/object-visit): Call a specified method on each value in the given object. | [homepage](https://github.com/jonschlinkert/object-visit "Call a specified method on each value in the given object.")
|
||||
|
||||
### Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||
|
||||
### Contributors
|
||||
|
||||
| **Commits** | **Contributor** |
|
||||
| --- | --- |
|
||||
| 15 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||
| 7 | [doowb](https://github.com/doowb) |
|
||||
|
||||
### Building docs
|
||||
|
||||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||
|
||||
To generate the readme, run the following command:
|
||||
|
||||
```sh
|
||||
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||
```
|
||||
|
||||
### Running tests
|
||||
|
||||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||
|
||||
```sh
|
||||
$ npm install && npm test
|
||||
```
|
||||
|
||||
### Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
|
||||
|
||||
### License
|
||||
|
||||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||
Released under the [MIT License](LICENSE).
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.5.0, on April 09, 2017._
|
37
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/map-visit/index.js
generated
vendored
Normal file
37
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/map-visit/index.js
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
var visit = require('object-visit');
|
||||
|
||||
/**
|
||||
* Map `visit` over an array of objects.
|
||||
*
|
||||
* @param {Object} `collection` The context in which to invoke `method`
|
||||
* @param {String} `method` Name of the method to call on `collection`
|
||||
* @param {Object} `arr` Array of objects.
|
||||
*/
|
||||
|
||||
module.exports = function mapVisit(collection, method, val) {
|
||||
if (isObject(val)) {
|
||||
return visit.apply(null, arguments);
|
||||
}
|
||||
|
||||
if (!Array.isArray(val)) {
|
||||
throw new TypeError('expected an array: ' + util.inspect(val));
|
||||
}
|
||||
|
||||
var args = [].slice.call(arguments, 3);
|
||||
|
||||
for (var i = 0; i < val.length; i++) {
|
||||
var ele = val[i];
|
||||
if (isObject(ele)) {
|
||||
visit.apply(null, [collection, method, ele].concat(args));
|
||||
} else {
|
||||
collection[method].apply(collection, [ele].concat(args));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function isObject(val) {
|
||||
return val && (typeof val === 'function' || (!Array.isArray(val) && typeof val === 'object'));
|
||||
}
|
74
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/map-visit/package.json
generated
vendored
Normal file
74
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/map-visit/package.json
generated
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
{
|
||||
"name": "map-visit",
|
||||
"description": "Map `visit` over an array of objects.",
|
||||
"version": "1.0.0",
|
||||
"homepage": "https://github.com/jonschlinkert/map-visit",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"contributors": [
|
||||
"Brian Woodward <brian.woodward@gmail.com> (https://twitter.com/doowb)",
|
||||
"Jon Schlinkert <jon.schlinkert@sellside.com> (http://twitter.com/jonschlinkert)"
|
||||
],
|
||||
"repository": "jonschlinkert/map-visit",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/map-visit/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"object-visit": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"clone-deep": "^0.2.4",
|
||||
"extend-shallow": "^2.0.1",
|
||||
"gulp-format-md": "^0.1.12",
|
||||
"lodash": "^4.17.4",
|
||||
"mocha": "^3.2.0"
|
||||
},
|
||||
"keywords": [
|
||||
"array",
|
||||
"arrays",
|
||||
"function",
|
||||
"helper",
|
||||
"invoke",
|
||||
"key",
|
||||
"map",
|
||||
"method",
|
||||
"object",
|
||||
"objects",
|
||||
"value",
|
||||
"visit",
|
||||
"visitor"
|
||||
],
|
||||
"verb": {
|
||||
"toc": false,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
},
|
||||
"related": {
|
||||
"list": [
|
||||
"collection-visit",
|
||||
"object-visit"
|
||||
]
|
||||
},
|
||||
"reflinks": [
|
||||
"verb",
|
||||
"verb-generate-readme"
|
||||
]
|
||||
}
|
||||
}
|
21
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/md5.js/LICENSE
generated
vendored
Normal file
21
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/md5.js/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Kirill Fomichev
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
29
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/md5.js/README.md
generated
vendored
Normal file
29
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/md5.js/README.md
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
# md5.js
|
||||
|
||||
[![NPM Package](https://img.shields.io/npm/v/md5.js.svg?style=flat-square)](https://www.npmjs.org/package/md5.js)
|
||||
[![Build Status](https://img.shields.io/travis/crypto-browserify/md5.js.svg?branch=master&style=flat-square)](https://travis-ci.org/crypto-browserify/md5.js)
|
||||
[![Dependency status](https://img.shields.io/david/crypto-browserify/md5.js.svg?style=flat-square)](https://david-dm.org/crypto-browserify/md5.js#info=dependencies)
|
||||
|
||||
[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
|
||||
|
||||
Node style `md5` on pure JavaScript.
|
||||
|
||||
From [NIST SP 800-131A][1]: *md5 is no longer acceptable where collision resistance is required such as digital signatures.*
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var MD5 = require('md5.js')
|
||||
|
||||
console.log(new MD5().update('42').digest('hex'))
|
||||
// => a1d0c6e83f027327d8461063f4ac58a6
|
||||
|
||||
var md5stream = new MD5()
|
||||
md5stream.end('42')
|
||||
console.log(md5stream.read().toString('hex'))
|
||||
// => a1d0c6e83f027327d8461063f4ac58a6
|
||||
```
|
||||
|
||||
## LICENSE [MIT](LICENSE)
|
||||
|
||||
[1]: http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar1.pdf
|
146
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/md5.js/index.js
generated
vendored
Normal file
146
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/md5.js/index.js
generated
vendored
Normal file
|
@ -0,0 +1,146 @@
|
|||
'use strict'
|
||||
var inherits = require('inherits')
|
||||
var HashBase = require('hash-base')
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
|
||||
var ARRAY16 = new Array(16)
|
||||
|
||||
function MD5 () {
|
||||
HashBase.call(this, 64)
|
||||
|
||||
// state
|
||||
this._a = 0x67452301
|
||||
this._b = 0xefcdab89
|
||||
this._c = 0x98badcfe
|
||||
this._d = 0x10325476
|
||||
}
|
||||
|
||||
inherits(MD5, HashBase)
|
||||
|
||||
MD5.prototype._update = function () {
|
||||
var M = ARRAY16
|
||||
for (var i = 0; i < 16; ++i) M[i] = this._block.readInt32LE(i * 4)
|
||||
|
||||
var a = this._a
|
||||
var b = this._b
|
||||
var c = this._c
|
||||
var d = this._d
|
||||
|
||||
a = fnF(a, b, c, d, M[0], 0xd76aa478, 7)
|
||||
d = fnF(d, a, b, c, M[1], 0xe8c7b756, 12)
|
||||
c = fnF(c, d, a, b, M[2], 0x242070db, 17)
|
||||
b = fnF(b, c, d, a, M[3], 0xc1bdceee, 22)
|
||||
a = fnF(a, b, c, d, M[4], 0xf57c0faf, 7)
|
||||
d = fnF(d, a, b, c, M[5], 0x4787c62a, 12)
|
||||
c = fnF(c, d, a, b, M[6], 0xa8304613, 17)
|
||||
b = fnF(b, c, d, a, M[7], 0xfd469501, 22)
|
||||
a = fnF(a, b, c, d, M[8], 0x698098d8, 7)
|
||||
d = fnF(d, a, b, c, M[9], 0x8b44f7af, 12)
|
||||
c = fnF(c, d, a, b, M[10], 0xffff5bb1, 17)
|
||||
b = fnF(b, c, d, a, M[11], 0x895cd7be, 22)
|
||||
a = fnF(a, b, c, d, M[12], 0x6b901122, 7)
|
||||
d = fnF(d, a, b, c, M[13], 0xfd987193, 12)
|
||||
c = fnF(c, d, a, b, M[14], 0xa679438e, 17)
|
||||
b = fnF(b, c, d, a, M[15], 0x49b40821, 22)
|
||||
|
||||
a = fnG(a, b, c, d, M[1], 0xf61e2562, 5)
|
||||
d = fnG(d, a, b, c, M[6], 0xc040b340, 9)
|
||||
c = fnG(c, d, a, b, M[11], 0x265e5a51, 14)
|
||||
b = fnG(b, c, d, a, M[0], 0xe9b6c7aa, 20)
|
||||
a = fnG(a, b, c, d, M[5], 0xd62f105d, 5)
|
||||
d = fnG(d, a, b, c, M[10], 0x02441453, 9)
|
||||
c = fnG(c, d, a, b, M[15], 0xd8a1e681, 14)
|
||||
b = fnG(b, c, d, a, M[4], 0xe7d3fbc8, 20)
|
||||
a = fnG(a, b, c, d, M[9], 0x21e1cde6, 5)
|
||||
d = fnG(d, a, b, c, M[14], 0xc33707d6, 9)
|
||||
c = fnG(c, d, a, b, M[3], 0xf4d50d87, 14)
|
||||
b = fnG(b, c, d, a, M[8], 0x455a14ed, 20)
|
||||
a = fnG(a, b, c, d, M[13], 0xa9e3e905, 5)
|
||||
d = fnG(d, a, b, c, M[2], 0xfcefa3f8, 9)
|
||||
c = fnG(c, d, a, b, M[7], 0x676f02d9, 14)
|
||||
b = fnG(b, c, d, a, M[12], 0x8d2a4c8a, 20)
|
||||
|
||||
a = fnH(a, b, c, d, M[5], 0xfffa3942, 4)
|
||||
d = fnH(d, a, b, c, M[8], 0x8771f681, 11)
|
||||
c = fnH(c, d, a, b, M[11], 0x6d9d6122, 16)
|
||||
b = fnH(b, c, d, a, M[14], 0xfde5380c, 23)
|
||||
a = fnH(a, b, c, d, M[1], 0xa4beea44, 4)
|
||||
d = fnH(d, a, b, c, M[4], 0x4bdecfa9, 11)
|
||||
c = fnH(c, d, a, b, M[7], 0xf6bb4b60, 16)
|
||||
b = fnH(b, c, d, a, M[10], 0xbebfbc70, 23)
|
||||
a = fnH(a, b, c, d, M[13], 0x289b7ec6, 4)
|
||||
d = fnH(d, a, b, c, M[0], 0xeaa127fa, 11)
|
||||
c = fnH(c, d, a, b, M[3], 0xd4ef3085, 16)
|
||||
b = fnH(b, c, d, a, M[6], 0x04881d05, 23)
|
||||
a = fnH(a, b, c, d, M[9], 0xd9d4d039, 4)
|
||||
d = fnH(d, a, b, c, M[12], 0xe6db99e5, 11)
|
||||
c = fnH(c, d, a, b, M[15], 0x1fa27cf8, 16)
|
||||
b = fnH(b, c, d, a, M[2], 0xc4ac5665, 23)
|
||||
|
||||
a = fnI(a, b, c, d, M[0], 0xf4292244, 6)
|
||||
d = fnI(d, a, b, c, M[7], 0x432aff97, 10)
|
||||
c = fnI(c, d, a, b, M[14], 0xab9423a7, 15)
|
||||
b = fnI(b, c, d, a, M[5], 0xfc93a039, 21)
|
||||
a = fnI(a, b, c, d, M[12], 0x655b59c3, 6)
|
||||
d = fnI(d, a, b, c, M[3], 0x8f0ccc92, 10)
|
||||
c = fnI(c, d, a, b, M[10], 0xffeff47d, 15)
|
||||
b = fnI(b, c, d, a, M[1], 0x85845dd1, 21)
|
||||
a = fnI(a, b, c, d, M[8], 0x6fa87e4f, 6)
|
||||
d = fnI(d, a, b, c, M[15], 0xfe2ce6e0, 10)
|
||||
c = fnI(c, d, a, b, M[6], 0xa3014314, 15)
|
||||
b = fnI(b, c, d, a, M[13], 0x4e0811a1, 21)
|
||||
a = fnI(a, b, c, d, M[4], 0xf7537e82, 6)
|
||||
d = fnI(d, a, b, c, M[11], 0xbd3af235, 10)
|
||||
c = fnI(c, d, a, b, M[2], 0x2ad7d2bb, 15)
|
||||
b = fnI(b, c, d, a, M[9], 0xeb86d391, 21)
|
||||
|
||||
this._a = (this._a + a) | 0
|
||||
this._b = (this._b + b) | 0
|
||||
this._c = (this._c + c) | 0
|
||||
this._d = (this._d + d) | 0
|
||||
}
|
||||
|
||||
MD5.prototype._digest = function () {
|
||||
// create padding and handle blocks
|
||||
this._block[this._blockOffset++] = 0x80
|
||||
if (this._blockOffset > 56) {
|
||||
this._block.fill(0, this._blockOffset, 64)
|
||||
this._update()
|
||||
this._blockOffset = 0
|
||||
}
|
||||
|
||||
this._block.fill(0, this._blockOffset, 56)
|
||||
this._block.writeUInt32LE(this._length[0], 56)
|
||||
this._block.writeUInt32LE(this._length[1], 60)
|
||||
this._update()
|
||||
|
||||
// produce result
|
||||
var buffer = Buffer.allocUnsafe(16)
|
||||
buffer.writeInt32LE(this._a, 0)
|
||||
buffer.writeInt32LE(this._b, 4)
|
||||
buffer.writeInt32LE(this._c, 8)
|
||||
buffer.writeInt32LE(this._d, 12)
|
||||
return buffer
|
||||
}
|
||||
|
||||
function rotl (x, n) {
|
||||
return (x << n) | (x >>> (32 - n))
|
||||
}
|
||||
|
||||
function fnF (a, b, c, d, m, k, s) {
|
||||
return (rotl((a + ((b & c) | ((~b) & d)) + m + k) | 0, s) + b) | 0
|
||||
}
|
||||
|
||||
function fnG (a, b, c, d, m, k, s) {
|
||||
return (rotl((a + ((b & d) | (c & (~d))) + m + k) | 0, s) + b) | 0
|
||||
}
|
||||
|
||||
function fnH (a, b, c, d, m, k, s) {
|
||||
return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + b) | 0
|
||||
}
|
||||
|
||||
function fnI (a, b, c, d, m, k, s) {
|
||||
return (rotl((a + ((c ^ (b | (~d)))) + m + k) | 0, s) + b) | 0
|
||||
}
|
||||
|
||||
module.exports = MD5
|
38
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/md5.js/package.json
generated
vendored
Normal file
38
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/md5.js/package.json
generated
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"name": "md5.js",
|
||||
"version": "1.3.5",
|
||||
"description": "node style md5 on pure JavaScript",
|
||||
"keywords": [
|
||||
"crypto",
|
||||
"md5"
|
||||
],
|
||||
"homepage": "https://github.com/crypto-browserify/md5.js",
|
||||
"bugs": {
|
||||
"url": "https://github.com/crypto-browserify/md5.js/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": "Kirill Fomichev <fanatid@ya.ru> (https://github.com/fanatid)",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/crypto-browserify/md5.js.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "standard",
|
||||
"test": "npm run lint && npm run unit",
|
||||
"unit": "node test/*.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"hash-base": "^3.0.0",
|
||||
"inherits": "^2.0.1",
|
||||
"safe-buffer": "^5.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"hash-test-vectors": "^1.3.2",
|
||||
"standard": "^7.0.0",
|
||||
"tape": "^4.2.0"
|
||||
}
|
||||
}
|
55
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/mem/index.js
generated
vendored
Normal file
55
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/mem/index.js
generated
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
'use strict';
|
||||
const mimicFn = require('mimic-fn');
|
||||
|
||||
const cacheStore = new WeakMap();
|
||||
|
||||
const defaultCacheKey = function (x) {
|
||||
if (arguments.length === 1 && (x === null || x === undefined || (typeof x !== 'function' && typeof x !== 'object'))) {
|
||||
return x;
|
||||
}
|
||||
|
||||
return JSON.stringify(arguments);
|
||||
};
|
||||
|
||||
module.exports = (fn, opts) => {
|
||||
opts = Object.assign({
|
||||
cacheKey: defaultCacheKey,
|
||||
cache: new Map()
|
||||
}, opts);
|
||||
|
||||
const memoized = function () {
|
||||
const cache = cacheStore.get(memoized);
|
||||
const key = opts.cacheKey.apply(null, arguments);
|
||||
|
||||
if (cache.has(key)) {
|
||||
const c = cache.get(key);
|
||||
|
||||
if (typeof opts.maxAge !== 'number' || Date.now() < c.maxAge) {
|
||||
return c.data;
|
||||
}
|
||||
}
|
||||
|
||||
const ret = fn.apply(null, arguments);
|
||||
|
||||
cache.set(key, {
|
||||
data: ret,
|
||||
maxAge: Date.now() + (opts.maxAge || 0)
|
||||
});
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
mimicFn(memoized, fn);
|
||||
|
||||
cacheStore.set(memoized, opts.cache);
|
||||
|
||||
return memoized;
|
||||
};
|
||||
|
||||
module.exports.clear = fn => {
|
||||
const cache = cacheStore.get(fn);
|
||||
|
||||
if (cache && typeof cache.clear === 'function') {
|
||||
cache.clear();
|
||||
}
|
||||
};
|
21
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/mem/license
generated
vendored
Normal file
21
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/mem/license
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
45
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/mem/package.json
generated
vendored
Normal file
45
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/mem/package.json
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
"name": "mem",
|
||||
"version": "1.1.0",
|
||||
"description": "Memoize functions - An optimization used to speed up consecutive function calls by caching the result of calls with identical input",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/mem",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"memoize",
|
||||
"function",
|
||||
"mem",
|
||||
"memoization",
|
||||
"cache",
|
||||
"caching",
|
||||
"optimize",
|
||||
"performance",
|
||||
"ttl",
|
||||
"expire",
|
||||
"promise"
|
||||
],
|
||||
"dependencies": {
|
||||
"mimic-fn": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"delay": "^1.1.0",
|
||||
"xo": "*"
|
||||
},
|
||||
"xo": {
|
||||
"esnext": true
|
||||
}
|
||||
}
|
147
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/mem/readme.md
generated
vendored
Normal file
147
11-前端模块化开发Webpack(Node.js基础)/04-webpack_Loader使用/node_modules/mem/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,147 @@
|
|||
# mem [![Build Status](https://travis-ci.org/sindresorhus/mem.svg?branch=master)](https://travis-ci.org/sindresorhus/mem)
|
||||
|
||||
> [Memoize](https://en.wikipedia.org/wiki/Memoization) functions - An optimization used to speed up consecutive function calls by caching the result of calls with identical input
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save mem
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const mem = require('mem');
|
||||
|
||||
let i = 0;
|
||||
const counter = () => ++i;
|
||||
const memoized = mem(counter);
|
||||
|
||||
memoized('foo');
|
||||
//=> 1
|
||||
|
||||
// cached as it's the same arguments
|
||||
memoized('foo');
|
||||
//=> 1
|
||||
|
||||
// not cached anymore as the arguments changed
|
||||
memoized('bar');
|
||||
//=> 2
|
||||
|
||||
memoized('bar');
|
||||
//=> 2
|
||||
```
|
||||
|
||||
##### Works fine with promise returning functions
|
||||
|
||||
```js
|
||||
const mem = require('mem');
|
||||
|
||||
let i = 0;
|
||||
const counter = () => Promise.resolve(++i);
|
||||
const memoized = mem(counter);
|
||||
|
||||
memoized().then(a => {
|
||||
console.log(a);
|
||||
//=> 1
|
||||
|
||||
memoized().then(b => {
|
||||
// the return value didn't increase as it's cached
|
||||
console.log(b);
|
||||
//=> 1
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
```js
|
||||
const mem = require('mem');
|
||||
const got = require('got');
|
||||
const memGot = mem(got, {maxAge: 1000});
|
||||
|
||||
memGot('sindresorhus.com').then(() => {
|
||||
// this call is cached
|
||||
memGot('sindresorhus.com').then(() => {
|
||||
setTimeout(() => {
|
||||
// this call is not cached as the cache has expired
|
||||
memGot('sindresorhus.com').then(() => {});
|
||||
}, 2000);
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### mem(fn, [options])
|
||||
|
||||
#### fn
|
||||
|
||||
Type: `Function`
|
||||
|
||||
Function to be memoized.
|
||||
|
||||
#### options
|
||||
|
||||
##### maxAge
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `Infinity`
|
||||
|
||||
Milliseconds until the cache expires.
|
||||
|
||||
##### cacheKey
|
||||
|
||||
Type: `Function`
|
||||
|
||||
Determines the cache key for storing the result based on the function arguments. By default, if there's only one argument and it's a [primitive](https://developer.mozilla.org/en-US/docs/Glossary/Primitive), it's used directly as a key, otherwise it's all the function arguments JSON stringified as an array.
|
||||
|
||||
You could for example change it to only cache on the first argument `x => JSON.stringify(x)`.
|
||||
|
||||
##### cache
|
||||
|
||||
Type: `Object`<br>
|
||||
Default: `new Map()`
|
||||
|
||||
Use a different cache storage. Must implement the following methods: `.has(key)`, `.get(key)`, `.set(key, value)`, and optionally `.clear()`. You could for example use a `WeakMap` instead.
|
||||
|
||||
### mem.clear(fn)
|
||||
|
||||
Clear all cached data of a memoized function.
|
||||
|
||||
#### fn
|
||||
|
||||
Type: `Function`
|
||||
|
||||
Memoized function.
|
||||
|
||||
|
||||
## Tips
|
||||
|
||||
### Cache statistics
|
||||
|
||||
If you want to know how many times your cache had a hit or a miss, you can make use of [stats-map](https://github.com/SamVerschueren/stats-map) as a replacement for the default cache.
|
||||
|
||||
#### Example
|
||||
|
||||
```js
|
||||
const mem = require('mem');
|
||||
const StatsMap = require('stats-map');
|
||||
const got = require('got');
|
||||
|
||||
const cache = new StatsMap();
|
||||
const memGot = mem(got, {cache});
|
||||
|
||||
memGot('sindresorhus.com')
|
||||
.then(() => memGot('sindresorhus.com'))
|
||||
.then(() => memGot('sindresorhus.com'));
|
||||
|
||||
console.log(cache.stats);
|
||||
//=> {hits: 2, misses: 1}
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue