Compare commits

...

2 Commits

Author SHA1 Message Date
John-David Dalton
0cf3476f14 Bump to v4.13.0. 2016-05-22 19:38:19 -07:00
John-David Dalton
dbe6a9008c Bump to v4.12.0. 2016-05-08 12:30:27 -07:00
215 changed files with 2262 additions and 1847 deletions

View File

@@ -1,4 +1,4 @@
# lodash v4.11.2 # lodash v4.13.0
The [Lodash](https://lodash.com/) library exported as [Node.js](https://nodejs.org/) modules. The [Lodash](https://lodash.com/) library exported as [Node.js](https://nodejs.org/) modules.
@@ -28,13 +28,13 @@ var chunk = require('lodash/chunk');
var extend = require('lodash/fp/extend'); var extend = require('lodash/fp/extend');
``` ```
See the [package source](https://github.com/lodash/lodash/tree/4.11.2-npm) for more details. See the [package source](https://github.com/lodash/lodash/tree/4.13.0-npm) for more details.
**Note:**<br> **Note:**<br>
Dont assign values to the [special variable](http://nodejs.org/api/repl.html#repl_repl_features) `_` when in the REPL.<br> Dont assign values to the [special variable](http://nodejs.org/api/repl.html#repl_repl_features) `_` in the Node.js < 6 REPL.<br>
Install [n_](https://www.npmjs.com/package/n_) for a REPL that includes `lodash` by default. Install [n_](https://www.npmjs.com/package/n_) for a REPL that includes `lodash` by default.
## Support ## Support
Tested in Chrome 48-49, Firefox 44-45, IE 9-11, Edge 13, Safari 8-9, Node.js 0.10, 0.12, 4, & 5, & PhantomJS 1.9.8.<br> Tested in Chrome 49-50, Firefox 45-46, IE 9-11, Edge 13, Safari 8-9, Node.js 0.10-6, & PhantomJS 1.9.8.<br>
Automated [browser](https://saucelabs.com/u/lodash) & [CI](https://travis-ci.org/lodash/lodash/) test runs are available. Automated [browser](https://saucelabs.com/u/lodash) & [CI](https://travis-ci.org/lodash/lodash/) test runs are available.

View File

@@ -1,18 +1,32 @@
var nativeCreate = require('./_nativeCreate'); var hashClear = require('./_hashClear'),
hashDelete = require('./_hashDelete'),
/** Used for built-in method references. */ hashGet = require('./_hashGet'),
var objectProto = Object.prototype; hashHas = require('./_hashHas'),
hashSet = require('./_hashSet');
/** /**
* Creates a hash object. * Creates a hash object.
* *
* @private * @private
* @constructor * @constructor
* @returns {Object} Returns the new hash object. * @param {Array} [entries] The key-value pairs to cache.
*/ */
function Hash() {} function Hash(entries) {
var index = -1,
length = entries ? entries.length : 0;
// Avoid inheriting from `Object.prototype` when possible. this.clear();
Hash.prototype = nativeCreate ? nativeCreate(null) : objectProto; while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
// Add methods to `Hash`.
Hash.prototype.clear = hashClear;
Hash.prototype['delete'] = hashDelete;
Hash.prototype.get = hashGet;
Hash.prototype.has = hashHas;
Hash.prototype.set = hashSet;
module.exports = Hash; module.exports = Hash;

32
_ListCache.js Normal file
View File

@@ -0,0 +1,32 @@
var listCacheClear = require('./_listCacheClear'),
listCacheDelete = require('./_listCacheDelete'),
listCacheGet = require('./_listCacheGet'),
listCacheHas = require('./_listCacheHas'),
listCacheSet = require('./_listCacheSet');
/**
* Creates an list cache object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function ListCache(entries) {
var index = -1,
length = entries ? entries.length : 0;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
// Add methods to `ListCache`.
ListCache.prototype.clear = listCacheClear;
ListCache.prototype['delete'] = listCacheDelete;
ListCache.prototype.get = listCacheGet;
ListCache.prototype.has = listCacheHas;
ListCache.prototype.set = listCacheSet;
module.exports = ListCache;

View File

@@ -1,32 +1,32 @@
var mapClear = require('./_mapClear'), var mapCacheClear = require('./_mapCacheClear'),
mapDelete = require('./_mapDelete'), mapCacheDelete = require('./_mapCacheDelete'),
mapGet = require('./_mapGet'), mapCacheGet = require('./_mapCacheGet'),
mapHas = require('./_mapHas'), mapCacheHas = require('./_mapCacheHas'),
mapSet = require('./_mapSet'); mapCacheSet = require('./_mapCacheSet');
/** /**
* Creates a map cache object to store key-value pairs. * Creates a map cache object to store key-value pairs.
* *
* @private * @private
* @constructor * @constructor
* @param {Array} [values] The values to cache. * @param {Array} [entries] The key-value pairs to cache.
*/ */
function MapCache(values) { function MapCache(entries) {
var index = -1, var index = -1,
length = values ? values.length : 0; length = entries ? entries.length : 0;
this.clear(); this.clear();
while (++index < length) { while (++index < length) {
var entry = values[index]; var entry = entries[index];
this.set(entry[0], entry[1]); this.set(entry[0], entry[1]);
} }
} }
// Add methods to `MapCache`. // Add methods to `MapCache`.
MapCache.prototype.clear = mapClear; MapCache.prototype.clear = mapCacheClear;
MapCache.prototype['delete'] = mapDelete; MapCache.prototype['delete'] = mapCacheDelete;
MapCache.prototype.get = mapGet; MapCache.prototype.get = mapCacheGet;
MapCache.prototype.has = mapHas; MapCache.prototype.has = mapCacheHas;
MapCache.prototype.set = mapSet; MapCache.prototype.set = mapCacheSet;
module.exports = MapCache; module.exports = MapCache;

View File

@@ -1,9 +1,10 @@
var MapCache = require('./_MapCache'), var MapCache = require('./_MapCache'),
cachePush = require('./_cachePush'); setCacheAdd = require('./_setCacheAdd'),
setCacheHas = require('./_setCacheHas');
/** /**
* *
* Creates a set cache object to store unique values. * Creates an array cache object to store unique values.
* *
* @private * @private
* @constructor * @constructor
@@ -15,11 +16,12 @@ function SetCache(values) {
this.__data__ = new MapCache; this.__data__ = new MapCache;
while (++index < length) { while (++index < length) {
this.push(values[index]); this.add(values[index]);
} }
} }
// Add methods to `SetCache`. // Add methods to `SetCache`.
SetCache.prototype.push = cachePush; SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
SetCache.prototype.has = setCacheHas;
module.exports = SetCache; module.exports = SetCache;

View File

@@ -1,4 +1,5 @@
var stackClear = require('./_stackClear'), var ListCache = require('./_ListCache'),
stackClear = require('./_stackClear'),
stackDelete = require('./_stackDelete'), stackDelete = require('./_stackDelete'),
stackGet = require('./_stackGet'), stackGet = require('./_stackGet'),
stackHas = require('./_stackHas'), stackHas = require('./_stackHas'),
@@ -9,17 +10,10 @@ var stackClear = require('./_stackClear'),
* *
* @private * @private
* @constructor * @constructor
* @param {Array} [values] The values to cache. * @param {Array} [entries] The key-value pairs to cache.
*/ */
function Stack(values) { function Stack(entries) {
var index = -1, this.__data__ = new ListCache(entries);
length = values ? values.length : 0;
this.clear();
while (++index < length) {
var entry = values[index];
this.set(entry[0], entry[1]);
}
} }
// Add methods to `Stack`. // Add methods to `Stack`.

View File

@@ -2,7 +2,7 @@
* A specialized version of `baseAggregator` for arrays. * A specialized version of `baseAggregator` for arrays.
* *
* @private * @private
* @param {Array} array The array to iterate over. * @param {Array} [array] The array to iterate over.
* @param {Function} setter The function to set `accumulator` values. * @param {Function} setter The function to set `accumulator` values.
* @param {Function} iteratee The iteratee to transform keys. * @param {Function} iteratee The iteratee to transform keys.
* @param {Object} accumulator The initial aggregated object. * @param {Object} accumulator The initial aggregated object.
@@ -10,7 +10,7 @@
*/ */
function arrayAggregator(array, setter, iteratee, accumulator) { function arrayAggregator(array, setter, iteratee, accumulator) {
var index = -1, var index = -1,
length = array.length; length = array ? array.length : 0;
while (++index < length) { while (++index < length) {
var value = array[index]; var value = array[index];

View File

@@ -1,25 +0,0 @@
/**
* Creates a new array concatenating `array` with `other`.
*
* @private
* @param {Array} array The first array to concatenate.
* @param {Array} other The second array to concatenate.
* @returns {Array} Returns the new concatenated array.
*/
function arrayConcat(array, other) {
var index = -1,
length = array.length,
othIndex = -1,
othLength = other.length,
result = Array(length + othLength);
while (++index < length) {
result[index] = array[index];
}
while (++othIndex < othLength) {
result[index++] = other[othIndex];
}
return result;
}
module.exports = arrayConcat;

View File

@@ -3,13 +3,13 @@
* iteratee shorthands. * iteratee shorthands.
* *
* @private * @private
* @param {Array} array The array to iterate over. * @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration. * @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns `array`. * @returns {Array} Returns `array`.
*/ */
function arrayEach(array, iteratee) { function arrayEach(array, iteratee) {
var index = -1, var index = -1,
length = array.length; length = array ? array.length : 0;
while (++index < length) { while (++index < length) {
if (iteratee(array[index], index, array) === false) { if (iteratee(array[index], index, array) === false) {

View File

@@ -3,12 +3,12 @@
* iteratee shorthands. * iteratee shorthands.
* *
* @private * @private
* @param {Array} array The array to iterate over. * @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration. * @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns `array`. * @returns {Array} Returns `array`.
*/ */
function arrayEachRight(array, iteratee) { function arrayEachRight(array, iteratee) {
var length = array.length; var length = array ? array.length : 0;
while (length--) { while (length--) {
if (iteratee(array[length], length, array) === false) { if (iteratee(array[length], length, array) === false) {

View File

@@ -3,14 +3,14 @@
* iteratee shorthands. * iteratee shorthands.
* *
* @private * @private
* @param {Array} array The array to iterate over. * @param {Array} [array] The array to iterate over.
* @param {Function} predicate The function invoked per iteration. * @param {Function} predicate The function invoked per iteration.
* @returns {boolean} Returns `true` if all elements pass the predicate check, * @returns {boolean} Returns `true` if all elements pass the predicate check,
* else `false`. * else `false`.
*/ */
function arrayEvery(array, predicate) { function arrayEvery(array, predicate) {
var index = -1, var index = -1,
length = array.length; length = array ? array.length : 0;
while (++index < length) { while (++index < length) {
if (!predicate(array[index], index, array)) { if (!predicate(array[index], index, array)) {

View File

@@ -3,13 +3,13 @@
* iteratee shorthands. * iteratee shorthands.
* *
* @private * @private
* @param {Array} array The array to iterate over. * @param {Array} [array] The array to iterate over.
* @param {Function} predicate The function invoked per iteration. * @param {Function} predicate The function invoked per iteration.
* @returns {Array} Returns the new filtered array. * @returns {Array} Returns the new filtered array.
*/ */
function arrayFilter(array, predicate) { function arrayFilter(array, predicate) {
var index = -1, var index = -1,
length = array.length, length = array ? array.length : 0,
resIndex = 0, resIndex = 0,
result = []; result = [];

View File

@@ -5,12 +5,13 @@ var baseIndexOf = require('./_baseIndexOf');
* specifying an index to search from. * specifying an index to search from.
* *
* @private * @private
* @param {Array} array The array to search. * @param {Array} [array] The array to search.
* @param {*} target The value to search for. * @param {*} target The value to search for.
* @returns {boolean} Returns `true` if `target` is found, else `false`. * @returns {boolean} Returns `true` if `target` is found, else `false`.
*/ */
function arrayIncludes(array, value) { function arrayIncludes(array, value) {
return !!array.length && baseIndexOf(array, value, 0) > -1; var length = array ? array.length : 0;
return !!length && baseIndexOf(array, value, 0) > -1;
} }
module.exports = arrayIncludes; module.exports = arrayIncludes;

View File

@@ -2,14 +2,14 @@
* This function is like `arrayIncludes` except that it accepts a comparator. * This function is like `arrayIncludes` except that it accepts a comparator.
* *
* @private * @private
* @param {Array} array The array to search. * @param {Array} [array] The array to search.
* @param {*} target The value to search for. * @param {*} target The value to search for.
* @param {Function} comparator The comparator invoked per element. * @param {Function} comparator The comparator invoked per element.
* @returns {boolean} Returns `true` if `target` is found, else `false`. * @returns {boolean} Returns `true` if `target` is found, else `false`.
*/ */
function arrayIncludesWith(array, value, comparator) { function arrayIncludesWith(array, value, comparator) {
var index = -1, var index = -1,
length = array.length; length = array ? array.length : 0;
while (++index < length) { while (++index < length) {
if (comparator(value, array[index])) { if (comparator(value, array[index])) {

View File

@@ -3,13 +3,13 @@
* shorthands. * shorthands.
* *
* @private * @private
* @param {Array} array The array to iterate over. * @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration. * @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns the new mapped array. * @returns {Array} Returns the new mapped array.
*/ */
function arrayMap(array, iteratee) { function arrayMap(array, iteratee) {
var index = -1, var index = -1,
length = array.length, length = array ? array.length : 0,
result = Array(length); result = Array(length);
while (++index < length) { while (++index < length) {

View File

@@ -3,7 +3,7 @@
* iteratee shorthands. * iteratee shorthands.
* *
* @private * @private
* @param {Array} array The array to iterate over. * @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration. * @param {Function} iteratee The function invoked per iteration.
* @param {*} [accumulator] The initial value. * @param {*} [accumulator] The initial value.
* @param {boolean} [initAccum] Specify using the first element of `array` as * @param {boolean} [initAccum] Specify using the first element of `array` as
@@ -12,7 +12,7 @@
*/ */
function arrayReduce(array, iteratee, accumulator, initAccum) { function arrayReduce(array, iteratee, accumulator, initAccum) {
var index = -1, var index = -1,
length = array.length; length = array ? array.length : 0;
if (initAccum && length) { if (initAccum && length) {
accumulator = array[++index]; accumulator = array[++index];

View File

@@ -3,7 +3,7 @@
* iteratee shorthands. * iteratee shorthands.
* *
* @private * @private
* @param {Array} array The array to iterate over. * @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration. * @param {Function} iteratee The function invoked per iteration.
* @param {*} [accumulator] The initial value. * @param {*} [accumulator] The initial value.
* @param {boolean} [initAccum] Specify using the last element of `array` as * @param {boolean} [initAccum] Specify using the last element of `array` as
@@ -11,7 +11,7 @@
* @returns {*} Returns the accumulated value. * @returns {*} Returns the accumulated value.
*/ */
function arrayReduceRight(array, iteratee, accumulator, initAccum) { function arrayReduceRight(array, iteratee, accumulator, initAccum) {
var length = array.length; var length = array ? array.length : 0;
if (initAccum && length) { if (initAccum && length) {
accumulator = array[--length]; accumulator = array[--length];
} }

View File

@@ -3,14 +3,14 @@
* shorthands. * shorthands.
* *
* @private * @private
* @param {Array} array The array to iterate over. * @param {Array} [array] The array to iterate over.
* @param {Function} predicate The function invoked per iteration. * @param {Function} predicate The function invoked per iteration.
* @returns {boolean} Returns `true` if any element passes the predicate check, * @returns {boolean} Returns `true` if any element passes the predicate check,
* else `false`. * else `false`.
*/ */
function arraySome(array, predicate) { function arraySome(array, predicate) {
var index = -1, var index = -1,
length = array.length; length = array ? array.length : 0;
while (++index < length) { while (++index < length) {
if (predicate(array[index], index, array)) { if (predicate(array[index], index, array)) {

View File

@@ -1,16 +0,0 @@
var assocIndexOf = require('./_assocIndexOf');
/**
* Gets the associative array value for `key`.
*
* @private
* @param {Array} array The array to query.
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function assocGet(array, key) {
var index = assocIndexOf(array, key);
return index < 0 ? undefined : array[index][1];
}
module.exports = assocGet;

View File

@@ -1,20 +0,0 @@
var assocIndexOf = require('./_assocIndexOf');
/**
* Sets the associative array `key` to `value`.
*
* @private
* @param {Array} array The array to modify.
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
*/
function assocSet(array, key, value) {
var index = assocIndexOf(array, key);
if (index < 0) {
array.push([key, value]);
} else {
array[index][1] = value;
}
}
module.exports = assocSet;

View File

@@ -6,7 +6,7 @@ var get = require('./get');
* @private * @private
* @param {Object} object The object to iterate over. * @param {Object} object The object to iterate over.
* @param {string[]} paths The property paths of elements to pick. * @param {string[]} paths The property paths of elements to pick.
* @returns {Array} Returns the new array of picked elements. * @returns {Array} Returns the picked elements.
*/ */
function baseAt(object, paths) { function baseAt(object, paths) {
var index = -1, var index = -1,

View File

@@ -5,7 +5,7 @@ var keys = require('./keys');
* *
* @private * @private
* @param {Object} source The object of property predicates to conform to. * @param {Object} source The object of property predicates to conform to.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new spec function.
*/ */
function baseConforms(source) { function baseConforms(source) {
var props = keys(source), var props = keys(source),

View File

@@ -5,12 +5,13 @@
* @private * @private
* @param {Array} array The array to search. * @param {Array} array The array to search.
* @param {Function} predicate The function invoked per iteration. * @param {Function} predicate The function invoked per iteration.
* @param {number} fromIndex The index to search from.
* @param {boolean} [fromRight] Specify iterating from right to left. * @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {number} Returns the index of the matched value, else `-1`. * @returns {number} Returns the index of the matched value, else `-1`.
*/ */
function baseFindIndex(array, predicate, fromRight) { function baseFindIndex(array, predicate, fromIndex, fromRight) {
var length = array.length, var length = array.length,
index = fromRight ? length : -1; index = fromIndex + (fromRight ? 1 : -1);
while ((fromRight ? index-- : ++index < length)) { while ((fromRight ? index-- : ++index < length)) {
if (predicate(array[index], index, array)) { if (predicate(array[index], index, array)) {

View File

@@ -1,25 +1,23 @@
/** /**
* The base implementation of methods like `_.find` and `_.findKey`, without * The base implementation of methods like `_.findKey` and `_.findLastKey`,
* support for iteratee shorthands, which iterates over `collection` using * without support for iteratee shorthands, which iterates over `collection`
* `eachFunc`. * using `eachFunc`.
* *
* @private * @private
* @param {Array|Object} collection The collection to search. * @param {Array|Object} collection The collection to search.
* @param {Function} predicate The function invoked per iteration. * @param {Function} predicate The function invoked per iteration.
* @param {Function} eachFunc The function to iterate over `collection`. * @param {Function} eachFunc The function to iterate over `collection`.
* @param {boolean} [retKey] Specify returning the key of the found element
* instead of the element itself.
* @returns {*} Returns the found element or its key, else `undefined`. * @returns {*} Returns the found element or its key, else `undefined`.
*/ */
function baseFind(collection, predicate, eachFunc, retKey) { function baseFindKey(collection, predicate, eachFunc) {
var result; var result;
eachFunc(collection, function(value, key, collection) { eachFunc(collection, function(value, key, collection) {
if (predicate(value, key, collection)) { if (predicate(value, key, collection)) {
result = retKey ? key : value; result = key;
return false; return false;
} }
}); });
return result; return result;
} }
module.exports = baseFind; module.exports = baseFindKey;

View File

@@ -8,7 +8,7 @@ var arrayFilter = require('./_arrayFilter'),
* @private * @private
* @param {Object} object The object to inspect. * @param {Object} object The object to inspect.
* @param {Array} props The property names to filter. * @param {Array} props The property names to filter.
* @returns {Array} Returns the new array of filtered property names. * @returns {Array} Returns the function names.
*/ */
function baseFunctions(object, props) { function baseFunctions(object, props) {
return arrayFilter(props, function(key) { return arrayFilter(props, function(key) {

View File

@@ -14,9 +14,7 @@ var arrayPush = require('./_arrayPush'),
*/ */
function baseGetAllKeys(object, keysFunc, symbolsFunc) { function baseGetAllKeys(object, keysFunc, symbolsFunc) {
var result = keysFunc(object); var result = keysFunc(object);
return isArray(object) return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
? result
: arrayPush(result, symbolsFunc(object));
} }
module.exports = baseGetAllKeys; module.exports = baseGetAllKeys;

View File

@@ -10,7 +10,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* The base implementation of `_.has` without support for deep paths. * The base implementation of `_.has` without support for deep paths.
* *
* @private * @private
* @param {Object} object The object to query. * @param {Object} [object] The object to query.
* @param {Array|string} key The key to check. * @param {Array|string} key The key to check.
* @returns {boolean} Returns `true` if `key` exists, else `false`. * @returns {boolean} Returns `true` if `key` exists, else `false`.
*/ */
@@ -18,8 +18,9 @@ function baseHas(object, key) {
// Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`, // Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`,
// that are composed entirely of index properties, return `false` for // that are composed entirely of index properties, return `false` for
// `hasOwnProperty` checks of them. // `hasOwnProperty` checks of them.
return hasOwnProperty.call(object, key) || return object != null &&
(typeof object == 'object' && key in object && getPrototype(object) === null); (hasOwnProperty.call(object, key) ||
(typeof object == 'object' && key in object && getPrototype(object) === null));
} }
module.exports = baseHas; module.exports = baseHas;

View File

@@ -2,12 +2,12 @@
* The base implementation of `_.hasIn` without support for deep paths. * The base implementation of `_.hasIn` without support for deep paths.
* *
* @private * @private
* @param {Object} object The object to query. * @param {Object} [object] The object to query.
* @param {Array|string} key The key to check. * @param {Array|string} key The key to check.
* @returns {boolean} Returns `true` if `key` exists, else `false`. * @returns {boolean} Returns `true` if `key` exists, else `false`.
*/ */
function baseHasIn(object, key) { function baseHasIn(object, key) {
return key in Object(object); return object != null && key in Object(object);
} }
module.exports = baseHasIn; module.exports = baseHasIn;

47
_baseIsNative.js Normal file
View File

@@ -0,0 +1,47 @@
var isFunction = require('./isFunction'),
isHostObject = require('./_isHostObject'),
isMasked = require('./_isMasked'),
isObject = require('./isObject'),
toSource = require('./_toSource');
/**
* Used to match `RegExp`
* [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns).
*/
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
/** Used to detect host constructors (Safari). */
var reIsHostCtor = /^\[object .+?Constructor\]$/;
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to resolve the decompiled source of functions. */
var funcToString = Function.prototype.toString;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/** Used to detect if a method is native. */
var reIsNative = RegExp('^' +
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
);
/**
* The base implementation of `_.isNative` without bad shim checks.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a native function,
* else `false`.
*/
function baseIsNative(value) {
if (!isObject(value) || isMasked(value)) {
return false;
}
var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
return pattern.test(toSource(value));
}
module.exports = baseIsNative;

View File

@@ -7,7 +7,7 @@ var baseIsMatch = require('./_baseIsMatch'),
* *
* @private * @private
* @param {Object} source The object of property values to match. * @param {Object} source The object of property values to match.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new spec function.
*/ */
function baseMatches(source) { function baseMatches(source) {
var matchData = getMatchData(source); var matchData = getMatchData(source);

View File

@@ -16,7 +16,7 @@ var UNORDERED_COMPARE_FLAG = 1,
* @private * @private
* @param {string} path The path of the property to get. * @param {string} path The path of the property to get.
* @param {*} srcValue The value to match. * @param {*} srcValue The value to match.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new spec function.
*/ */
function baseMatchesProperty(path, srcValue) { function baseMatchesProperty(path, srcValue) {
if (isKey(path) && isStrictComparable(srcValue)) { if (isKey(path) && isStrictComparable(srcValue)) {

View File

@@ -3,7 +3,7 @@
* *
* @private * @private
* @param {string} key The key of the property to get. * @param {string} key The key of the property to get.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new accessor function.
*/ */
function baseProperty(key) { function baseProperty(key) {
return function(object) { return function(object) {

View File

@@ -5,7 +5,7 @@ var baseGet = require('./_baseGet');
* *
* @private * @private
* @param {Array|string} path The path of the property to get. * @param {Array|string} path The path of the property to get.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new accessor function.
*/ */
function basePropertyDeep(path) { function basePropertyDeep(path) {
return function(object) { return function(object) {

View File

@@ -1,7 +1,8 @@
var arrayMap = require('./_arrayMap'), var arrayMap = require('./_arrayMap'),
baseIndexOf = require('./_baseIndexOf'), baseIndexOf = require('./_baseIndexOf'),
baseIndexOfWith = require('./_baseIndexOfWith'), baseIndexOfWith = require('./_baseIndexOfWith'),
baseUnary = require('./_baseUnary'); baseUnary = require('./_baseUnary'),
copyArray = require('./_copyArray');
/** Used for built-in method references. */ /** Used for built-in method references. */
var arrayProto = Array.prototype; var arrayProto = Array.prototype;
@@ -26,6 +27,9 @@ function basePullAll(array, values, iteratee, comparator) {
length = values.length, length = values.length,
seen = array; seen = array;
if (array === values) {
values = copyArray(values);
}
if (iteratee) { if (iteratee) {
seen = arrayMap(array, baseUnary(iteratee)); seen = arrayMap(array, baseUnary(iteratee));
} }

View File

@@ -11,7 +11,7 @@ var nativeCeil = Math.ceil,
* @param {number} end The end of the range. * @param {number} end The end of the range.
* @param {number} step The value to increment or decrement by. * @param {number} step The value to increment or decrement by.
* @param {boolean} [fromRight] Specify iterating from right to left. * @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {Array} Returns the new array of numbers. * @returns {Array} Returns the range of numbers.
*/ */
function baseRange(start, end, step, fromRight) { function baseRange(start, end, step, fromRight) {
var index = -1, var index = -1,

View File

@@ -7,7 +7,7 @@ var arrayMap = require('./_arrayMap');
* @private * @private
* @param {Object} object The object to query. * @param {Object} object The object to query.
* @param {Array} props The property names to get values for. * @param {Array} props The property names to get values for.
* @returns {Object} Returns the new array of key-value pairs. * @returns {Object} Returns the key-value pairs.
*/ */
function baseToPairs(object, props) { function baseToPairs(object, props) {
return arrayMap(props, function(key) { return arrayMap(props, function(key) {

View File

@@ -3,7 +3,7 @@
* *
* @private * @private
* @param {Function} func The function to cap arguments for. * @param {Function} func The function to cap arguments for.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new capped function.
*/ */
function baseUnary(func) { function baseUnary(func) {
return function(value) { return function(value) {

View File

@@ -1,25 +1,13 @@
var isKeyable = require('./_isKeyable');
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
/** /**
* Checks if `value` is in `cache`. * Checks if a cache value for `key` exists.
* *
* @private * @private
* @param {Object} cache The set cache to search. * @param {Object} cache The cache to query.
* @param {*} value The value to search for. * @param {string} key The key of the entry to check.
* @returns {number} Returns `true` if `value` is found, else `false`. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/ */
function cacheHas(cache, value) { function cacheHas(cache, key) {
var map = cache.__data__; return cache.has(key);
if (isKeyable(value)) {
var data = map.__data__,
hash = typeof value == 'string' ? data.string : data.hash;
return hash[value] === HASH_UNDEFINED;
}
return map.has(value);
} }
module.exports = cacheHas; module.exports = cacheHas;

View File

@@ -1,27 +0,0 @@
var isKeyable = require('./_isKeyable');
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
/**
* Adds `value` to the set cache.
*
* @private
* @name push
* @memberOf SetCache
* @param {*} value The value to cache.
*/
function cachePush(value) {
var map = this.__data__;
if (isKeyable(value)) {
var data = map.__data__,
hash = typeof value == 'string' ? data.string : data.hash;
hash[value] = HASH_UNDEFINED;
}
else {
map.set(value, HASH_UNDEFINED);
}
}
module.exports = cachePush;

View File

@@ -6,7 +6,7 @@ var nativeMax = Math.max;
* placeholders, and provided arguments into a single array of arguments. * placeholders, and provided arguments into a single array of arguments.
* *
* @private * @private
* @param {Array|Object} args The provided arguments. * @param {Array} args The provided arguments.
* @param {Array} partials The arguments to prepend to those provided. * @param {Array} partials The arguments to prepend to those provided.
* @param {Array} holders The `partials` placeholder indexes. * @param {Array} holders The `partials` placeholder indexes.
* @params {boolean} [isCurried] Specify composing for a curried function. * @params {boolean} [isCurried] Specify composing for a curried function.

View File

@@ -6,7 +6,7 @@ var nativeMax = Math.max;
* is tailored for `_.partialRight`. * is tailored for `_.partialRight`.
* *
* @private * @private
* @param {Array|Object} args The provided arguments. * @param {Array} args The provided arguments.
* @param {Array} partials The arguments to append to those provided. * @param {Array} partials The arguments to append to those provided.
* @param {Array} holders The `partials` placeholder indexes. * @param {Array} holders The `partials` placeholder indexes.
* @params {boolean} [isCurried] Specify composing for a curried function. * @params {boolean} [isCurried] Specify composing for a curried function.

6
_coreJsData.js Normal file
View File

@@ -0,0 +1,6 @@
var root = require('./_root');
/** Used to detect overreaching core-js shims. */
var coreJsData = root['__core-js_shared__'];
module.exports = coreJsData;

View File

@@ -15,7 +15,7 @@ function createAssigner(assigner) {
customizer = length > 1 ? sources[length - 1] : undefined, customizer = length > 1 ? sources[length - 1] : undefined,
guard = length > 2 ? sources[2] : undefined; guard = length > 2 ? sources[2] : undefined;
customizer = typeof customizer == 'function' customizer = (assigner.length > 3 && typeof customizer == 'function')
? (length--, customizer) ? (length--, customizer)
: undefined; : undefined;

View File

@@ -8,7 +8,7 @@ var castSlice = require('./_castSlice'),
* *
* @private * @private
* @param {string} methodName The name of the `String` case method to use. * @param {string} methodName The name of the `String` case method to use.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new case function.
*/ */
function createCaseFirst(methodName) { function createCaseFirst(methodName) {
return function(string) { return function(string) {

View File

@@ -2,7 +2,7 @@ var apply = require('./_apply'),
createCtorWrapper = require('./_createCtorWrapper'), createCtorWrapper = require('./_createCtorWrapper'),
createHybridWrapper = require('./_createHybridWrapper'), createHybridWrapper = require('./_createHybridWrapper'),
createRecurryWrapper = require('./_createRecurryWrapper'), createRecurryWrapper = require('./_createRecurryWrapper'),
getPlaceholder = require('./_getPlaceholder'), getHolder = require('./_getHolder'),
replaceHolders = require('./_replaceHolders'), replaceHolders = require('./_replaceHolders'),
root = require('./_root'); root = require('./_root');
@@ -23,7 +23,7 @@ function createCurryWrapper(func, bitmask, arity) {
var length = arguments.length, var length = arguments.length,
args = Array(length), args = Array(length),
index = length, index = length,
placeholder = getPlaceholder(wrapper); placeholder = getHolder(wrapper);
while (index--) { while (index--) {
args[index] = arguments[index]; args[index] = arguments[index];

View File

@@ -3,7 +3,7 @@ var composeArgs = require('./_composeArgs'),
countHolders = require('./_countHolders'), countHolders = require('./_countHolders'),
createCtorWrapper = require('./_createCtorWrapper'), createCtorWrapper = require('./_createCtorWrapper'),
createRecurryWrapper = require('./_createRecurryWrapper'), createRecurryWrapper = require('./_createRecurryWrapper'),
getPlaceholder = require('./_getPlaceholder'), getHolder = require('./_getHolder'),
reorder = require('./_reorder'), reorder = require('./_reorder'),
replaceHolders = require('./_replaceHolders'), replaceHolders = require('./_replaceHolders'),
root = require('./_root'); root = require('./_root');
@@ -46,14 +46,14 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials
function wrapper() { function wrapper() {
var length = arguments.length, var length = arguments.length,
index = length, args = Array(length),
args = Array(length); index = length;
while (index--) { while (index--) {
args[index] = arguments[index]; args[index] = arguments[index];
} }
if (isCurried) { if (isCurried) {
var placeholder = getPlaceholder(wrapper), var placeholder = getHolder(wrapper),
holdersCount = countHolders(args, placeholder); holdersCount = countHolders(args, placeholder);
} }
if (partials) { if (partials) {

View File

@@ -12,7 +12,7 @@ var apply = require('./_apply'),
* *
* @private * @private
* @param {Function} arrayFunc The function to iterate over iteratees. * @param {Function} arrayFunc The function to iterate over iteratees.
* @returns {Function} Returns the new invoker function. * @returns {Function} Returns the new over function.
*/ */
function createOver(arrayFunc) { function createOver(arrayFunc) {
return rest(function(iteratees) { return rest(function(iteratees) {

View File

@@ -2,6 +2,9 @@ var toInteger = require('./toInteger'),
toNumber = require('./toNumber'), toNumber = require('./toNumber'),
toString = require('./toString'); toString = require('./toString');
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMin = Math.min;
/** /**
* Creates a function like `_.round`. * Creates a function like `_.round`.
* *
@@ -13,7 +16,7 @@ function createRound(methodName) {
var func = Math[methodName]; var func = Math[methodName];
return function(number, precision) { return function(number, precision) {
number = toNumber(number); number = toNumber(number);
precision = toInteger(precision); precision = nativeMin(toInteger(precision), 292);
if (precision) { if (precision) {
// Shift with exponential notation to avoid floating-point issues. // Shift with exponential notation to avoid floating-point issues.
// See [MDN](https://mdn.io/round#Examples) for more details. // See [MDN](https://mdn.io/round#Examples) for more details.

30
_createToPairs.js Normal file
View File

@@ -0,0 +1,30 @@
var baseToPairs = require('./_baseToPairs'),
getTag = require('./_getTag'),
mapToArray = require('./_mapToArray'),
setToPairs = require('./_setToPairs');
/** `Object#toString` result references. */
var mapTag = '[object Map]',
setTag = '[object Set]';
/**
* Creates a `_.toPairs` or `_.toPairsIn` function.
*
* @private
* @param {Function} keysFunc The function to get the keys of a given object.
* @returns {Function} Returns the new pairs function.
*/
function createToPairs(keysFunc) {
return function(object) {
var tag = getTag(object);
if (tag == mapTag) {
return mapToArray(object);
}
if (tag == setTag) {
return setToPairs(object);
}
return baseToPairs(object, keysFunc(object));
};
}
module.exports = createToPairs;

View File

@@ -39,6 +39,7 @@ var nativeMax = Math.max;
* 64 - `_.partialRight` * 64 - `_.partialRight`
* 128 - `_.rearg` * 128 - `_.rearg`
* 256 - `_.ary` * 256 - `_.ary`
* 512 - `_.flip`
* @param {*} [thisArg] The `this` binding of `func`. * @param {*} [thisArg] The `this` binding of `func`.
* @param {Array} [partials] The arguments to be partially applied. * @param {Array} [partials] The arguments to be partially applied.
* @param {Array} [holders] The `partials` placeholder indexes. * @param {Array} [holders] The `partials` placeholder indexes.

View File

@@ -1,4 +1,5 @@
var arraySome = require('./_arraySome'); var SetCache = require('./_SetCache'),
arraySome = require('./_arraySome');
/** Used to compose bitmasks for comparison styles. */ /** Used to compose bitmasks for comparison styles. */
var UNORDERED_COMPARE_FLAG = 1, var UNORDERED_COMPARE_FLAG = 1,
@@ -19,9 +20,7 @@ var UNORDERED_COMPARE_FLAG = 1,
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
*/ */
function equalArrays(array, other, equalFunc, customizer, bitmask, stack) { function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
var index = -1, var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
isPartial = bitmask & PARTIAL_COMPARE_FLAG,
isUnordered = bitmask & UNORDERED_COMPARE_FLAG,
arrLength = array.length, arrLength = array.length,
othLength = other.length; othLength = other.length;
@@ -33,7 +32,10 @@ function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
if (stacked) { if (stacked) {
return stacked == other; return stacked == other;
} }
var result = true; var index = -1,
result = true,
seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined;
stack.set(array, other); stack.set(array, other);
// Ignore non-index properties. // Ignore non-index properties.
@@ -54,10 +56,12 @@ function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
break; break;
} }
// Recursively compare arrays (susceptible to call stack limits). // Recursively compare arrays (susceptible to call stack limits).
if (isUnordered) { if (seen) {
if (!arraySome(other, function(othValue) { if (!arraySome(other, function(othValue, othIndex) {
return arrValue === othValue || if (!seen.has(othIndex) &&
equalFunc(arrValue, othValue, customizer, bitmask, stack); (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
return seen.add(othIndex);
}
})) { })) {
result = false; result = false;
break; break;

View File

@@ -5,9 +5,9 @@
* @param {Function} func The function to inspect. * @param {Function} func The function to inspect.
* @returns {*} Returns the placeholder value. * @returns {*} Returns the placeholder value.
*/ */
function getPlaceholder(func) { function getHolder(func) {
var object = func; var object = func;
return object.placeholder; return object.placeholder;
} }
module.exports = getPlaceholder; module.exports = getHolder;

18
_getMapData.js Normal file
View File

@@ -0,0 +1,18 @@
var isKeyable = require('./_isKeyable');
/**
* Gets the data for `map`.
*
* @private
* @param {Object} map The map to query.
* @param {string} key The reference key.
* @returns {*} Returns the map data.
*/
function getMapData(map, key) {
var data = map.__data__;
return isKeyable(key)
? data[typeof key == 'string' ? 'string' : 'hash']
: data.map;
}
module.exports = getMapData;

View File

@@ -1,5 +1,5 @@
var isStrictComparable = require('./_isStrictComparable'), var isStrictComparable = require('./_isStrictComparable'),
toPairs = require('./toPairs'); keys = require('./keys');
/** /**
* Gets the property names, values, and compare flags of `object`. * Gets the property names, values, and compare flags of `object`.
@@ -9,11 +9,14 @@ var isStrictComparable = require('./_isStrictComparable'),
* @returns {Array} Returns the match data of `object`. * @returns {Array} Returns the match data of `object`.
*/ */
function getMatchData(object) { function getMatchData(object) {
var result = toPairs(object), var result = keys(object),
length = result.length; length = result.length;
while (length--) { while (length--) {
result[length][2] = isStrictComparable(result[length][1]); var key = result[length],
value = object[key];
result[length] = [key, value, isStrictComparable(value)];
} }
return result; return result;
} }

View File

@@ -1,4 +1,5 @@
var isNative = require('./isNative'); var baseIsNative = require('./_baseIsNative'),
getValue = require('./_getValue');
/** /**
* Gets the native function at `key` of `object`. * Gets the native function at `key` of `object`.
@@ -9,8 +10,8 @@ var isNative = require('./isNative');
* @returns {*} Returns the function if it's native, else `undefined`. * @returns {*} Returns the function if it's native, else `undefined`.
*/ */
function getNative(object, key) { function getNative(object, key) {
var value = object[key]; var value = getValue(object, key);
return isNative(value) ? value : undefined; return baseIsNative(value) ? value : undefined;
} }
module.exports = getNative; module.exports = getNative;

View File

@@ -1,3 +1,5 @@
var stubArray = require('./stubArray');
/** Built-in value references. */ /** Built-in value references. */
var getOwnPropertySymbols = Object.getOwnPropertySymbols; var getOwnPropertySymbols = Object.getOwnPropertySymbols;
@@ -16,9 +18,7 @@ function getSymbols(object) {
// Fallback for IE < 11. // Fallback for IE < 11.
if (!getOwnPropertySymbols) { if (!getOwnPropertySymbols) {
getSymbols = function() { getSymbols = stubArray;
return [];
};
} }
module.exports = getSymbols; module.exports = getSymbols;

13
_getValue.js Normal file
View File

@@ -0,0 +1,13 @@
/**
* Gets the value at `key` of `object`.
*
* @private
* @param {Object} [object] The object to query.
* @param {string} key The key of the property to get.
* @returns {*} Returns the property value.
*/
function getValue(object, key) {
return object == null ? undefined : object[key];
}
module.exports = getValue;

14
_hashClear.js Normal file
View File

@@ -0,0 +1,14 @@
var nativeCreate = require('./_nativeCreate');
/**
* Removes all key-value entries from the hash.
*
* @private
* @name clear
* @memberOf Hash
*/
function hashClear() {
this.__data__ = nativeCreate ? nativeCreate(null) : {};
}
module.exports = hashClear;

View File

@@ -1,15 +1,15 @@
var hashHas = require('./_hashHas');
/** /**
* Removes `key` and its value from the hash. * Removes `key` and its value from the hash.
* *
* @private * @private
* @name delete
* @memberOf Hash
* @param {Object} hash The hash to modify. * @param {Object} hash The hash to modify.
* @param {string} key The key of the value to remove. * @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/ */
function hashDelete(hash, key) { function hashDelete(key) {
return hashHas(hash, key) && delete hash[key]; return this.has(key) && delete this.__data__[key];
} }
module.exports = hashDelete; module.exports = hashDelete;

View File

@@ -13,16 +13,18 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* Gets the hash value for `key`. * Gets the hash value for `key`.
* *
* @private * @private
* @param {Object} hash The hash to query. * @name get
* @memberOf Hash
* @param {string} key The key of the value to get. * @param {string} key The key of the value to get.
* @returns {*} Returns the entry value. * @returns {*} Returns the entry value.
*/ */
function hashGet(hash, key) { function hashGet(key) {
var data = this.__data__;
if (nativeCreate) { if (nativeCreate) {
var result = hash[key]; var result = data[key];
return result === HASH_UNDEFINED ? undefined : result; return result === HASH_UNDEFINED ? undefined : result;
} }
return hasOwnProperty.call(hash, key) ? hash[key] : undefined; return hasOwnProperty.call(data, key) ? data[key] : undefined;
} }
module.exports = hashGet; module.exports = hashGet;

View File

@@ -10,12 +10,14 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* Checks if a hash value for `key` exists. * Checks if a hash value for `key` exists.
* *
* @private * @private
* @param {Object} hash The hash to query. * @name has
* @memberOf Hash
* @param {string} key The key of the entry to check. * @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/ */
function hashHas(hash, key) { function hashHas(key) {
return nativeCreate ? hash[key] !== undefined : hasOwnProperty.call(hash, key); var data = this.__data__;
return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
} }
module.exports = hashHas; module.exports = hashHas;

View File

@@ -7,12 +7,16 @@ var HASH_UNDEFINED = '__lodash_hash_undefined__';
* Sets the hash `key` to `value`. * Sets the hash `key` to `value`.
* *
* @private * @private
* @param {Object} hash The hash to modify. * @name set
* @memberOf Hash
* @param {string} key The key of the value to set. * @param {string} key The key of the value to set.
* @param {*} value The value to set. * @param {*} value The value to set.
* @returns {Object} Returns the hash instance.
*/ */
function hashSet(hash, key, value) { function hashSet(key, value) {
hash[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; var data = this.__data__;
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
return this;
} }
module.exports = hashSet; module.exports = hashSet;

View File

@@ -9,7 +9,7 @@
*/ */
function indexOfNaN(array, fromIndex, fromRight) { function indexOfNaN(array, fromIndex, fromRight) {
var length = array.length, var length = array.length,
index = fromIndex + (fromRight ? 0 : -1); index = fromIndex + (fromRight ? 1 : -1);
while ((fromRight ? index-- : ++index < length)) { while ((fromRight ? index-- : ++index < length)) {
var other = array[index]; var other = array[index];

View File

@@ -1,6 +1,5 @@
var isArguments = require('./isArguments'), var isArguments = require('./isArguments'),
isArray = require('./isArray'), isArray = require('./isArray');
isArrayLikeObject = require('./isArrayLikeObject');
/** /**
* Checks if `value` is a flattenable `arguments` object or array. * Checks if `value` is a flattenable `arguments` object or array.
@@ -10,7 +9,7 @@ var isArguments = require('./isArguments'),
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
*/ */
function isFlattenable(value) { function isFlattenable(value) {
return isArrayLikeObject(value) && (isArray(value) || isArguments(value)); return isArray(value) || isArguments(value);
} }
module.exports = isFlattenable; module.exports = isFlattenable;

14
_isMaskable.js Normal file
View File

@@ -0,0 +1,14 @@
var coreJsData = require('./_coreJsData'),
isFunction = require('./isFunction'),
stubFalse = require('./stubFalse');
/**
* Checks if `func` is capable of being masked.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `func` is maskable, else `false`.
*/
var isMaskable = !coreJsData ? stubFalse : isFunction;
module.exports = isMaskable;

20
_isMasked.js Normal file
View File

@@ -0,0 +1,20 @@
var coreJsData = require('./_coreJsData');
/** Used to detect methods masquerading as native. */
var maskSrcKey = (function() {
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
return uid ? ('Symbol(src)_1.' + uid) : '';
}());
/**
* Checks if `func` has its source masked.
*
* @private
* @param {Function} func The function to check.
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
*/
function isMasked(func) {
return !!maskSrcKey && (maskSrcKey in func);
}
module.exports = isMasked;

12
_listCacheClear.js Normal file
View File

@@ -0,0 +1,12 @@
/**
* Removes all key-value entries from the list cache.
*
* @private
* @name clear
* @memberOf ListCache
*/
function listCacheClear() {
this.__data__ = [];
}
module.exports = listCacheClear;

View File

@@ -7,25 +7,28 @@ var arrayProto = Array.prototype;
var splice = arrayProto.splice; var splice = arrayProto.splice;
/** /**
* Removes `key` and its value from the associative array. * Removes `key` and its value from the list cache.
* *
* @private * @private
* @param {Array} array The array to modify. * @name delete
* @memberOf ListCache
* @param {string} key The key of the value to remove. * @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/ */
function assocDelete(array, key) { function listCacheDelete(key) {
var index = assocIndexOf(array, key); var data = this.__data__,
index = assocIndexOf(data, key);
if (index < 0) { if (index < 0) {
return false; return false;
} }
var lastIndex = array.length - 1; var lastIndex = data.length - 1;
if (index == lastIndex) { if (index == lastIndex) {
array.pop(); data.pop();
} else { } else {
splice.call(array, index, 1); splice.call(data, index, 1);
} }
return true; return true;
} }
module.exports = assocDelete; module.exports = listCacheDelete;

19
_listCacheGet.js Normal file
View File

@@ -0,0 +1,19 @@
var assocIndexOf = require('./_assocIndexOf');
/**
* Gets the list cache value for `key`.
*
* @private
* @name get
* @memberOf ListCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function listCacheGet(key) {
var data = this.__data__,
index = assocIndexOf(data, key);
return index < 0 ? undefined : data[index][1];
}
module.exports = listCacheGet;

View File

@@ -1,15 +1,16 @@
var assocIndexOf = require('./_assocIndexOf'); var assocIndexOf = require('./_assocIndexOf');
/** /**
* Checks if an associative array value for `key` exists. * Checks if a list cache value for `key` exists.
* *
* @private * @private
* @param {Array} array The array to query. * @name has
* @memberOf ListCache
* @param {string} key The key of the entry to check. * @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/ */
function assocHas(array, key) { function listCacheHas(key) {
return assocIndexOf(array, key) > -1; return assocIndexOf(this.__data__, key) > -1;
} }
module.exports = assocHas; module.exports = listCacheHas;

25
_listCacheSet.js Normal file
View File

@@ -0,0 +1,25 @@
var assocIndexOf = require('./_assocIndexOf');
/**
* Sets the list cache `key` to `value`.
*
* @private
* @name set
* @memberOf ListCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the list cache instance.
*/
function listCacheSet(key, value) {
var data = this.__data__,
index = assocIndexOf(data, key);
if (index < 0) {
data.push([key, value]);
} else {
data[index][1] = value;
}
return this;
}
module.exports = listCacheSet;

View File

@@ -1,4 +1,5 @@
var Hash = require('./_Hash'), var Hash = require('./_Hash'),
ListCache = require('./_ListCache'),
Map = require('./_Map'); Map = require('./_Map');
/** /**
@@ -8,12 +9,12 @@ var Hash = require('./_Hash'),
* @name clear * @name clear
* @memberOf MapCache * @memberOf MapCache
*/ */
function mapClear() { function mapCacheClear() {
this.__data__ = { this.__data__ = {
'hash': new Hash, 'hash': new Hash,
'map': Map ? new Map : [], 'map': new (Map || ListCache),
'string': new Hash 'string': new Hash
}; };
} }
module.exports = mapClear; module.exports = mapCacheClear;

16
_mapCacheDelete.js Normal file
View File

@@ -0,0 +1,16 @@
var getMapData = require('./_getMapData');
/**
* Removes `key` and its value from the map.
*
* @private
* @name delete
* @memberOf MapCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function mapCacheDelete(key) {
return getMapData(this, key)['delete'](key);
}
module.exports = mapCacheDelete;

16
_mapCacheGet.js Normal file
View File

@@ -0,0 +1,16 @@
var getMapData = require('./_getMapData');
/**
* Gets the map value for `key`.
*
* @private
* @name get
* @memberOf MapCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function mapCacheGet(key) {
return getMapData(this, key).get(key);
}
module.exports = mapCacheGet;

16
_mapCacheHas.js Normal file
View File

@@ -0,0 +1,16 @@
var getMapData = require('./_getMapData');
/**
* Checks if a map value for `key` exists.
*
* @private
* @name has
* @memberOf MapCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function mapCacheHas(key) {
return getMapData(this, key).has(key);
}
module.exports = mapCacheHas;

18
_mapCacheSet.js Normal file
View File

@@ -0,0 +1,18 @@
var getMapData = require('./_getMapData');
/**
* Sets the map `key` to `value`.
*
* @private
* @name set
* @memberOf MapCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the map cache instance.
*/
function mapCacheSet(key, value) {
getMapData(this, key).set(key, value);
return this;
}
module.exports = mapCacheSet;

View File

@@ -1,23 +0,0 @@
var Map = require('./_Map'),
assocDelete = require('./_assocDelete'),
hashDelete = require('./_hashDelete'),
isKeyable = require('./_isKeyable');
/**
* Removes `key` and its value from the map.
*
* @private
* @name delete
* @memberOf MapCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function mapDelete(key) {
var data = this.__data__;
if (isKeyable(key)) {
return hashDelete(typeof key == 'string' ? data.string : data.hash, key);
}
return Map ? data.map['delete'](key) : assocDelete(data.map, key);
}
module.exports = mapDelete;

View File

@@ -1,23 +0,0 @@
var Map = require('./_Map'),
assocGet = require('./_assocGet'),
hashGet = require('./_hashGet'),
isKeyable = require('./_isKeyable');
/**
* Gets the map value for `key`.
*
* @private
* @name get
* @memberOf MapCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function mapGet(key) {
var data = this.__data__;
if (isKeyable(key)) {
return hashGet(typeof key == 'string' ? data.string : data.hash, key);
}
return Map ? data.map.get(key) : assocGet(data.map, key);
}
module.exports = mapGet;

View File

@@ -1,23 +0,0 @@
var Map = require('./_Map'),
assocHas = require('./_assocHas'),
hashHas = require('./_hashHas'),
isKeyable = require('./_isKeyable');
/**
* Checks if a map value for `key` exists.
*
* @private
* @name has
* @memberOf MapCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function mapHas(key) {
var data = this.__data__;
if (isKeyable(key)) {
return hashHas(typeof key == 'string' ? data.string : data.hash, key);
}
return Map ? data.map.has(key) : assocHas(data.map, key);
}
module.exports = mapHas;

View File

@@ -1,28 +0,0 @@
var Map = require('./_Map'),
assocSet = require('./_assocSet'),
hashSet = require('./_hashSet'),
isKeyable = require('./_isKeyable');
/**
* Sets the map `key` to `value`.
*
* @private
* @name set
* @memberOf MapCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the map cache instance.
*/
function mapSet(key, value) {
var data = this.__data__;
if (isKeyable(key)) {
hashSet(typeof key == 'string' ? data.string : data.hash, key, value);
} else if (Map) {
data.map.set(key, value);
} else {
assocSet(data.map, key, value);
}
return this;
}
module.exports = mapSet;

View File

@@ -1,9 +1,9 @@
/** /**
* Converts `map` to an array. * Converts `map` to its key-value pairs.
* *
* @private * @private
* @param {Object} map The map to convert. * @param {Object} map The map to convert.
* @returns {Array} Returns the converted array. * @returns {Array} Returns the key-value pairs.
*/ */
function mapToArray(map) { function mapToArray(map) {
var index = -1, var index = -1,

View File

@@ -5,7 +5,7 @@
* @private * @private
* @param {string} key The key of the property to get. * @param {string} key The key of the property to get.
* @param {*} srcValue The value to match. * @param {*} srcValue The value to match.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new spec function.
*/ */
function matchesStrictComparable(key, srcValue) { function matchesStrictComparable(key, srcValue) {
return function(object) { return function(object) {

View File

@@ -1,41 +1,15 @@
var checkGlobal = require('./_checkGlobal'); var checkGlobal = require('./_checkGlobal');
/** Used to determine if values are of the language type `Object`. */
var objectTypes = {
'function': true,
'object': true
};
/** Detect free variable `exports`. */
var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
? exports
: undefined;
/** Detect free variable `module`. */
var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
? module
: undefined;
/** Detect free variable `global` from Node.js. */ /** Detect free variable `global` from Node.js. */
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global); var freeGlobal = checkGlobal(typeof global == 'object' && global);
/** Detect free variable `self`. */ /** Detect free variable `self`. */
var freeSelf = checkGlobal(objectTypes[typeof self] && self); var freeSelf = checkGlobal(typeof self == 'object' && self);
/** Detect free variable `window`. */
var freeWindow = checkGlobal(objectTypes[typeof window] && window);
/** Detect `this` as the global object. */ /** Detect `this` as the global object. */
var thisGlobal = checkGlobal(objectTypes[typeof this] && this); var thisGlobal = checkGlobal(typeof this == 'object' && this);
/** /** Used as a reference to the global object. */
* Used as a reference to the global object. var root = freeGlobal || freeSelf || thisGlobal || Function('return this')();
*
* The `this` value is used if it's the global object to avoid Greasemonkey's
* restricted `window` object, otherwise the `window` object is used.
*/
var root = freeGlobal ||
((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) ||
freeSelf || thisGlobal || Function('return this')();
module.exports = root; module.exports = root;

19
_setCacheAdd.js Normal file
View File

@@ -0,0 +1,19 @@
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
/**
* Adds `value` to the array cache.
*
* @private
* @name add
* @memberOf SetCache
* @alias push
* @param {*} value The value to cache.
* @returns {Object} Returns the cache instance.
*/
function setCacheAdd(value) {
this.__data__.set(value, HASH_UNDEFINED);
return this;
}
module.exports = setCacheAdd;

14
_setCacheHas.js Normal file
View File

@@ -0,0 +1,14 @@
/**
* Checks if `value` is in the array cache.
*
* @private
* @name has
* @memberOf SetCache
* @param {*} value The value to search for.
* @returns {number} Returns `true` if `value` is found, else `false`.
*/
function setCacheHas(value) {
return this.__data__.has(value);
}
module.exports = setCacheHas;

View File

@@ -1,9 +1,9 @@
/** /**
* Converts `set` to an array. * Converts `set` to an array of its values.
* *
* @private * @private
* @param {Object} set The set to convert. * @param {Object} set The set to convert.
* @returns {Array} Returns the converted array. * @returns {Array} Returns the values.
*/ */
function setToArray(set) { function setToArray(set) {
var index = -1, var index = -1,

18
_setToPairs.js Normal file
View File

@@ -0,0 +1,18 @@
/**
* Converts `set` to its value-value pairs.
*
* @private
* @param {Object} set The set to convert.
* @returns {Array} Returns the value-value pairs.
*/
function setToPairs(set) {
var index = -1,
result = Array(set.size);
set.forEach(function(value) {
result[++index] = [value, value];
});
return result;
}
module.exports = setToPairs;

View File

@@ -1,3 +1,5 @@
var ListCache = require('./_ListCache');
/** /**
* Removes all key-value entries from the stack. * Removes all key-value entries from the stack.
* *
@@ -6,7 +8,7 @@
* @memberOf Stack * @memberOf Stack
*/ */
function stackClear() { function stackClear() {
this.__data__ = { 'array': [], 'map': null }; this.__data__ = new ListCache;
} }
module.exports = stackClear; module.exports = stackClear;

View File

@@ -1,5 +1,3 @@
var assocDelete = require('./_assocDelete');
/** /**
* Removes `key` and its value from the stack. * Removes `key` and its value from the stack.
* *
@@ -10,10 +8,7 @@ var assocDelete = require('./_assocDelete');
* @returns {boolean} Returns `true` if the entry was removed, else `false`. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/ */
function stackDelete(key) { function stackDelete(key) {
var data = this.__data__, return this.__data__['delete'](key);
array = data.array;
return array ? assocDelete(array, key) : data.map['delete'](key);
} }
module.exports = stackDelete; module.exports = stackDelete;

View File

@@ -1,5 +1,3 @@
var assocGet = require('./_assocGet');
/** /**
* Gets the stack value for `key`. * Gets the stack value for `key`.
* *
@@ -10,10 +8,7 @@ var assocGet = require('./_assocGet');
* @returns {*} Returns the entry value. * @returns {*} Returns the entry value.
*/ */
function stackGet(key) { function stackGet(key) {
var data = this.__data__, return this.__data__.get(key);
array = data.array;
return array ? assocGet(array, key) : data.map.get(key);
} }
module.exports = stackGet; module.exports = stackGet;

View File

@@ -1,5 +1,3 @@
var assocHas = require('./_assocHas');
/** /**
* Checks if a stack value for `key` exists. * Checks if a stack value for `key` exists.
* *
@@ -10,10 +8,7 @@ var assocHas = require('./_assocHas');
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/ */
function stackHas(key) { function stackHas(key) {
var data = this.__data__, return this.__data__.has(key);
array = data.array;
return array ? assocHas(array, key) : data.map.has(key);
} }
module.exports = stackHas; module.exports = stackHas;

View File

@@ -1,5 +1,5 @@
var MapCache = require('./_MapCache'), var ListCache = require('./_ListCache'),
assocSet = require('./_assocSet'); MapCache = require('./_MapCache');
/** Used as the size to enable large array optimizations. */ /** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200; var LARGE_ARRAY_SIZE = 200;
@@ -15,21 +15,11 @@ var LARGE_ARRAY_SIZE = 200;
* @returns {Object} Returns the stack cache instance. * @returns {Object} Returns the stack cache instance.
*/ */
function stackSet(key, value) { function stackSet(key, value) {
var data = this.__data__, var cache = this.__data__;
array = data.array; if (cache instanceof ListCache && cache.__data__.length == LARGE_ARRAY_SIZE) {
cache = this.__data__ = new MapCache(cache.__data__);
if (array) {
if (array.length < (LARGE_ARRAY_SIZE - 1)) {
assocSet(array, key, value);
} else {
data.array = null;
data.map = new MapCache(array);
}
}
var map = data.map;
if (map) {
map.set(key, value);
} }
cache.set(key, value);
return this; return this;
} }

View File

@@ -2,7 +2,7 @@ var memoize = require('./memoize'),
toString = require('./toString'); toString = require('./toString');
/** Used to match property names within property paths. */ /** Used to match property names within property paths. */
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]/g; var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(\.|\[\])(?:\4|$))/g;
/** Used to match backslashes in property paths. */ /** Used to match backslashes in property paths. */
var reEscapeChar = /\\(\\)?/g; var reEscapeChar = /\\(\\)?/g;

View File

@@ -12,6 +12,7 @@ module.exports = {
'fill': require('./fill'), 'fill': require('./fill'),
'findIndex': require('./findIndex'), 'findIndex': require('./findIndex'),
'findLastIndex': require('./findLastIndex'), 'findLastIndex': require('./findLastIndex'),
'first': require('./first'),
'flatten': require('./flatten'), 'flatten': require('./flatten'),
'flattenDeep': require('./flattenDeep'), 'flattenDeep': require('./flattenDeep'),
'flattenDepth': require('./flattenDepth'), 'flattenDepth': require('./flattenDepth'),

2
ary.js
View File

@@ -14,7 +14,7 @@ var ARY_FLAG = 128;
* @param {Function} func The function to cap arguments for. * @param {Function} func The function to cap arguments for.
* @param {number} [n=func.length] The arity cap. * @param {number} [n=func.length] The arity cap.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new capped function.
* @example * @example
* *
* _.map(['6', '8', '10'], _.ary(parseInt, 1)); * _.map(['6', '8', '10'], _.ary(parseInt, 1));

5
at.js
View File

@@ -11,16 +11,13 @@ var baseAt = require('./_baseAt'),
* @category Object * @category Object
* @param {Object} object The object to iterate over. * @param {Object} object The object to iterate over.
* @param {...(string|string[])} [paths] The property paths of elements to pick. * @param {...(string|string[])} [paths] The property paths of elements to pick.
* @returns {Array} Returns the new array of picked elements. * @returns {Array} Returns the picked values.
* @example * @example
* *
* var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
* *
* _.at(object, ['a[0].b.c', 'a[1]']); * _.at(object, ['a[0].b.c', 'a[1]']);
* // => [3, 4] * // => [3, 4]
*
* _.at(['a', 'b', 'c'], 0, 2);
* // => ['a', 'c']
*/ */
var at = rest(function(object, paths) { var at = rest(function(object, paths) {
return baseAt(object, baseFlatten(paths, 1)); return baseAt(object, baseFlatten(paths, 1));

View File

@@ -1,5 +1,5 @@
var createWrapper = require('./_createWrapper'), var createWrapper = require('./_createWrapper'),
getPlaceholder = require('./_getPlaceholder'), getHolder = require('./_getHolder'),
replaceHolders = require('./_replaceHolders'), replaceHolders = require('./_replaceHolders'),
rest = require('./rest'); rest = require('./rest');
@@ -14,7 +14,7 @@ var BIND_FLAG = 1,
* The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
* may be used as a placeholder for partially applied arguments. * may be used as a placeholder for partially applied arguments.
* *
* **Note:** Unlike native `Function#bind` this method doesn't set the "length" * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
* property of bound functions. * property of bound functions.
* *
* @static * @static
@@ -45,7 +45,7 @@ var BIND_FLAG = 1,
var bind = rest(function(func, thisArg, partials) { var bind = rest(function(func, thisArg, partials) {
var bitmask = BIND_FLAG; var bitmask = BIND_FLAG;
if (partials.length) { if (partials.length) {
var holders = replaceHolders(partials, getPlaceholder(bind)); var holders = replaceHolders(partials, getHolder(bind));
bitmask |= PARTIAL_FLAG; bitmask |= PARTIAL_FLAG;
} }
return createWrapper(func, bitmask, thisArg, partials, holders); return createWrapper(func, bitmask, thisArg, partials, holders);

View File

@@ -26,7 +26,7 @@ var arrayEach = require('./_arrayEach'),
* } * }
* }; * };
* *
* _.bindAll(view, 'onClick'); * _.bindAll(view, ['onClick']);
* jQuery(element).on('click', view.onClick); * jQuery(element).on('click', view.onClick);
* // => Logs 'clicked docs' when clicked. * // => Logs 'clicked docs' when clicked.
*/ */

View File

@@ -1,5 +1,5 @@
var createWrapper = require('./_createWrapper'), var createWrapper = require('./_createWrapper'),
getPlaceholder = require('./_getPlaceholder'), getHolder = require('./_getHolder'),
replaceHolders = require('./_replaceHolders'), replaceHolders = require('./_replaceHolders'),
rest = require('./rest'); rest = require('./rest');
@@ -56,7 +56,7 @@ var BIND_FLAG = 1,
var bindKey = rest(function(object, key, partials) { var bindKey = rest(function(object, key, partials) {
var bitmask = BIND_FLAG | BIND_KEY_FLAG; var bitmask = BIND_FLAG | BIND_KEY_FLAG;
if (partials.length) { if (partials.length) {
var holders = replaceHolders(partials, getPlaceholder(bindKey)); var holders = replaceHolders(partials, getHolder(bindKey));
bitmask |= PARTIAL_FLAG; bitmask |= PARTIAL_FLAG;
} }
return createWrapper(key, bitmask, object, partials, holders); return createWrapper(key, bitmask, object, partials, holders);

View File

@@ -18,7 +18,7 @@ var nativeCeil = Math.ceil,
* @param {Array} array The array to process. * @param {Array} array The array to process.
* @param {number} [size=1] The length of each chunk * @param {number} [size=1] The length of each chunk
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {Array} Returns the new array containing chunks. * @returns {Array} Returns the new array of chunks.
* @example * @example
* *
* _.chunk(['a', 'b', 'c', 'd'], 2); * _.chunk(['a', 'b', 'c', 'd'], 2);

Some files were not shown because too many files have changed in this diff Show More