mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
Compare commits
5 Commits
4.15.0-amd
...
4.16.4-amd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52a75b18e4 | ||
|
|
0961d6edde | ||
|
|
2f8450b523 | ||
|
|
81b88ae10c | ||
|
|
0b9ddff408 |
10
README.md
10
README.md
@@ -1,9 +1,9 @@
|
||||
# lodash-amd v4.15.0
|
||||
# lodash-amd v4.16.4
|
||||
|
||||
The [Lodash](https://lodash.com/) library exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules.
|
||||
|
||||
Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli):
|
||||
```bash
|
||||
```shell
|
||||
$ lodash exports=amd -o ./
|
||||
$ lodash exports=amd -d -o ./main.js
|
||||
```
|
||||
@@ -11,8 +11,8 @@ $ lodash exports=amd -d -o ./main.js
|
||||
## Installation
|
||||
|
||||
Using npm:
|
||||
```bash
|
||||
$ {sudo -H} npm i -g npm
|
||||
```shell
|
||||
$ npm i -g npm
|
||||
$ npm i --save lodash-amd
|
||||
```
|
||||
|
||||
@@ -27,4 +27,4 @@ require({
|
||||
});
|
||||
```
|
||||
|
||||
See the [package source](https://github.com/lodash/lodash/tree/4.15.0-amd) for more details.
|
||||
See the [package source](https://github.com/lodash/lodash/tree/4.16.4-amd) for more details.
|
||||
|
||||
@@ -8,7 +8,8 @@ define(['./_ListCache', './_stackClear', './_stackDelete', './_stackGet', './_st
|
||||
* @param {Array} [entries] The key-value pairs to cache.
|
||||
*/
|
||||
function Stack(entries) {
|
||||
this.__data__ = new ListCache(entries);
|
||||
var data = this.__data__ = new ListCache(entries);
|
||||
this.size = data.size;
|
||||
}
|
||||
|
||||
// Add methods to `Stack`.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_baseTimes', './isArguments', './isArray', './_isIndex'], function(baseTimes, isArguments, isArray, isIndex) {
|
||||
define(['./_baseTimes', './isArguments', './isArray', './isBuffer', './_isIndex', './isTypedArray'], function(baseTimes, isArguments, isArray, isBuffer, isIndex, isTypedArray) {
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
@@ -15,18 +15,26 @@ define(['./_baseTimes', './isArguments', './isArray', './_isIndex'], function(ba
|
||||
* @returns {Array} Returns the array of property names.
|
||||
*/
|
||||
function arrayLikeKeys(value, inherited) {
|
||||
// Safari 8.1 makes `arguments.callee` enumerable in strict mode.
|
||||
// Safari 9 makes `arguments.length` enumerable in strict mode.
|
||||
var result = (isArray(value) || isArguments(value))
|
||||
? baseTimes(value.length, String)
|
||||
: [];
|
||||
|
||||
var length = result.length,
|
||||
skipIndexes = !!length;
|
||||
var isArr = isArray(value),
|
||||
isArg = !isArr && isArguments(value),
|
||||
isBuff = !isArr && !isArg && isBuffer(value),
|
||||
isType = !isArr && !isArg && !isBuff && isTypedArray(value),
|
||||
skipIndexes = isArr || isArg || isBuff || isType,
|
||||
result = skipIndexes ? baseTimes(value.length, String) : [],
|
||||
length = result.length;
|
||||
|
||||
for (var key in value) {
|
||||
if ((inherited || hasOwnProperty.call(value, key)) &&
|
||||
!(skipIndexes && (key == 'length' || isIndex(key, length)))) {
|
||||
!(skipIndexes && (
|
||||
// Safari 9 has enumerable `arguments.length` in strict mode.
|
||||
key == 'length' ||
|
||||
// Node.js 0.10 has enumerable non-index properties on buffers.
|
||||
(isBuff && (key == 'offset' || key == 'parent')) ||
|
||||
// PhantomJS 2 has enumerable non-index properties on typed arrays.
|
||||
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
|
||||
// Skip index properties.
|
||||
isIndex(key, length)
|
||||
))) {
|
||||
result.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
19
_arraySample.js
Normal file
19
_arraySample.js
Normal file
@@ -0,0 +1,19 @@
|
||||
define(['./_baseRandom'], function(baseRandom) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/**
|
||||
* A specialized version of `_.sample` for arrays.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to sample.
|
||||
* @returns {*} Returns the random element.
|
||||
*/
|
||||
function arraySample(array) {
|
||||
var length = array.length;
|
||||
return length ? array[baseRandom(0, length - 1)] : undefined;
|
||||
}
|
||||
|
||||
return arraySample;
|
||||
});
|
||||
16
_arraySampleSize.js
Normal file
16
_arraySampleSize.js
Normal file
@@ -0,0 +1,16 @@
|
||||
define(['./_baseClamp', './_copyArray', './_shuffleSelf'], function(baseClamp, copyArray, shuffleSelf) {
|
||||
|
||||
/**
|
||||
* A specialized version of `_.sampleSize` for arrays.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to sample.
|
||||
* @param {number} n The number of elements to sample.
|
||||
* @returns {Array} Returns the random elements.
|
||||
*/
|
||||
function arraySampleSize(array, n) {
|
||||
return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
|
||||
}
|
||||
|
||||
return arraySampleSize;
|
||||
});
|
||||
15
_arrayShuffle.js
Normal file
15
_arrayShuffle.js
Normal file
@@ -0,0 +1,15 @@
|
||||
define(['./_copyArray', './_shuffleSelf'], function(copyArray, shuffleSelf) {
|
||||
|
||||
/**
|
||||
* A specialized version of `_.shuffle` for arrays.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to shuffle.
|
||||
* @returns {Array} Returns the new shuffled array.
|
||||
*/
|
||||
function arrayShuffle(array) {
|
||||
return shuffleSelf(copyArray(array));
|
||||
}
|
||||
|
||||
return arrayShuffle;
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./eq'], function(eq) {
|
||||
define(['./_baseAssignValue', './eq'], function(baseAssignValue, eq) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -14,8 +14,8 @@ define(['./eq'], function(eq) {
|
||||
*/
|
||||
function assignMergeValue(object, key, value) {
|
||||
if ((value !== undefined && !eq(object[key], value)) ||
|
||||
(typeof key == 'number' && value === undefined && !(key in object))) {
|
||||
object[key] = value;
|
||||
(value === undefined && !(key in object))) {
|
||||
baseAssignValue(object, key, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./eq'], function(eq) {
|
||||
define(['./_baseAssignValue', './eq'], function(baseAssignValue, eq) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -23,7 +23,7 @@ define(['./eq'], function(eq) {
|
||||
var objValue = object[key];
|
||||
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
|
||||
(value === undefined && !(key in object))) {
|
||||
object[key] = value;
|
||||
baseAssignValue(object, key, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
26
_baseAssignValue.js
Normal file
26
_baseAssignValue.js
Normal file
@@ -0,0 +1,26 @@
|
||||
define(['./_defineProperty'], function(defineProperty) {
|
||||
|
||||
/**
|
||||
* The base implementation of `assignValue` and `assignMergeValue` without
|
||||
* value checks.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to modify.
|
||||
* @param {string} key The key of the property to assign.
|
||||
* @param {*} value The value to assign.
|
||||
*/
|
||||
function baseAssignValue(object, key, value) {
|
||||
if (key == '__proto__' && defineProperty) {
|
||||
defineProperty(object, key, {
|
||||
'configurable': true,
|
||||
'enumerable': true,
|
||||
'value': value,
|
||||
'writable': true
|
||||
});
|
||||
} else {
|
||||
object[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return baseAssignValue;
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_cloneBuffer', './_copyArray', './_copySymbols', './_getAllKeys', './_getTag', './_initCloneArray', './_initCloneByTag', './_initCloneObject', './isArray', './isBuffer', './_isHostObject', './isObject', './keys'], function(Stack, arrayEach, assignValue, baseAssign, cloneBuffer, copyArray, copySymbols, getAllKeys, getTag, initCloneArray, initCloneByTag, initCloneObject, isArray, isBuffer, isHostObject, isObject, keys) {
|
||||
define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_cloneBuffer', './_copyArray', './_copySymbols', './_getAllKeys', './_getTag', './_initCloneArray', './_initCloneByTag', './_initCloneObject', './isArray', './isBuffer', './isObject', './keys'], function(Stack, arrayEach, assignValue, baseAssign, cloneBuffer, copyArray, copySymbols, getAllKeys, getTag, initCloneArray, initCloneByTag, initCloneObject, isArray, isBuffer, isObject, keys) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -87,9 +87,6 @@ define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_clone
|
||||
return cloneBuffer(value, isDeep);
|
||||
}
|
||||
if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
|
||||
if (isHostObject(value)) {
|
||||
return object ? value : {};
|
||||
}
|
||||
result = initCloneObject(isFunc ? {} : value);
|
||||
if (!isDeep) {
|
||||
return copySymbols(value, baseAssign(result, value));
|
||||
@@ -109,9 +106,7 @@ define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_clone
|
||||
}
|
||||
stack.set(value, result);
|
||||
|
||||
if (!isArr) {
|
||||
var props = isFull ? getAllKeys(value) : keys(value);
|
||||
}
|
||||
var props = isArr ? undefined : (isFull ? getAllKeys : keys)(value);
|
||||
arrayEach(props || value, function(subValue, key) {
|
||||
if (props) {
|
||||
key = subValue;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
define(['./isObject'], function(isObject) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/** Built-in value references. */
|
||||
var objectCreate = Object.create;
|
||||
|
||||
@@ -8,12 +11,24 @@ define(['./isObject'], function(isObject) {
|
||||
* properties to the created object.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} prototype The object to inherit from.
|
||||
* @param {Object} proto The object to inherit from.
|
||||
* @returns {Object} Returns the new object.
|
||||
*/
|
||||
function baseCreate(proto) {
|
||||
return isObject(proto) ? objectCreate(proto) : {};
|
||||
}
|
||||
var baseCreate = (function() {
|
||||
function object() {}
|
||||
return function(proto) {
|
||||
if (!isObject(proto)) {
|
||||
return {};
|
||||
}
|
||||
if (objectCreate) {
|
||||
return objectCreate(proto);
|
||||
}
|
||||
object.prototype = proto;
|
||||
var result = new object;
|
||||
object.prototype = undefined;
|
||||
return result;
|
||||
};
|
||||
}());
|
||||
|
||||
return baseCreate;
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ define([], function() {
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
/** Error message constants. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_baseFindIndex', './_baseIsNaN'], function(baseFindIndex, baseIsNaN) {
|
||||
define(['./_baseFindIndex', './_baseIsNaN', './_strictIndexOf'], function(baseFindIndex, baseIsNaN, strictIndexOf) {
|
||||
|
||||
/**
|
||||
* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
|
||||
@@ -10,18 +10,9 @@ define(['./_baseFindIndex', './_baseIsNaN'], function(baseFindIndex, baseIsNaN)
|
||||
* @returns {number} Returns the index of the matched value, else `-1`.
|
||||
*/
|
||||
function baseIndexOf(array, value, fromIndex) {
|
||||
if (value !== value) {
|
||||
return baseFindIndex(array, baseIsNaN, fromIndex);
|
||||
}
|
||||
var index = fromIndex - 1,
|
||||
length = array.length;
|
||||
|
||||
while (++index < length) {
|
||||
if (array[index] === value) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return value === value
|
||||
? strictIndexOf(array, value, fromIndex)
|
||||
: baseFindIndex(array, baseIsNaN, fromIndex);
|
||||
}
|
||||
|
||||
return baseIndexOf;
|
||||
|
||||
28
_baseIsArguments.js
Normal file
28
_baseIsArguments.js
Normal file
@@ -0,0 +1,28 @@
|
||||
define(['./isObjectLike'], function(isObjectLike) {
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var argsTag = '[object Arguments]';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/**
|
||||
* Used to resolve the
|
||||
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var objectToString = objectProto.toString;
|
||||
|
||||
/**
|
||||
* The base implementation of `_.isArguments`.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
||||
*/
|
||||
function baseIsArguments(value) {
|
||||
return isObjectLike(value) && objectToString.call(value) == argsTag;
|
||||
}
|
||||
|
||||
return baseIsArguments;
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_Stack', './_equalArrays', './_equalByTag', './_equalObjects', './_getTag', './isArray', './_isHostObject', './isTypedArray'], function(Stack, equalArrays, equalByTag, equalObjects, getTag, isArray, isHostObject, isTypedArray) {
|
||||
define(['./_Stack', './_equalArrays', './_equalByTag', './_equalObjects', './_getTag', './isArray', './isBuffer', './isTypedArray'], function(Stack, equalArrays, equalByTag, equalObjects, getTag, isArray, isBuffer, isTypedArray) {
|
||||
|
||||
/** Used to compose bitmasks for comparison styles. */
|
||||
var PARTIAL_COMPARE_FLAG = 2;
|
||||
@@ -43,10 +43,17 @@ define(['./_Stack', './_equalArrays', './_equalByTag', './_equalObjects', './_ge
|
||||
othTag = getTag(other);
|
||||
othTag = othTag == argsTag ? objectTag : othTag;
|
||||
}
|
||||
var objIsObj = objTag == objectTag && !isHostObject(object),
|
||||
othIsObj = othTag == objectTag && !isHostObject(other),
|
||||
var objIsObj = objTag == objectTag,
|
||||
othIsObj = othTag == objectTag,
|
||||
isSameTag = objTag == othTag;
|
||||
|
||||
if (isSameTag && isBuffer(object)) {
|
||||
if (!isBuffer(other)) {
|
||||
return false;
|
||||
}
|
||||
objIsArr = true;
|
||||
objIsObj = false;
|
||||
}
|
||||
if (isSameTag && !objIsObj) {
|
||||
stack || (stack = new Stack);
|
||||
return (objIsArr || isTypedArray(object))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./isFunction', './_isHostObject', './_isMasked', './isObject', './_toSource'], function(isFunction, isHostObject, isMasked, isObject, toSource) {
|
||||
define(['./isFunction', './_isMasked', './isObject', './_toSource'], function(isFunction, isMasked, isObject, toSource) {
|
||||
|
||||
/**
|
||||
* Used to match `RegExp`
|
||||
@@ -37,7 +37,7 @@ define(['./isFunction', './_isHostObject', './_isMasked', './isObject', './_toSo
|
||||
if (!isObject(value) || isMasked(value)) {
|
||||
return false;
|
||||
}
|
||||
var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
|
||||
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
||||
return pattern.test(toSource(value));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_Stack', './_arrayEach', './_assignMergeValue', './_baseKeysIn', './_baseMergeDeep', './isArray', './isObject', './isTypedArray'], function(Stack, arrayEach, assignMergeValue, baseKeysIn, baseMergeDeep, isArray, isObject, isTypedArray) {
|
||||
define(['./_Stack', './_assignMergeValue', './_baseFor', './_baseMergeDeep', './isObject', './keysIn'], function(Stack, assignMergeValue, baseFor, baseMergeDeep, isObject, keysIn) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -18,14 +18,7 @@ define(['./_Stack', './_arrayEach', './_assignMergeValue', './_baseKeysIn', './_
|
||||
if (object === source) {
|
||||
return;
|
||||
}
|
||||
if (!(isArray(source) || isTypedArray(source))) {
|
||||
var props = baseKeysIn(source);
|
||||
}
|
||||
arrayEach(props || source, function(srcValue, key) {
|
||||
if (props) {
|
||||
key = srcValue;
|
||||
srcValue = source[key];
|
||||
}
|
||||
baseFor(source, function(srcValue, key) {
|
||||
if (isObject(srcValue)) {
|
||||
stack || (stack = new Stack);
|
||||
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
||||
@@ -40,7 +33,7 @@ define(['./_Stack', './_arrayEach', './_assignMergeValue', './_baseKeysIn', './_
|
||||
}
|
||||
assignMergeValue(object, key, newValue);
|
||||
}
|
||||
});
|
||||
}, keysIn);
|
||||
}
|
||||
|
||||
return baseMerge;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_assignMergeValue', './_baseClone', './_copyArray', './isArguments', './isArray', './isArrayLikeObject', './isFunction', './isObject', './isPlainObject', './isTypedArray', './toPlainObject'], function(assignMergeValue, baseClone, copyArray, isArguments, isArray, isArrayLikeObject, isFunction, isObject, isPlainObject, isTypedArray, toPlainObject) {
|
||||
define(['./_assignMergeValue', './_cloneBuffer', './_cloneTypedArray', './_copyArray', './_initCloneObject', './isArguments', './isArray', './isArrayLikeObject', './isBuffer', './isFunction', './isObject', './isPlainObject', './isTypedArray', './toPlainObject'], function(assignMergeValue, cloneBuffer, cloneTypedArray, copyArray, initCloneObject, isArguments, isArray, isArrayLikeObject, isBuffer, isFunction, isObject, isPlainObject, isTypedArray, toPlainObject) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -34,29 +34,37 @@ define(['./_assignMergeValue', './_baseClone', './_copyArray', './isArguments',
|
||||
var isCommon = newValue === undefined;
|
||||
|
||||
if (isCommon) {
|
||||
var isArr = isArray(srcValue),
|
||||
isBuff = !isArr && isBuffer(srcValue),
|
||||
isTyped = !isArr && !isBuff && isTypedArray(srcValue);
|
||||
|
||||
newValue = srcValue;
|
||||
if (isArray(srcValue) || isTypedArray(srcValue)) {
|
||||
if (isArr || isBuff || isTyped) {
|
||||
if (isArray(objValue)) {
|
||||
newValue = objValue;
|
||||
}
|
||||
else if (isArrayLikeObject(objValue)) {
|
||||
newValue = copyArray(objValue);
|
||||
}
|
||||
else {
|
||||
else if (isBuff) {
|
||||
isCommon = false;
|
||||
newValue = baseClone(srcValue, true);
|
||||
newValue = cloneBuffer(srcValue, true);
|
||||
}
|
||||
else if (isTyped) {
|
||||
isCommon = false;
|
||||
newValue = cloneTypedArray(srcValue, true);
|
||||
}
|
||||
else {
|
||||
newValue = [];
|
||||
}
|
||||
}
|
||||
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
||||
newValue = objValue;
|
||||
if (isArguments(objValue)) {
|
||||
newValue = toPlainObject(objValue);
|
||||
}
|
||||
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
||||
isCommon = false;
|
||||
newValue = baseClone(srcValue, true);
|
||||
}
|
||||
else {
|
||||
newValue = objValue;
|
||||
newValue = initCloneObject(srcValue);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define([], function() {
|
||||
define(['./_baseAssignValue'], function(baseAssignValue) {
|
||||
|
||||
/**
|
||||
* The base implementation of `_.pickBy` without support for iteratee shorthands.
|
||||
@@ -19,7 +19,7 @@ define([], function() {
|
||||
value = object[key];
|
||||
|
||||
if (predicate(value, key)) {
|
||||
result[key] = value;
|
||||
baseAssignValue(result, key, value);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
27
_baseRest.js
27
_baseRest.js
@@ -1,10 +1,4 @@
|
||||
define(['./_apply'], function(apply) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
var nativeMax = Math.max;
|
||||
define(['./identity', './_overRest', './_setToString'], function(identity, overRest, setToString) {
|
||||
|
||||
/**
|
||||
* The base implementation of `_.rest` which doesn't validate or coerce arguments.
|
||||
@@ -15,24 +9,7 @@ define(['./_apply'], function(apply) {
|
||||
* @returns {Function} Returns the new function.
|
||||
*/
|
||||
function baseRest(func, start) {
|
||||
start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
|
||||
return function() {
|
||||
var args = arguments,
|
||||
index = -1,
|
||||
length = nativeMax(args.length - start, 0),
|
||||
array = Array(length);
|
||||
|
||||
while (++index < length) {
|
||||
array[index] = args[start + index];
|
||||
}
|
||||
index = -1;
|
||||
var otherArgs = Array(start + 1);
|
||||
while (++index < start) {
|
||||
otherArgs[index] = args[index];
|
||||
}
|
||||
otherArgs[start] = array;
|
||||
return apply(func, this, otherArgs);
|
||||
};
|
||||
return setToString(overRest(func, start, identity), func + '');
|
||||
}
|
||||
|
||||
return baseRest;
|
||||
|
||||
15
_baseSample.js
Normal file
15
_baseSample.js
Normal file
@@ -0,0 +1,15 @@
|
||||
define(['./_arraySample', './values'], function(arraySample, values) {
|
||||
|
||||
/**
|
||||
* The base implementation of `_.sample`.
|
||||
*
|
||||
* @private
|
||||
* @param {Array|Object} collection The collection to sample.
|
||||
* @returns {*} Returns the random element.
|
||||
*/
|
||||
function baseSample(collection) {
|
||||
return arraySample(values(collection));
|
||||
}
|
||||
|
||||
return baseSample;
|
||||
});
|
||||
17
_baseSampleSize.js
Normal file
17
_baseSampleSize.js
Normal file
@@ -0,0 +1,17 @@
|
||||
define(['./_baseClamp', './_shuffleSelf', './values'], function(baseClamp, shuffleSelf, values) {
|
||||
|
||||
/**
|
||||
* The base implementation of `_.sampleSize` without param guards.
|
||||
*
|
||||
* @private
|
||||
* @param {Array|Object} collection The collection to sample.
|
||||
* @param {number} n The number of elements to sample.
|
||||
* @returns {Array} Returns the random elements.
|
||||
*/
|
||||
function baseSampleSize(collection, n) {
|
||||
var array = values(collection);
|
||||
return shuffleSelf(array, baseClamp(n, 0, array.length));
|
||||
}
|
||||
|
||||
return baseSampleSize;
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
define(['./identity', './_metaMap'], function(identity, metaMap) {
|
||||
|
||||
/**
|
||||
* The base implementation of `setData` without support for hot loop detection.
|
||||
* The base implementation of `setData` without support for hot loop shorting.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} func The function to associate metadata with.
|
||||
|
||||
21
_baseSetToString.js
Normal file
21
_baseSetToString.js
Normal file
@@ -0,0 +1,21 @@
|
||||
define(['./constant', './_defineProperty', './identity'], function(constant, defineProperty, identity) {
|
||||
|
||||
/**
|
||||
* The base implementation of `setToString` without support for hot loop shorting.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} func The function to modify.
|
||||
* @param {Function} string The `toString` result.
|
||||
* @returns {Function} Returns `func`.
|
||||
*/
|
||||
var baseSetToString = !defineProperty ? identity : function(func, string) {
|
||||
return defineProperty(func, 'toString', {
|
||||
'configurable': true,
|
||||
'enumerable': false,
|
||||
'value': constant(string),
|
||||
'writable': true
|
||||
});
|
||||
};
|
||||
|
||||
return baseSetToString;
|
||||
});
|
||||
15
_baseShuffle.js
Normal file
15
_baseShuffle.js
Normal file
@@ -0,0 +1,15 @@
|
||||
define(['./_shuffleSelf', './values'], function(shuffleSelf, values) {
|
||||
|
||||
/**
|
||||
* The base implementation of `_.shuffle`.
|
||||
*
|
||||
* @private
|
||||
* @param {Array|Object} collection The collection to shuffle.
|
||||
* @returns {Array} Returns the new shuffled array.
|
||||
*/
|
||||
function baseShuffle(collection) {
|
||||
return shuffleSelf(values(collection));
|
||||
}
|
||||
|
||||
return baseShuffle;
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_Symbol', './isSymbol'], function(Symbol, isSymbol) {
|
||||
define(['./_Symbol', './_arrayMap', './isArray', './isSymbol'], function(Symbol, arrayMap, isArray, isSymbol) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -23,6 +23,10 @@ define(['./_Symbol', './isSymbol'], function(Symbol, isSymbol) {
|
||||
if (typeof value == 'string') {
|
||||
return value;
|
||||
}
|
||||
if (isArray(value)) {
|
||||
// Recursively convert values (susceptible to call stack limits).
|
||||
return arrayMap(value, baseToString) + '';
|
||||
}
|
||||
if (isSymbol(value)) {
|
||||
return symbolToString ? symbolToString.call(value) : '';
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
define([], function() {
|
||||
|
||||
/**
|
||||
* Checks if a cache value for `key` exists.
|
||||
* Checks if a `cache` value for `key` exists.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} cache The cache to query.
|
||||
|
||||
15
_castRest.js
Normal file
15
_castRest.js
Normal file
@@ -0,0 +1,15 @@
|
||||
define(['./_baseRest'], function(baseRest) {
|
||||
|
||||
/**
|
||||
* A `baseRest` alias which can be replaced with `identity` by module
|
||||
* replacement plugins.
|
||||
*
|
||||
* @private
|
||||
* @type {Function}
|
||||
* @param {Function} func The function to apply a rest parameter to.
|
||||
* @returns {Function} Returns the new function.
|
||||
*/
|
||||
var castRest = baseRest;
|
||||
|
||||
return castRest;
|
||||
});
|
||||
@@ -1,4 +1,20 @@
|
||||
define([], function() {
|
||||
define(['./_root'], function(root) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/** Detect free variable `exports`. */
|
||||
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
||||
|
||||
/** Detect free variable `module`. */
|
||||
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
|
||||
|
||||
/** Detect the popular CommonJS extension `module.exports`. */
|
||||
var moduleExports = freeModule && freeModule.exports === freeExports;
|
||||
|
||||
/** Built-in value references. */
|
||||
var Buffer = moduleExports ? root.Buffer : undefined,
|
||||
allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
|
||||
|
||||
/**
|
||||
* Creates a clone of `buffer`.
|
||||
@@ -12,7 +28,9 @@ define([], function() {
|
||||
if (isDeep) {
|
||||
return buffer.slice();
|
||||
}
|
||||
var result = new buffer.constructor(buffer.length);
|
||||
var length = buffer.length,
|
||||
result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
|
||||
|
||||
buffer.copy(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_assignValue'], function(assignValue) {
|
||||
define(['./_assignValue', './_baseAssignValue'], function(assignValue, baseAssignValue) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -14,6 +14,7 @@ define(['./_assignValue'], function(assignValue) {
|
||||
* @returns {Object} Returns `object`.
|
||||
*/
|
||||
function copyObject(source, props, object, customizer) {
|
||||
var isNew = !object;
|
||||
object || (object = {});
|
||||
|
||||
var index = -1,
|
||||
@@ -26,7 +27,14 @@ define(['./_assignValue'], function(assignValue) {
|
||||
? customizer(object[key], source[key], key, object, source)
|
||||
: undefined;
|
||||
|
||||
assignValue(object, key, newValue === undefined ? source[key] : newValue);
|
||||
if (newValue === undefined) {
|
||||
newValue = source[key];
|
||||
}
|
||||
if (isNew) {
|
||||
baseAssignValue(object, key, newValue);
|
||||
} else {
|
||||
assignValue(object, key, newValue);
|
||||
}
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ define([], function() {
|
||||
|
||||
while (length--) {
|
||||
if (array[length] === placeholder) {
|
||||
result++;
|
||||
++result;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_LodashWrapper', './_baseFlatten', './_baseRest', './_getData', './_getFuncName', './isArray', './_isLaziable'], function(LodashWrapper, baseFlatten, baseRest, getData, getFuncName, isArray, isLaziable) {
|
||||
define(['./_LodashWrapper', './_flatRest', './_getData', './_getFuncName', './isArray', './_isLaziable'], function(LodashWrapper, flatRest, getData, getFuncName, isArray, isLaziable) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -6,7 +6,7 @@ define(['./_LodashWrapper', './_baseFlatten', './_baseRest', './_getData', './_g
|
||||
/** Used as the size to enable large array optimizations. */
|
||||
var LARGE_ARRAY_SIZE = 200;
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
/** Error message constants. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/** Used to compose bitmasks for function metadata. */
|
||||
@@ -23,9 +23,7 @@ define(['./_LodashWrapper', './_baseFlatten', './_baseRest', './_getData', './_g
|
||||
* @returns {Function} Returns the new flow function.
|
||||
*/
|
||||
function createFlow(fromRight) {
|
||||
return baseRest(function(funcs) {
|
||||
funcs = baseFlatten(funcs, 1);
|
||||
|
||||
return flatRest(function(funcs) {
|
||||
var length = funcs.length,
|
||||
index = length,
|
||||
prereq = LodashWrapper.prototype.thru;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_apply', './_arrayMap', './_baseFlatten', './_baseIteratee', './_baseRest', './_baseUnary', './isArray'], function(apply, arrayMap, baseFlatten, baseIteratee, baseRest, baseUnary, isArray) {
|
||||
define(['./_apply', './_arrayMap', './_baseIteratee', './_baseRest', './_baseUnary', './_flatRest'], function(apply, arrayMap, baseIteratee, baseRest, baseUnary, flatRest) {
|
||||
|
||||
/**
|
||||
* Creates a function like `_.over`.
|
||||
@@ -8,11 +8,8 @@ define(['./_apply', './_arrayMap', './_baseFlatten', './_baseIteratee', './_base
|
||||
* @returns {Function} Returns the new over function.
|
||||
*/
|
||||
function createOver(arrayFunc) {
|
||||
return baseRest(function(iteratees) {
|
||||
iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
|
||||
? arrayMap(iteratees[0], baseUnary(baseIteratee))
|
||||
: arrayMap(baseFlatten(iteratees, 1), baseUnary(baseIteratee));
|
||||
|
||||
return flatRest(function(iteratees) {
|
||||
iteratees = arrayMap(iteratees, baseUnary(baseIteratee));
|
||||
return baseRest(function(args) {
|
||||
var thisArg = this;
|
||||
return arrayFunc(iteratees, function(iteratee) {
|
||||
|
||||
@@ -3,7 +3,7 @@ define(['./_baseSetData', './_createBind', './_createCurry', './_createHybrid',
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
/** Error message constants. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/** Used to compose bitmasks for function metadata. */
|
||||
|
||||
@@ -55,7 +55,7 @@ define(['./_basePropertyOf'], function(basePropertyOf) {
|
||||
'\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
|
||||
'\u0132': 'IJ', '\u0133': 'ij',
|
||||
'\u0152': 'Oe', '\u0153': 'oe',
|
||||
'\u0149': "'n", '\u017f': 'ss'
|
||||
'\u0149': "'n", '\u017f': 's'
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
define(['./_getNative'], function(getNative) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/* Used to set `toString` methods. */
|
||||
var defineProperty = (function() {
|
||||
var func = getNative(Object, 'defineProperty'),
|
||||
name = getNative.name;
|
||||
|
||||
return (name && name.length > 2) ? func : undefined;
|
||||
try {
|
||||
var func = getNative(Object, 'defineProperty');
|
||||
func({}, '', {});
|
||||
return func;
|
||||
} catch (e) {}
|
||||
}());
|
||||
|
||||
return defineProperty;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_SetCache', './_arraySome'], function(SetCache, arraySome) {
|
||||
define(['./_SetCache', './_arraySome', './_cacheHas'], function(SetCache, arraySome, cacheHas) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -61,9 +61,9 @@ define(['./_SetCache', './_arraySome'], function(SetCache, arraySome) {
|
||||
// Recursively compare arrays (susceptible to call stack limits).
|
||||
if (seen) {
|
||||
if (!arraySome(other, function(othValue, othIndex) {
|
||||
if (!seen.has(othIndex) &&
|
||||
if (!cacheHas(seen, othIndex) &&
|
||||
(arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
|
||||
return seen.add(othIndex);
|
||||
return seen.push(othIndex);
|
||||
}
|
||||
})) {
|
||||
result = false;
|
||||
|
||||
@@ -6,8 +6,7 @@ define(['./_basePropertyOf'], function(basePropertyOf) {
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": ''',
|
||||
'`': '`'
|
||||
"'": '''
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
18
_flatRest.js
Normal file
18
_flatRest.js
Normal file
@@ -0,0 +1,18 @@
|
||||
define(['./flatten', './_overRest', './_setToString'], function(flatten, overRest, setToString) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/**
|
||||
* A specialized version of `baseRest` which flattens the rest array.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} func The function to apply a rest parameter to.
|
||||
* @returns {Function} Returns the new function.
|
||||
*/
|
||||
function flatRest(func) {
|
||||
return setToString(overRest(func, undefined, flatten), func + '');
|
||||
}
|
||||
|
||||
return flatRest;
|
||||
});
|
||||
@@ -38,8 +38,7 @@ define(['./_DataView', './_Map', './_Promise', './_Set', './_WeakMap', './_baseG
|
||||
*/
|
||||
var getTag = baseGetTag;
|
||||
|
||||
// Fallback for data views, maps, sets, and weak maps in IE 11,
|
||||
// for data views in Edge < 14, and promises in Node.js.
|
||||
// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
|
||||
if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
|
||||
(Map && getTag(new Map) != mapTag) ||
|
||||
(Promise && getTag(Promise.resolve()) != promiseTag) ||
|
||||
|
||||
10
_hasPath.js
10
_hasPath.js
@@ -12,9 +12,9 @@ define(['./_castPath', './isArguments', './isArray', './_isIndex', './_isKey', '
|
||||
function hasPath(object, path, hasFunc) {
|
||||
path = isKey(path, object) ? [path] : castPath(path);
|
||||
|
||||
var result,
|
||||
index = -1,
|
||||
length = path.length;
|
||||
var index = -1,
|
||||
length = path.length,
|
||||
result = false;
|
||||
|
||||
while (++index < length) {
|
||||
var key = toKey(path[index]);
|
||||
@@ -23,10 +23,10 @@ define(['./_castPath', './isArguments', './isArray', './_isIndex', './_isKey', '
|
||||
}
|
||||
object = object[key];
|
||||
}
|
||||
if (result) {
|
||||
if (result || ++index != length) {
|
||||
return result;
|
||||
}
|
||||
var length = object ? object.length : 0;
|
||||
length = object ? object.length : 0;
|
||||
return !!length && isLength(length) && isIndex(key, length) &&
|
||||
(isArray(object) || isArguments(object));
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ define(['./_nativeCreate'], function(nativeCreate) {
|
||||
*/
|
||||
function hashClear() {
|
||||
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
||||
this.size = 0;
|
||||
}
|
||||
|
||||
return hashClear;
|
||||
|
||||
@@ -11,7 +11,9 @@ define([], function() {
|
||||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||||
*/
|
||||
function hashDelete(key) {
|
||||
return this.has(key) && delete this.__data__[key];
|
||||
var result = this.has(key) && delete this.__data__[key];
|
||||
this.size -= result ? 1 : 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
return hashDelete;
|
||||
|
||||
@@ -18,6 +18,7 @@ define(['./_nativeCreate'], function(nativeCreate) {
|
||||
*/
|
||||
function hashSet(key, value) {
|
||||
var data = this.__data__;
|
||||
this.size += this.has(key) ? 0 : 1;
|
||||
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -12,9 +12,11 @@ define([], function() {
|
||||
* @returns {string} Returns the modified source.
|
||||
*/
|
||||
function insertWrapDetails(source, details) {
|
||||
var length = details.length,
|
||||
lastIndex = length - 1;
|
||||
|
||||
var length = details.length;
|
||||
if (!length) {
|
||||
return source;
|
||||
}
|
||||
var lastIndex = length - 1;
|
||||
details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
|
||||
details = details.join(length > 2 ? ', ' : ' ');
|
||||
return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
define([], function() {
|
||||
|
||||
/**
|
||||
* Checks if `value` is a host object in IE < 9.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is a host object, else `false`.
|
||||
*/
|
||||
function isHostObject(value) {
|
||||
// Many host objects are `Object` objects that can coerce to strings
|
||||
// despite having improperly defined `toString` methods.
|
||||
var result = false;
|
||||
if (value != null && typeof value.toString != 'function') {
|
||||
try {
|
||||
result = !!(value + '');
|
||||
} catch (e) {}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return isHostObject;
|
||||
});
|
||||
@@ -9,6 +9,7 @@ define([], function() {
|
||||
*/
|
||||
function listCacheClear() {
|
||||
this.__data__ = [];
|
||||
this.size = 0;
|
||||
}
|
||||
|
||||
return listCacheClear;
|
||||
|
||||
@@ -28,6 +28,7 @@ define(['./_assocIndexOf'], function(assocIndexOf) {
|
||||
} else {
|
||||
splice.call(data, index, 1);
|
||||
}
|
||||
--this.size;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ define(['./_assocIndexOf'], function(assocIndexOf) {
|
||||
index = assocIndexOf(data, key);
|
||||
|
||||
if (index < 0) {
|
||||
++this.size;
|
||||
data.push([key, value]);
|
||||
} else {
|
||||
data[index][1] = value;
|
||||
|
||||
@@ -8,6 +8,7 @@ define(['./_Hash', './_ListCache', './_Map'], function(Hash, ListCache, Map) {
|
||||
* @memberOf MapCache
|
||||
*/
|
||||
function mapCacheClear() {
|
||||
this.size = 0;
|
||||
this.__data__ = {
|
||||
'hash': new Hash,
|
||||
'map': new (Map || ListCache),
|
||||
|
||||
@@ -10,7 +10,9 @@ define(['./_getMapData'], function(getMapData) {
|
||||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||||
*/
|
||||
function mapCacheDelete(key) {
|
||||
return getMapData(this, key)['delete'](key);
|
||||
var result = getMapData(this, key)['delete'](key);
|
||||
this.size -= result ? 1 : 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
return mapCacheDelete;
|
||||
|
||||
@@ -11,7 +11,11 @@ define(['./_getMapData'], function(getMapData) {
|
||||
* @returns {Object} Returns the map cache instance.
|
||||
*/
|
||||
function mapCacheSet(key, value) {
|
||||
getMapData(this, key).set(key, value);
|
||||
var data = getMapData(this, key),
|
||||
size = data.size;
|
||||
|
||||
data.set(key, value);
|
||||
this.size += data.size == size ? 0 : 1;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
27
_memoizeCapped.js
Normal file
27
_memoizeCapped.js
Normal file
@@ -0,0 +1,27 @@
|
||||
define(['./memoize'], function(memoize) {
|
||||
|
||||
/** Used as the maximum memoize cache size. */
|
||||
var MAX_MEMOIZE_SIZE = 500;
|
||||
|
||||
/**
|
||||
* A specialized version of `_.memoize` which clears the memoized function's
|
||||
* cache when it exceeds `MAX_MEMOIZE_SIZE`.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} func The function to have its output memoized.
|
||||
* @returns {Function} Returns the new memoized function.
|
||||
*/
|
||||
function memoizeCapped(func) {
|
||||
var result = memoize(func, function(key) {
|
||||
if (cache.size === MAX_MEMOIZE_SIZE) {
|
||||
cache.clear();
|
||||
}
|
||||
return key;
|
||||
});
|
||||
|
||||
var cache = result.cache;
|
||||
return result;
|
||||
}
|
||||
|
||||
return memoizeCapped;
|
||||
});
|
||||
40
_overRest.js
Normal file
40
_overRest.js
Normal file
@@ -0,0 +1,40 @@
|
||||
define(['./_apply'], function(apply) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
var nativeMax = Math.max;
|
||||
|
||||
/**
|
||||
* A specialized version of `baseRest` which transforms the rest array.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} func The function to apply a rest parameter to.
|
||||
* @param {number} [start=func.length-1] The start position of the rest parameter.
|
||||
* @param {Function} transform The rest array transform.
|
||||
* @returns {Function} Returns the new function.
|
||||
*/
|
||||
function overRest(func, start, transform) {
|
||||
start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
|
||||
return function() {
|
||||
var args = arguments,
|
||||
index = -1,
|
||||
length = nativeMax(args.length - start, 0),
|
||||
array = Array(length);
|
||||
|
||||
while (++index < length) {
|
||||
array[index] = args[start + index];
|
||||
}
|
||||
index = -1;
|
||||
var otherArgs = Array(start + 1);
|
||||
while (++index < start) {
|
||||
otherArgs[index] = args[index];
|
||||
}
|
||||
otherArgs[start] = transform(array);
|
||||
return apply(func, this, otherArgs);
|
||||
};
|
||||
}
|
||||
|
||||
return overRest;
|
||||
});
|
||||
26
_setData.js
26
_setData.js
@@ -1,8 +1,4 @@
|
||||
define(['./_baseSetData', './now'], function(baseSetData, now) {
|
||||
|
||||
/** Used to detect hot functions by number of calls within a span of milliseconds. */
|
||||
var HOT_COUNT = 150,
|
||||
HOT_SPAN = 16;
|
||||
define(['./_baseSetData', './_shortOut'], function(baseSetData, shortOut) {
|
||||
|
||||
/**
|
||||
* Sets metadata for `func`.
|
||||
@@ -18,25 +14,7 @@ define(['./_baseSetData', './now'], function(baseSetData, now) {
|
||||
* @param {*} data The metadata.
|
||||
* @returns {Function} Returns `func`.
|
||||
*/
|
||||
var setData = (function() {
|
||||
var count = 0,
|
||||
lastCalled = 0;
|
||||
|
||||
return function(key, value) {
|
||||
var stamp = now(),
|
||||
remaining = HOT_SPAN - (stamp - lastCalled);
|
||||
|
||||
lastCalled = stamp;
|
||||
if (remaining > 0) {
|
||||
if (++count >= HOT_COUNT) {
|
||||
return key;
|
||||
}
|
||||
} else {
|
||||
count = 0;
|
||||
}
|
||||
return baseSetData(key, value);
|
||||
};
|
||||
}());
|
||||
var setData = shortOut(baseSetData);
|
||||
|
||||
return setData;
|
||||
});
|
||||
|
||||
14
_setToString.js
Normal file
14
_setToString.js
Normal file
@@ -0,0 +1,14 @@
|
||||
define(['./_baseSetToString', './_shortOut'], function(baseSetToString, shortOut) {
|
||||
|
||||
/**
|
||||
* Sets the `toString` method of `func` to return `string`.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} func The function to modify.
|
||||
* @param {Function} string The `toString` result.
|
||||
* @returns {Function} Returns `func`.
|
||||
*/
|
||||
var setToString = shortOut(baseSetToString);
|
||||
|
||||
return setToString;
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./constant', './_defineProperty', './_getWrapDetails', './identity', './_insertWrapDetails', './_updateWrapDetails'], function(constant, defineProperty, getWrapDetails, identity, insertWrapDetails, updateWrapDetails) {
|
||||
define(['./_getWrapDetails', './_insertWrapDetails', './_setToString', './_updateWrapDetails'], function(getWrapDetails, insertWrapDetails, setToString, updateWrapDetails) {
|
||||
|
||||
/**
|
||||
* Sets the `toString` method of `wrapper` to mimic the source of `reference`
|
||||
@@ -10,14 +10,10 @@ define(['./constant', './_defineProperty', './_getWrapDetails', './identity', '.
|
||||
* @param {number} bitmask The bitmask flags. See `createWrap` for more details.
|
||||
* @returns {Function} Returns `wrapper`.
|
||||
*/
|
||||
var setWrapToString = !defineProperty ? identity : function(wrapper, reference, bitmask) {
|
||||
function setWrapToString(wrapper, reference, bitmask) {
|
||||
var source = (reference + '');
|
||||
return defineProperty(wrapper, 'toString', {
|
||||
'configurable': true,
|
||||
'enumerable': false,
|
||||
'value': constant(insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)))
|
||||
});
|
||||
};
|
||||
return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
|
||||
}
|
||||
|
||||
return setWrapToString;
|
||||
});
|
||||
|
||||
43
_shortOut.js
Normal file
43
_shortOut.js
Normal file
@@ -0,0 +1,43 @@
|
||||
define([], function() {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/** Used to detect hot functions by number of calls within a span of milliseconds. */
|
||||
var HOT_COUNT = 500,
|
||||
HOT_SPAN = 16;
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
var nativeNow = Date.now;
|
||||
|
||||
/**
|
||||
* Creates a function that'll short out and invoke `identity` instead
|
||||
* of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
|
||||
* milliseconds.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} func The function to restrict.
|
||||
* @returns {Function} Returns the new shortable function.
|
||||
*/
|
||||
function shortOut(func) {
|
||||
var count = 0,
|
||||
lastCalled = 0;
|
||||
|
||||
return function() {
|
||||
var stamp = nativeNow(),
|
||||
remaining = HOT_SPAN - (stamp - lastCalled);
|
||||
|
||||
lastCalled = stamp;
|
||||
if (remaining > 0) {
|
||||
if (++count >= HOT_COUNT) {
|
||||
return arguments[0];
|
||||
}
|
||||
} else {
|
||||
count = 0;
|
||||
}
|
||||
return func.apply(undefined, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
return shortOut;
|
||||
});
|
||||
32
_shuffleSelf.js
Normal file
32
_shuffleSelf.js
Normal file
@@ -0,0 +1,32 @@
|
||||
define(['./_baseRandom'], function(baseRandom) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/**
|
||||
* A specialized version of `_.shuffle` which mutates and sets the size of `array`.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to shuffle.
|
||||
* @param {number} [size=array.length] The size of `array`.
|
||||
* @returns {Array} Returns `array`.
|
||||
*/
|
||||
function shuffleSelf(array, size) {
|
||||
var index = -1,
|
||||
length = array.length,
|
||||
lastIndex = length - 1;
|
||||
|
||||
size = size === undefined ? length : size;
|
||||
while (++index < size) {
|
||||
var rand = baseRandom(index, lastIndex),
|
||||
value = array[rand];
|
||||
|
||||
array[rand] = array[index];
|
||||
array[index] = value;
|
||||
}
|
||||
array.length = size;
|
||||
return array;
|
||||
}
|
||||
|
||||
return shuffleSelf;
|
||||
});
|
||||
@@ -9,6 +9,7 @@ define(['./_ListCache'], function(ListCache) {
|
||||
*/
|
||||
function stackClear() {
|
||||
this.__data__ = new ListCache;
|
||||
this.size = 0;
|
||||
}
|
||||
|
||||
return stackClear;
|
||||
|
||||
@@ -10,7 +10,11 @@ define([], function() {
|
||||
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
||||
*/
|
||||
function stackDelete(key) {
|
||||
return this.__data__['delete'](key);
|
||||
var data = this.__data__,
|
||||
result = data['delete'](key);
|
||||
|
||||
this.size = data.size;
|
||||
return result;
|
||||
}
|
||||
|
||||
return stackDelete;
|
||||
|
||||
12
_stackSet.js
12
_stackSet.js
@@ -14,16 +14,18 @@ define(['./_ListCache', './_Map', './_MapCache'], function(ListCache, Map, MapCa
|
||||
* @returns {Object} Returns the stack cache instance.
|
||||
*/
|
||||
function stackSet(key, value) {
|
||||
var cache = this.__data__;
|
||||
if (cache instanceof ListCache) {
|
||||
var pairs = cache.__data__;
|
||||
var data = this.__data__;
|
||||
if (data instanceof ListCache) {
|
||||
var pairs = data.__data__;
|
||||
if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
|
||||
pairs.push([key, value]);
|
||||
this.size = ++data.size;
|
||||
return this;
|
||||
}
|
||||
cache = this.__data__ = new MapCache(pairs);
|
||||
data = this.__data__ = new MapCache(pairs);
|
||||
}
|
||||
cache.set(key, value);
|
||||
data.set(key, value);
|
||||
this.size = data.size;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
26
_strictIndexOf.js
Normal file
26
_strictIndexOf.js
Normal file
@@ -0,0 +1,26 @@
|
||||
define([], function() {
|
||||
|
||||
/**
|
||||
* A specialized version of `_.indexOf` which performs strict equality
|
||||
* comparisons of values, i.e. `===`.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to inspect.
|
||||
* @param {*} value The value to search for.
|
||||
* @param {number} fromIndex The index to search from.
|
||||
* @returns {number} Returns the index of the matched value, else `-1`.
|
||||
*/
|
||||
function strictIndexOf(array, value, fromIndex) {
|
||||
var index = fromIndex - 1,
|
||||
length = array.length;
|
||||
|
||||
while (++index < length) {
|
||||
if (array[index] === value) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
return strictIndexOf;
|
||||
});
|
||||
24
_strictLastIndexOf.js
Normal file
24
_strictLastIndexOf.js
Normal file
@@ -0,0 +1,24 @@
|
||||
define([], function() {
|
||||
|
||||
/**
|
||||
* A specialized version of `_.lastIndexOf` which performs strict equality
|
||||
* comparisons of values, i.e. `===`.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to inspect.
|
||||
* @param {*} value The value to search for.
|
||||
* @param {number} fromIndex The index to search from.
|
||||
* @returns {number} Returns the index of the matched value, else `-1`.
|
||||
*/
|
||||
function strictLastIndexOf(array, value, fromIndex) {
|
||||
var index = fromIndex + 1;
|
||||
while (index--) {
|
||||
if (array[index] === value) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
return strictLastIndexOf;
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./memoize', './toString'], function(memoize, toString) {
|
||||
define(['./_memoizeCapped', './toString'], function(memoizeCapped, toString) {
|
||||
|
||||
/** Used to match property names within property paths. */
|
||||
var reLeadingDot = /^\./,
|
||||
@@ -14,7 +14,7 @@ define(['./memoize', './toString'], function(memoize, toString) {
|
||||
* @param {string} string The string to convert.
|
||||
* @returns {Array} Returns the property path array.
|
||||
*/
|
||||
var stringToPath = memoize(function(string) {
|
||||
var stringToPath = memoizeCapped(function(string) {
|
||||
string = toString(string);
|
||||
|
||||
var result = [];
|
||||
|
||||
@@ -6,8 +6,7 @@ define(['./_basePropertyOf'], function(basePropertyOf) {
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
''': "'",
|
||||
'`': '`'
|
||||
''': "'"
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,7 +36,7 @@ define([], function() {
|
||||
function unicodeSize(string) {
|
||||
var result = reUnicode.lastIndex = 0;
|
||||
while (reUnicode.test(string)) {
|
||||
result++;
|
||||
++result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
2
after.js
2
after.js
@@ -1,6 +1,6 @@
|
||||
define(['./toInteger'], function(toInteger) {
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
/** Error message constants. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,12 +6,6 @@ define(['./_assignValue', './_copyObject', './_createAssigner', './isArrayLike',
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/** Built-in value references. */
|
||||
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
||||
|
||||
/** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
|
||||
var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
|
||||
|
||||
/**
|
||||
* Assigns own enumerable string keyed properties of source objects to the
|
||||
* destination object. Source objects are applied from left to right.
|
||||
@@ -45,7 +39,7 @@ define(['./_assignValue', './_copyObject', './_createAssigner', './isArrayLike',
|
||||
* // => { 'a': 1, 'c': 3 }
|
||||
*/
|
||||
var assign = createAssigner(function(object, source) {
|
||||
if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
|
||||
if (isPrototype(source) || isArrayLike(source)) {
|
||||
copyObject(source, keys(source), object);
|
||||
return;
|
||||
}
|
||||
|
||||
6
at.js
6
at.js
@@ -1,4 +1,4 @@
|
||||
define(['./_baseAt', './_baseFlatten', './_baseRest'], function(baseAt, baseFlatten, baseRest) {
|
||||
define(['./_baseAt', './_flatRest'], function(baseAt, flatRest) {
|
||||
|
||||
/**
|
||||
* Creates an array of values corresponding to `paths` of `object`.
|
||||
@@ -17,9 +17,7 @@ define(['./_baseAt', './_baseFlatten', './_baseRest'], function(baseAt, baseFlat
|
||||
* _.at(object, ['a[0].b.c', 'a[1]']);
|
||||
* // => [3, 4]
|
||||
*/
|
||||
var at = baseRest(function(object, paths) {
|
||||
return baseAt(object, baseFlatten(paths, 1));
|
||||
});
|
||||
var at = flatRest(baseAt);
|
||||
|
||||
return at;
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ define(['./toInteger'], function(toInteger) {
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
/** Error message constants. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_arrayEach', './_baseFlatten', './_baseRest', './bind', './_toKey'], function(arrayEach, baseFlatten, baseRest, bind, toKey) {
|
||||
define(['./_arrayEach', './_baseAssignValue', './bind', './_flatRest', './_toKey'], function(arrayEach, baseAssignValue, bind, flatRest, toKey) {
|
||||
|
||||
/**
|
||||
* Binds methods of an object to the object itself, overwriting the existing
|
||||
@@ -26,10 +26,10 @@ define(['./_arrayEach', './_baseFlatten', './_baseRest', './bind', './_toKey'],
|
||||
* jQuery(element).on('click', view.click);
|
||||
* // => Logs 'clicked docs' when clicked.
|
||||
*/
|
||||
var bindAll = baseRest(function(object, methodNames) {
|
||||
arrayEach(baseFlatten(methodNames, 1), function(key) {
|
||||
var bindAll = flatRest(function(object, methodNames) {
|
||||
arrayEach(methodNames, function(key) {
|
||||
key = toKey(key);
|
||||
object[key] = bind(object[key], object);
|
||||
baseAssignValue(object, key, bind(object[key], object));
|
||||
});
|
||||
return object;
|
||||
});
|
||||
|
||||
11
concat.js
11
concat.js
@@ -23,17 +23,18 @@ define(['./_arrayPush', './_baseFlatten', './_copyArray', './isArray'], function
|
||||
* // => [1]
|
||||
*/
|
||||
function concat() {
|
||||
var length = arguments.length,
|
||||
args = Array(length ? length - 1 : 0),
|
||||
var length = arguments.length;
|
||||
if (!length) {
|
||||
return [];
|
||||
}
|
||||
var args = Array(length - 1),
|
||||
array = arguments[0],
|
||||
index = length;
|
||||
|
||||
while (index--) {
|
||||
args[index - 1] = arguments[index];
|
||||
}
|
||||
return length
|
||||
? arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1))
|
||||
: [];
|
||||
return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
|
||||
}
|
||||
|
||||
return concat;
|
||||
|
||||
2
cond.js
2
cond.js
@@ -1,6 +1,6 @@
|
||||
define(['./_apply', './_arrayMap', './_baseIteratee', './_baseRest'], function(apply, arrayMap, baseIteratee, baseRest) {
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
/** Error message constants. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_createAggregator'], function(createAggregator) {
|
||||
define(['./_baseAssignValue', './_createAggregator'], function(baseAssignValue, createAggregator) {
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
@@ -30,7 +30,11 @@ define(['./_createAggregator'], function(createAggregator) {
|
||||
* // => { '3': 2, '5': 1 }
|
||||
*/
|
||||
var countBy = createAggregator(function(result, value, key) {
|
||||
hasOwnProperty.call(result, key) ? ++result[key] : (result[key] = 1);
|
||||
if (hasOwnProperty.call(result, key)) {
|
||||
++result[key];
|
||||
} else {
|
||||
baseAssignValue(result, key, 1);
|
||||
}
|
||||
});
|
||||
|
||||
return countBy;
|
||||
|
||||
@@ -3,7 +3,7 @@ define(['./isObject', './now', './toNumber'], function(isObject, now, toNumber)
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
/** Error message constants. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
|
||||
2
defer.js
2
defer.js
@@ -16,7 +16,7 @@ define(['./_baseDelay', './_baseRest'], function(baseDelay, baseRest) {
|
||||
* _.defer(function(text) {
|
||||
* console.log(text);
|
||||
* }, 'deferred');
|
||||
* // => Logs 'deferred' after one or more milliseconds.
|
||||
* // => Logs 'deferred' after one millisecond.
|
||||
*/
|
||||
var defer = baseRest(function(func, args) {
|
||||
return baseDelay(func, 1, args);
|
||||
|
||||
@@ -3,8 +3,8 @@ define(['./_baseDifference', './_baseFlatten', './_baseRest', './isArrayLikeObje
|
||||
/**
|
||||
* Creates an array of `array` values not included in the other given arrays
|
||||
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
||||
* for equality comparisons. The order of result values is determined by the
|
||||
* order they occur in the first array.
|
||||
* for equality comparisons. The order and references of result values are
|
||||
* determined by the first array.
|
||||
*
|
||||
* **Note:** Unlike `_.pullAll`, this method returns a new array.
|
||||
*
|
||||
|
||||
@@ -6,8 +6,9 @@ define(['./_baseDifference', './_baseFlatten', './_baseIteratee', './_baseRest',
|
||||
/**
|
||||
* This method is like `_.difference` except that it accepts `iteratee` which
|
||||
* is invoked for each element of `array` and `values` to generate the criterion
|
||||
* by which they're compared. Result values are chosen from the first array.
|
||||
* The iteratee is invoked with one argument: (value).
|
||||
* by which they're compared. The order and references of result values are
|
||||
* determined by the first array. The iteratee is invoked with one argument:
|
||||
* (value).
|
||||
*
|
||||
* **Note:** Unlike `_.pullAllBy`, this method returns a new array.
|
||||
*
|
||||
|
||||
@@ -5,9 +5,9 @@ define(['./_baseDifference', './_baseFlatten', './_baseRest', './isArrayLikeObje
|
||||
|
||||
/**
|
||||
* This method is like `_.difference` except that it accepts `comparator`
|
||||
* which is invoked to compare elements of `array` to `values`. Result values
|
||||
* are chosen from the first array. The comparator is invoked with two arguments:
|
||||
* (arrVal, othVal).
|
||||
* which is invoked to compare elements of `array` to `values`. The order and
|
||||
* references of result values are determined by the first array. The comparator
|
||||
* is invoked with two arguments: (arrVal, othVal).
|
||||
*
|
||||
* **Note:** Unlike `_.pullAllWith`, this method returns a new array.
|
||||
*
|
||||
|
||||
12
escape.js
12
escape.js
@@ -1,12 +1,12 @@
|
||||
define(['./_escapeHtmlChar', './toString'], function(escapeHtmlChar, toString) {
|
||||
|
||||
/** Used to match HTML entities and HTML characters. */
|
||||
var reUnescapedHtml = /[&<>"'`]/g,
|
||||
var reUnescapedHtml = /[&<>"']/g,
|
||||
reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
|
||||
|
||||
/**
|
||||
* Converts the characters "&", "<", ">", '"', "'", and "\`" in `string` to
|
||||
* their corresponding HTML entities.
|
||||
* Converts the characters "&", "<", ">", '"', and "'" in `string` to their
|
||||
* corresponding HTML entities.
|
||||
*
|
||||
* **Note:** No other characters are escaped. To escape additional
|
||||
* characters use a third-party library like [_he_](https://mths.be/he).
|
||||
@@ -17,12 +17,6 @@ define(['./_escapeHtmlChar', './toString'], function(escapeHtmlChar, toString) {
|
||||
* [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
|
||||
* (under "semi-related fun fact") for more details.
|
||||
*
|
||||
* Backticks are escaped because in IE < 9, they can break out of
|
||||
* attribute values or HTML comments. See [#59](https://html5sec.org/#59),
|
||||
* [#102](https://html5sec.org/#102), [#108](https://html5sec.org/#108), and
|
||||
* [#133](https://html5sec.org/#133) of the
|
||||
* [HTML5 Security Cheatsheet](https://html5sec.org/) for more details.
|
||||
*
|
||||
* When working with HTML you should always
|
||||
* [quote attribute values](http://wonko.com/post/html-escaping) to reduce
|
||||
* XSS vectors.
|
||||
|
||||
@@ -20,7 +20,7 @@ define(['./_arrayEach', './_baseEach', './_baseIteratee', './isArray'], function
|
||||
* @see _.forEachRight
|
||||
* @example
|
||||
*
|
||||
* _([1, 2]).forEach(function(value) {
|
||||
* _.forEach([1, 2], function(value) {
|
||||
* console.log(value);
|
||||
* });
|
||||
* // => Logs `1` then `2`.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_createAggregator'], function(createAggregator) {
|
||||
define(['./_baseAssignValue', './_createAggregator'], function(baseAssignValue, createAggregator) {
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
@@ -34,7 +34,7 @@ define(['./_createAggregator'], function(createAggregator) {
|
||||
if (hasOwnProperty.call(result, key)) {
|
||||
result[key].push(value);
|
||||
} else {
|
||||
result[key] = [value];
|
||||
baseAssignValue(result, key, [value]);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ define(['./_arrayMap', './_baseIntersection', './_baseRest', './_castArrayLikeOb
|
||||
/**
|
||||
* Creates an array of unique values that are included in all given arrays
|
||||
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
||||
* for equality comparisons. The order of result values is determined by the
|
||||
* order they occur in the first array.
|
||||
* for equality comparisons. The order and references of result values are
|
||||
* determined by the first array.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -6,8 +6,9 @@ define(['./_arrayMap', './_baseIntersection', './_baseIteratee', './_baseRest',
|
||||
/**
|
||||
* This method is like `_.intersection` except that it accepts `iteratee`
|
||||
* which is invoked for each element of each `arrays` to generate the criterion
|
||||
* by which they're compared. Result values are chosen from the first array.
|
||||
* The iteratee is invoked with one argument: (value).
|
||||
* by which they're compared. The order and references of result values are
|
||||
* determined by the first array. The iteratee is invoked with one argument:
|
||||
* (value).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -5,9 +5,9 @@ define(['./_arrayMap', './_baseIntersection', './_baseRest', './_castArrayLikeOb
|
||||
|
||||
/**
|
||||
* This method is like `_.intersection` except that it accepts `comparator`
|
||||
* which is invoked to compare elements of `arrays`. Result values are chosen
|
||||
* from the first array. The comparator is invoked with two arguments:
|
||||
* (arrVal, othVal).
|
||||
* which is invoked to compare elements of `arrays`. The order and references
|
||||
* of result values are determined by the first array. The comparator is
|
||||
* invoked with two arguments: (arrVal, othVal).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
define(['./isArrayLikeObject'], function(isArrayLikeObject) {
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var argsTag = '[object Arguments]';
|
||||
define(['./_baseIsArguments', './isObjectLike'], function(baseIsArguments, isObjectLike) {
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
@@ -9,13 +6,6 @@ define(['./isArrayLikeObject'], function(isArrayLikeObject) {
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* Used to resolve the
|
||||
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var objectToString = objectProto.toString;
|
||||
|
||||
/** Built-in value references. */
|
||||
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
||||
|
||||
@@ -37,11 +27,10 @@ define(['./isArrayLikeObject'], function(isArrayLikeObject) {
|
||||
* _.isArguments([1, 2, 3]);
|
||||
* // => false
|
||||
*/
|
||||
function isArguments(value) {
|
||||
// Safari 8.1 makes `arguments.callee` enumerable in strict mode.
|
||||
return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
|
||||
(!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
|
||||
}
|
||||
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
|
||||
return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
|
||||
!propertyIsEnumerable.call(value, 'callee');
|
||||
};
|
||||
|
||||
return isArguments;
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@ define(['./isObjectLike', './isPlainObject'], function(isObjectLike, isPlainObje
|
||||
* // => false
|
||||
*/
|
||||
function isElement(value) {
|
||||
return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value);
|
||||
return value != null && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value);
|
||||
}
|
||||
|
||||
return isElement;
|
||||
|
||||
16
isEmpty.js
16
isEmpty.js
@@ -1,4 +1,4 @@
|
||||
define(['./_getTag', './isArguments', './isArray', './isArrayLike', './isBuffer', './_isPrototype', './_nativeKeys'], function(getTag, isArguments, isArray, isArrayLike, isBuffer, isPrototype, nativeKeys) {
|
||||
define(['./_baseKeys', './_getTag', './isArguments', './isArray', './isArrayLike', './isBuffer', './_isPrototype', './isTypedArray'], function(baseKeys, getTag, isArguments, isArray, isArrayLike, isBuffer, isPrototype, isTypedArray) {
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var mapTag = '[object Map]',
|
||||
@@ -10,12 +10,6 @@ define(['./_getTag', './isArguments', './isArray', './isArrayLike', './isBuffer'
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/** Built-in value references. */
|
||||
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
||||
|
||||
/** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
|
||||
var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
|
||||
|
||||
/**
|
||||
* Checks if `value` is an empty object, collection, map, or set.
|
||||
*
|
||||
@@ -51,16 +45,16 @@ define(['./_getTag', './isArguments', './isArray', './isArrayLike', './isBuffer'
|
||||
*/
|
||||
function isEmpty(value) {
|
||||
if (isArrayLike(value) &&
|
||||
(isArray(value) || typeof value == 'string' ||
|
||||
typeof value.splice == 'function' || isBuffer(value) || isArguments(value))) {
|
||||
(isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
|
||||
isBuffer(value) || isTypedArray(value) || isArguments(value))) {
|
||||
return !value.length;
|
||||
}
|
||||
var tag = getTag(value);
|
||||
if (tag == mapTag || tag == setTag) {
|
||||
return !value.size;
|
||||
}
|
||||
if (nonEnumShadows || isPrototype(value)) {
|
||||
return !nativeKeys(value).length;
|
||||
if (isPrototype(value)) {
|
||||
return !baseKeys(value).length;
|
||||
}
|
||||
for (var key in value) {
|
||||
if (hasOwnProperty.call(value, key)) {
|
||||
|
||||
@@ -2,7 +2,8 @@ define(['./isObject'], function(isObject) {
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var funcTag = '[object Function]',
|
||||
genTag = '[object GeneratorFunction]';
|
||||
genTag = '[object GeneratorFunction]',
|
||||
proxyTag = '[object Proxy]';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
@@ -33,9 +34,9 @@ define(['./isObject'], function(isObject) {
|
||||
*/
|
||||
function isFunction(value) {
|
||||
// The use of `Object#toString` avoids issues with the `typeof` operator
|
||||
// in Safari 8-9 which returns 'object' for typed array and other constructors.
|
||||
// in Safari 9 which returns 'object' for typed array and other constructors.
|
||||
var tag = isObject(value) ? objectToString.call(value) : '';
|
||||
return tag == funcTag || tag == genTag;
|
||||
return tag == funcTag || tag == genTag || tag == proxyTag;
|
||||
}
|
||||
|
||||
return isFunction;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
define(['./_baseIsNative', './_isMaskable'], function(baseIsNative, isMaskable) {
|
||||
|
||||
/** Error message constants. */
|
||||
var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://github.com/es-shims.';
|
||||
|
||||
/**
|
||||
* Checks if `value` is a pristine native function.
|
||||
*
|
||||
@@ -28,7 +31,7 @@ define(['./_baseIsNative', './_isMaskable'], function(baseIsNative, isMaskable)
|
||||
*/
|
||||
function isNative(value) {
|
||||
if (isMaskable(value)) {
|
||||
throw new Error('This method is not supported with core-js. Try https://github.com/es-shims.');
|
||||
throw new Error(CORE_ERROR_TEXT);
|
||||
}
|
||||
return baseIsNative(value);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ define([], function() {
|
||||
*/
|
||||
function isObject(value) {
|
||||
var type = typeof value;
|
||||
return !!value && (type == 'object' || type == 'function');
|
||||
return value != null && (type == 'object' || type == 'function');
|
||||
}
|
||||
|
||||
return isObject;
|
||||
|
||||
@@ -25,7 +25,7 @@ define([], function() {
|
||||
* // => false
|
||||
*/
|
||||
function isObjectLike(value) {
|
||||
return !!value && typeof value == 'object';
|
||||
return value != null && typeof value == 'object';
|
||||
}
|
||||
|
||||
return isObjectLike;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_getPrototype', './_isHostObject', './isObjectLike'], function(getPrototype, isHostObject, isObjectLike) {
|
||||
define(['./_getPrototype', './isObjectLike'], function(getPrototype, isObjectLike) {
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var objectTag = '[object Object]';
|
||||
@@ -52,8 +52,7 @@ define(['./_getPrototype', './_isHostObject', './isObjectLike'], function(getPro
|
||||
* // => true
|
||||
*/
|
||||
function isPlainObject(value) {
|
||||
if (!isObjectLike(value) ||
|
||||
objectToString.call(value) != objectTag || isHostObject(value)) {
|
||||
if (!isObjectLike(value) || objectToString.call(value) != objectTag) {
|
||||
return false;
|
||||
}
|
||||
var proto = getPrototype(value);
|
||||
|
||||
4
keyBy.js
4
keyBy.js
@@ -1,4 +1,4 @@
|
||||
define(['./_createAggregator'], function(createAggregator) {
|
||||
define(['./_baseAssignValue', './_createAggregator'], function(baseAssignValue, createAggregator) {
|
||||
|
||||
/**
|
||||
* Creates an object composed of keys generated from the results of running
|
||||
@@ -30,7 +30,7 @@ define(['./_createAggregator'], function(createAggregator) {
|
||||
* // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
|
||||
*/
|
||||
var keyBy = createAggregator(function(result, value, key) {
|
||||
result[key] = value;
|
||||
baseAssignValue(result, key, value);
|
||||
});
|
||||
|
||||
return keyBy;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_baseFindIndex', './_baseIsNaN', './toInteger'], function(baseFindIndex, baseIsNaN, toInteger) {
|
||||
define(['./_baseFindIndex', './_baseIsNaN', './_strictLastIndexOf', './toInteger'], function(baseFindIndex, baseIsNaN, strictLastIndexOf, toInteger) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -36,21 +36,11 @@ define(['./_baseFindIndex', './_baseIsNaN', './toInteger'], function(baseFindInd
|
||||
var index = length;
|
||||
if (fromIndex !== undefined) {
|
||||
index = toInteger(fromIndex);
|
||||
index = (
|
||||
index < 0
|
||||
? nativeMax(length + index, 0)
|
||||
: nativeMin(index, length - 1)
|
||||
) + 1;
|
||||
index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
|
||||
}
|
||||
if (value !== value) {
|
||||
return baseFindIndex(array, baseIsNaN, index - 1, true);
|
||||
}
|
||||
while (index--) {
|
||||
if (array[index] === value) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return value === value
|
||||
? strictLastIndexOf(array, value, index)
|
||||
: baseFindIndex(array, baseIsNaN, index, true);
|
||||
}
|
||||
|
||||
return lastIndexOf;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_baseForOwn', './_baseIteratee'], function(baseForOwn, baseIteratee) {
|
||||
define(['./_baseAssignValue', './_baseForOwn', './_baseIteratee'], function(baseAssignValue, baseForOwn, baseIteratee) {
|
||||
|
||||
/**
|
||||
* The opposite of `_.mapValues`; this method creates an object with the
|
||||
@@ -26,7 +26,7 @@ define(['./_baseForOwn', './_baseIteratee'], function(baseForOwn, baseIteratee)
|
||||
iteratee = baseIteratee(iteratee, 3);
|
||||
|
||||
baseForOwn(object, function(value, key, object) {
|
||||
result[iteratee(value, key, object)] = value;
|
||||
baseAssignValue(result, iteratee(value, key, object), value);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_baseForOwn', './_baseIteratee'], function(baseForOwn, baseIteratee) {
|
||||
define(['./_baseAssignValue', './_baseForOwn', './_baseIteratee'], function(baseAssignValue, baseForOwn, baseIteratee) {
|
||||
|
||||
/**
|
||||
* Creates an object with the same keys as `object` and values generated
|
||||
@@ -33,7 +33,7 @@ define(['./_baseForOwn', './_baseIteratee'], function(baseForOwn, baseIteratee)
|
||||
iteratee = baseIteratee(iteratee, 3);
|
||||
|
||||
baseForOwn(object, function(value, key, object) {
|
||||
result[key] = iteratee(value, key, object);
|
||||
baseAssignValue(result, key, iteratee(value, key, object));
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
define(['./_MapCache'], function(MapCache) {
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
/** Error message constants. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/**
|
||||
@@ -60,14 +60,14 @@ define(['./_MapCache'], function(MapCache) {
|
||||
return cache.get(key);
|
||||
}
|
||||
var result = func.apply(this, args);
|
||||
memoized.cache = cache.set(key, result);
|
||||
memoized.cache = cache.set(key, result) || cache;
|
||||
return result;
|
||||
};
|
||||
memoized.cache = new (memoize.Cache || MapCache);
|
||||
return memoized;
|
||||
}
|
||||
|
||||
// Assign cache to `_.memoize`.
|
||||
// Expose `MapCache`.
|
||||
memoize.Cache = MapCache;
|
||||
|
||||
return memoize;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user