mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 08:57:49 +00:00
Compare commits
2 Commits
4.16.1-amd
...
4.16.3-amd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0961d6edde | ||
|
|
2f8450b523 |
@@ -1,4 +1,4 @@
|
|||||||
# lodash-amd v4.16.1
|
# lodash-amd v4.16.3
|
||||||
|
|
||||||
The [Lodash](https://lodash.com/) library exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules.
|
The [Lodash](https://lodash.com/) library exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules.
|
||||||
|
|
||||||
@@ -27,4 +27,4 @@ require({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
See the [package source](https://github.com/lodash/lodash/tree/4.16.1-amd) for more details.
|
See the [package source](https://github.com/lodash/lodash/tree/4.16.3-amd) for more details.
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ define(['./_baseRandom'], function(baseRandom) {
|
|||||||
var undefined;
|
var undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialized version of `_.sample` for arrays without support for iteratee
|
* A specialized version of `_.sample` for arrays.
|
||||||
* shorthands.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to sample.
|
* @param {Array} array The array to sample.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./_arrayShuffle', './_baseClamp'], function(arrayShuffle, baseClamp) {
|
define(['./_copyArray', './_shuffleSelf'], function(copyArray, shuffleSelf) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialized version of `_.sampleSize` for arrays.
|
* A specialized version of `_.sampleSize` for arrays.
|
||||||
@@ -9,9 +9,7 @@ define(['./_arrayShuffle', './_baseClamp'], function(arrayShuffle, baseClamp) {
|
|||||||
* @returns {Array} Returns the random elements.
|
* @returns {Array} Returns the random elements.
|
||||||
*/
|
*/
|
||||||
function arraySampleSize(array, n) {
|
function arraySampleSize(array, n) {
|
||||||
var result = arrayShuffle(array);
|
return shuffleSelf(copyArray(array), n);
|
||||||
result.length = baseClamp(n, 0, result.length);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return arraySampleSize;
|
return arraySampleSize;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ define(['./_baseAssignValue', './eq'], function(baseAssignValue, eq) {
|
|||||||
*/
|
*/
|
||||||
function assignMergeValue(object, key, value) {
|
function assignMergeValue(object, key, value) {
|
||||||
if ((value !== undefined && !eq(object[key], value)) ||
|
if ((value !== undefined && !eq(object[key], value)) ||
|
||||||
(typeof key == 'number' && value === undefined && !(key in object))) {
|
(value === undefined && !(key in object))) {
|
||||||
baseAssignValue(object, key, value);
|
baseAssignValue(object, key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
define([], function() {
|
define(['./_defineProperty'], function(defineProperty) {
|
||||||
|
|
||||||
/** Built-in value references. */
|
|
||||||
var defineProperty = Object.defineProperty;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `assignValue` and `assignMergeValue` without
|
* The base implementation of `assignValue` and `assignMergeValue` without
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
define(['./isObject'], function(isObject) {
|
define(['./isObject'], function(isObject) {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
/** Built-in value references. */
|
/** Built-in value references. */
|
||||||
var objectCreate = Object.create;
|
var objectCreate = Object.create;
|
||||||
|
|
||||||
@@ -8,12 +11,24 @@ define(['./isObject'], function(isObject) {
|
|||||||
* properties to the created object.
|
* properties to the created object.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} prototype The object to inherit from.
|
* @param {Object} proto The object to inherit from.
|
||||||
* @returns {Object} Returns the new object.
|
* @returns {Object} Returns the new object.
|
||||||
*/
|
*/
|
||||||
function baseCreate(proto) {
|
var baseCreate = (function() {
|
||||||
return isObject(proto) ? objectCreate(proto) : {};
|
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;
|
return baseCreate;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ define([], function() {
|
|||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
|
|
||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Error message constants. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./_Stack', './_equalArrays', './_equalByTag', './_equalObjects', './_getTag', './isArray', './isTypedArray'], function(Stack, equalArrays, equalByTag, equalObjects, getTag, isArray, 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. */
|
/** Used to compose bitmasks for comparison styles. */
|
||||||
var PARTIAL_COMPARE_FLAG = 2;
|
var PARTIAL_COMPARE_FLAG = 2;
|
||||||
@@ -47,6 +47,13 @@ define(['./_Stack', './_equalArrays', './_equalByTag', './_equalObjects', './_ge
|
|||||||
othIsObj = othTag == objectTag,
|
othIsObj = othTag == objectTag,
|
||||||
isSameTag = objTag == othTag;
|
isSameTag = objTag == othTag;
|
||||||
|
|
||||||
|
if (isSameTag && isBuffer(object)) {
|
||||||
|
if (!isBuffer(other)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
objIsArr = true;
|
||||||
|
objIsObj = false;
|
||||||
|
}
|
||||||
if (isSameTag && !objIsObj) {
|
if (isSameTag && !objIsObj) {
|
||||||
stack || (stack = new Stack);
|
stack || (stack = new Stack);
|
||||||
return (objIsArr || isTypedArray(object))
|
return (objIsArr || isTypedArray(object))
|
||||||
|
|||||||
@@ -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', './_cloneTypedArray', './_copyArray', './_initCloneObject', './isArguments', './isArray', './isArrayLikeObject', './isFunction', './isObject', './isPlainObject', './isTypedArray', './toPlainObject'], function(assignMergeValue, cloneTypedArray, copyArray, initCloneObject, isArguments, isArray, isArrayLikeObject, isFunction, isObject, isPlainObject, isTypedArray, toPlainObject) {
|
||||||
|
|
||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
@@ -34,29 +34,32 @@ define(['./_assignMergeValue', './_baseClone', './_copyArray', './isArguments',
|
|||||||
var isCommon = newValue === undefined;
|
var isCommon = newValue === undefined;
|
||||||
|
|
||||||
if (isCommon) {
|
if (isCommon) {
|
||||||
|
var isArr = isArray(srcValue),
|
||||||
|
isTyped = !isArr && isTypedArray(srcValue);
|
||||||
|
|
||||||
newValue = srcValue;
|
newValue = srcValue;
|
||||||
if (isArray(srcValue) || isTypedArray(srcValue)) {
|
if (isArr || isTyped) {
|
||||||
if (isArray(objValue)) {
|
if (isArray(objValue)) {
|
||||||
newValue = objValue;
|
newValue = objValue;
|
||||||
}
|
}
|
||||||
else if (isArrayLikeObject(objValue)) {
|
else if (isArrayLikeObject(objValue)) {
|
||||||
newValue = copyArray(objValue);
|
newValue = copyArray(objValue);
|
||||||
}
|
}
|
||||||
else {
|
else if (isTyped) {
|
||||||
isCommon = false;
|
isCommon = false;
|
||||||
newValue = baseClone(srcValue, true);
|
newValue = cloneTypedArray(srcValue, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
newValue = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
||||||
|
newValue = objValue;
|
||||||
if (isArguments(objValue)) {
|
if (isArguments(objValue)) {
|
||||||
newValue = toPlainObject(objValue);
|
newValue = toPlainObject(objValue);
|
||||||
}
|
}
|
||||||
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
||||||
isCommon = false;
|
newValue = initCloneObject(srcValue);
|
||||||
newValue = baseClone(srcValue, true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
newValue = objValue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
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;
|
||||||
|
});
|
||||||
16
_baseSampleSize.js
Normal file
16
_baseSampleSize.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
define(['./_shuffleSelf', './values'], function(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) {
|
||||||
|
return shuffleSelf(values(collection), n);
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseSampleSize;
|
||||||
|
});
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./constant', './identity', './_nativeDefineProperty'], function(constant, identity, nativeDefineProperty) {
|
define(['./constant', './_defineProperty', './identity'], function(constant, defineProperty, identity) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `setToString` without support for hot loop shorting.
|
* The base implementation of `setToString` without support for hot loop shorting.
|
||||||
@@ -8,8 +8,8 @@ define(['./constant', './identity', './_nativeDefineProperty'], function(constan
|
|||||||
* @param {Function} string The `toString` result.
|
* @param {Function} string The `toString` result.
|
||||||
* @returns {Function} Returns `func`.
|
* @returns {Function} Returns `func`.
|
||||||
*/
|
*/
|
||||||
var baseSetToString = !nativeDefineProperty ? identity : function(func, string) {
|
var baseSetToString = !defineProperty ? identity : function(func, string) {
|
||||||
return nativeDefineProperty(func, 'toString', {
|
return defineProperty(func, 'toString', {
|
||||||
'configurable': true,
|
'configurable': true,
|
||||||
'enumerable': false,
|
'enumerable': false,
|
||||||
'value': constant(string),
|
'value': constant(string),
|
||||||
|
|||||||
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,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`.
|
* Creates a clone of `buffer`.
|
||||||
@@ -12,7 +28,9 @@ define([], function() {
|
|||||||
if (isDeep) {
|
if (isDeep) {
|
||||||
return buffer.slice();
|
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);
|
buffer.copy(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ define(['./_LodashWrapper', './_flatRest', './_getData', './_getFuncName', './is
|
|||||||
/** 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;
|
||||||
|
|
||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Error message constants. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/** Used to compose bitmasks for function metadata. */
|
/** Used to compose bitmasks for function metadata. */
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ define(['./_baseSetData', './_createBind', './_createCurry', './_createHybrid',
|
|||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
|
|
||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Error message constants. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/** Used to compose bitmasks for function metadata. */
|
/** Used to compose bitmasks for function metadata. */
|
||||||
|
|||||||
12
_defineProperty.js
Normal file
12
_defineProperty.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
define(['./_getNative'], function(getNative) {
|
||||||
|
|
||||||
|
var defineProperty = (function() {
|
||||||
|
try {
|
||||||
|
var func = getNative(Object, 'defineProperty');
|
||||||
|
func({}, '', {});
|
||||||
|
return func;
|
||||||
|
} catch (e) {}
|
||||||
|
}());
|
||||||
|
|
||||||
|
return defineProperty;
|
||||||
|
});
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
define(['./_getNative'], function(getNative) {
|
|
||||||
|
|
||||||
/* Built-in method references that are verified to be native. */
|
|
||||||
var nativeDefineProperty = getNative(Object, 'defineProperty');
|
|
||||||
|
|
||||||
return nativeDefineProperty;
|
|
||||||
});
|
|
||||||
@@ -1,24 +1,30 @@
|
|||||||
define(['./_baseRandom'], function(baseRandom) {
|
define(['./_baseClamp', './_baseRandom'], function(baseClamp, baseRandom) {
|
||||||
|
|
||||||
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
|
var undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialized version of `arrayShuffle` which mutates `array`.
|
* A specialized version of `_.shuffle` which mutates and sets the size of `array`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to shuffle.
|
* @param {Array} array The array to shuffle.
|
||||||
|
* @param {number} [size=array.length] The size of `array`.
|
||||||
* @returns {Array} Returns `array`.
|
* @returns {Array} Returns `array`.
|
||||||
*/
|
*/
|
||||||
function shuffleSelf(array) {
|
function shuffleSelf(array, size) {
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = array.length,
|
length = array.length,
|
||||||
lastIndex = length - 1;
|
lastIndex = length - 1;
|
||||||
|
|
||||||
while (++index < length) {
|
size = size === undefined ? length : baseClamp(size, 0, length);
|
||||||
|
while (++index < size) {
|
||||||
var rand = baseRandom(index, lastIndex),
|
var rand = baseRandom(index, lastIndex),
|
||||||
value = array[rand];
|
value = array[rand];
|
||||||
|
|
||||||
array[rand] = array[index];
|
array[rand] = array[index];
|
||||||
array[index] = value;
|
array[index] = value;
|
||||||
}
|
}
|
||||||
|
array.length = size;
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
after.js
2
after.js
@@ -1,6 +1,6 @@
|
|||||||
define(['./toInteger'], function(toInteger) {
|
define(['./toInteger'], function(toInteger) {
|
||||||
|
|
||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Error message constants. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ define(['./toInteger'], function(toInteger) {
|
|||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
|
|
||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Error message constants. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
2
cond.js
2
cond.js
@@ -1,6 +1,6 @@
|
|||||||
define(['./_apply', './_arrayMap', './_baseIteratee', './_baseRest'], function(apply, arrayMap, baseIteratee, baseRest) {
|
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';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ define(['./isObject', './now', './toNumber'], function(isObject, now, toNumber)
|
|||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
|
|
||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Error message constants. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ define(['./isObject'], function(isObject) {
|
|||||||
|
|
||||||
/** `Object#toString` result references. */
|
/** `Object#toString` result references. */
|
||||||
var funcTag = '[object Function]',
|
var funcTag = '[object Function]',
|
||||||
genTag = '[object GeneratorFunction]';
|
genTag = '[object GeneratorFunction]',
|
||||||
|
proxyTag = '[object Proxy]';
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var objectProto = Object.prototype;
|
var objectProto = Object.prototype;
|
||||||
@@ -35,7 +36,7 @@ define(['./isObject'], function(isObject) {
|
|||||||
// The use of `Object#toString` avoids issues with the `typeof` operator
|
// 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 8-9 which returns 'object' for typed array and other constructors.
|
||||||
var tag = isObject(value) ? objectToString.call(value) : '';
|
var tag = isObject(value) ? objectToString.call(value) : '';
|
||||||
return tag == funcTag || tag == genTag;
|
return tag == funcTag || tag == genTag || tag == proxyTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
return isFunction;
|
return isFunction;
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
define(['./_baseIsNative', './_isMaskable'], function(baseIsNative, isMaskable) {
|
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.
|
* Checks if `value` is a pristine native function.
|
||||||
*
|
*
|
||||||
@@ -28,7 +31,7 @@ define(['./_baseIsNative', './_isMaskable'], function(baseIsNative, isMaskable)
|
|||||||
*/
|
*/
|
||||||
function isNative(value) {
|
function isNative(value) {
|
||||||
if (isMaskable(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);
|
return baseIsNative(value);
|
||||||
}
|
}
|
||||||
|
|||||||
161
main.js
161
main.js
@@ -13,13 +13,14 @@
|
|||||||
var undefined;
|
var undefined;
|
||||||
|
|
||||||
/** Used as the semantic version number. */
|
/** Used as the semantic version number. */
|
||||||
var VERSION = '4.16.1';
|
var VERSION = '4.16.3';
|
||||||
|
|
||||||
/** 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;
|
||||||
|
|
||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Error message constants. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://github.com/es-shims.',
|
||||||
|
FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/** Used to stand-in for `undefined` hash values. */
|
/** Used to stand-in for `undefined` hash values. */
|
||||||
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
||||||
@@ -95,6 +96,7 @@
|
|||||||
numberTag = '[object Number]',
|
numberTag = '[object Number]',
|
||||||
objectTag = '[object Object]',
|
objectTag = '[object Object]',
|
||||||
promiseTag = '[object Promise]',
|
promiseTag = '[object Promise]',
|
||||||
|
proxyTag = '[object Proxy]',
|
||||||
regexpTag = '[object RegExp]',
|
regexpTag = '[object RegExp]',
|
||||||
setTag = '[object Set]',
|
setTag = '[object Set]',
|
||||||
stringTag = '[object String]',
|
stringTag = '[object String]',
|
||||||
@@ -1468,7 +1470,7 @@
|
|||||||
var Buffer = moduleExports ? context.Buffer : undefined,
|
var Buffer = moduleExports ? context.Buffer : undefined,
|
||||||
Symbol = context.Symbol,
|
Symbol = context.Symbol,
|
||||||
Uint8Array = context.Uint8Array,
|
Uint8Array = context.Uint8Array,
|
||||||
defineProperty = Object.defineProperty,
|
allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
|
||||||
getPrototype = overArg(Object.getPrototypeOf, Object),
|
getPrototype = overArg(Object.getPrototypeOf, Object),
|
||||||
iteratorSymbol = Symbol ? Symbol.iterator : undefined,
|
iteratorSymbol = Symbol ? Symbol.iterator : undefined,
|
||||||
objectCreate = Object.create,
|
objectCreate = Object.create,
|
||||||
@@ -1476,6 +1478,14 @@
|
|||||||
splice = arrayProto.splice,
|
splice = arrayProto.splice,
|
||||||
spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
|
spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
|
||||||
|
|
||||||
|
var defineProperty = (function() {
|
||||||
|
try {
|
||||||
|
var func = getNative(Object, 'defineProperty');
|
||||||
|
func({}, '', {});
|
||||||
|
return func;
|
||||||
|
} catch (e) {}
|
||||||
|
}());
|
||||||
|
|
||||||
/** Mocked built-ins. */
|
/** Mocked built-ins. */
|
||||||
var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
|
var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
|
||||||
ctxNow = Date && Date.now !== root.Date.now && Date.now,
|
ctxNow = Date && Date.now !== root.Date.now && Date.now,
|
||||||
@@ -1502,8 +1512,7 @@
|
|||||||
Promise = getNative(context, 'Promise'),
|
Promise = getNative(context, 'Promise'),
|
||||||
Set = getNative(context, 'Set'),
|
Set = getNative(context, 'Set'),
|
||||||
WeakMap = getNative(context, 'WeakMap'),
|
WeakMap = getNative(context, 'WeakMap'),
|
||||||
nativeCreate = getNative(Object, 'create'),
|
nativeCreate = getNative(Object, 'create');
|
||||||
nativeDefineProperty = getNative(Object, 'defineProperty');
|
|
||||||
|
|
||||||
/** Used to store function metadata. */
|
/** Used to store function metadata. */
|
||||||
var metaMap = WeakMap && new WeakMap;
|
var metaMap = WeakMap && new WeakMap;
|
||||||
@@ -1654,6 +1663,30 @@
|
|||||||
return new LodashWrapper(value);
|
return new LodashWrapper(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base implementation of `_.create` without support for assigning
|
||||||
|
* properties to the created object.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Object} proto The object to inherit from.
|
||||||
|
* @returns {Object} Returns the new object.
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
}());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The function whose prototype chain sequence wrappers inherit from.
|
* The function whose prototype chain sequence wrappers inherit from.
|
||||||
*
|
*
|
||||||
@@ -2374,8 +2407,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialized version of `_.sample` for arrays without support for iteratee
|
* A specialized version of `_.sample` for arrays.
|
||||||
* shorthands.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to sample.
|
* @param {Array} array The array to sample.
|
||||||
@@ -2395,9 +2427,7 @@
|
|||||||
* @returns {Array} Returns the random elements.
|
* @returns {Array} Returns the random elements.
|
||||||
*/
|
*/
|
||||||
function arraySampleSize(array, n) {
|
function arraySampleSize(array, n) {
|
||||||
var result = arrayShuffle(array);
|
return shuffleSelf(copyArray(array), n);
|
||||||
result.length = baseClamp(n, 0, result.length);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2440,7 +2470,7 @@
|
|||||||
*/
|
*/
|
||||||
function assignMergeValue(object, key, value) {
|
function assignMergeValue(object, key, value) {
|
||||||
if ((value !== undefined && !eq(object[key], value)) ||
|
if ((value !== undefined && !eq(object[key], value)) ||
|
||||||
(typeof key == 'number' && value === undefined && !(key in object))) {
|
(value === undefined && !(key in object))) {
|
||||||
baseAssignValue(object, key, value);
|
baseAssignValue(object, key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2687,18 +2717,6 @@
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The base implementation of `_.create` without support for assigning
|
|
||||||
* properties to the created object.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {Object} prototype The object to inherit from.
|
|
||||||
* @returns {Object} Returns the new object.
|
|
||||||
*/
|
|
||||||
function baseCreate(proto) {
|
|
||||||
return isObject(proto) ? objectCreate(proto) : {};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.delay` and `_.defer` which accepts `args`
|
* The base implementation of `_.delay` and `_.defer` which accepts `args`
|
||||||
* to provide to `func`.
|
* to provide to `func`.
|
||||||
@@ -3261,6 +3279,13 @@
|
|||||||
othIsObj = othTag == objectTag,
|
othIsObj = othTag == objectTag,
|
||||||
isSameTag = objTag == othTag;
|
isSameTag = objTag == othTag;
|
||||||
|
|
||||||
|
if (isSameTag && isBuffer(object)) {
|
||||||
|
if (!isBuffer(other)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
objIsArr = true;
|
||||||
|
objIsObj = false;
|
||||||
|
}
|
||||||
if (isSameTag && !objIsObj) {
|
if (isSameTag && !objIsObj) {
|
||||||
stack || (stack = new Stack);
|
stack || (stack = new Stack);
|
||||||
return (objIsArr || isTypedArray(object))
|
return (objIsArr || isTypedArray(object))
|
||||||
@@ -3606,29 +3631,32 @@
|
|||||||
var isCommon = newValue === undefined;
|
var isCommon = newValue === undefined;
|
||||||
|
|
||||||
if (isCommon) {
|
if (isCommon) {
|
||||||
|
var isArr = isArray(srcValue),
|
||||||
|
isTyped = !isArr && isTypedArray(srcValue);
|
||||||
|
|
||||||
newValue = srcValue;
|
newValue = srcValue;
|
||||||
if (isArray(srcValue) || isTypedArray(srcValue)) {
|
if (isArr || isTyped) {
|
||||||
if (isArray(objValue)) {
|
if (isArray(objValue)) {
|
||||||
newValue = objValue;
|
newValue = objValue;
|
||||||
}
|
}
|
||||||
else if (isArrayLikeObject(objValue)) {
|
else if (isArrayLikeObject(objValue)) {
|
||||||
newValue = copyArray(objValue);
|
newValue = copyArray(objValue);
|
||||||
}
|
}
|
||||||
else {
|
else if (isTyped) {
|
||||||
isCommon = false;
|
isCommon = false;
|
||||||
newValue = baseClone(srcValue, true);
|
newValue = cloneTypedArray(srcValue, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
newValue = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
||||||
|
newValue = objValue;
|
||||||
if (isArguments(objValue)) {
|
if (isArguments(objValue)) {
|
||||||
newValue = toPlainObject(objValue);
|
newValue = toPlainObject(objValue);
|
||||||
}
|
}
|
||||||
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
||||||
isCommon = false;
|
newValue = initCloneObject(srcValue);
|
||||||
newValue = baseClone(srcValue, true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
newValue = objValue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -3890,6 +3918,29 @@
|
|||||||
return setToString(overRest(func, start, identity), func + '');
|
return setToString(overRest(func, start, identity), func + '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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) {
|
||||||
|
return shuffleSelf(values(collection), n);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.set`.
|
* The base implementation of `_.set`.
|
||||||
*
|
*
|
||||||
@@ -3951,8 +4002,8 @@
|
|||||||
* @param {Function} string The `toString` result.
|
* @param {Function} string The `toString` result.
|
||||||
* @returns {Function} Returns `func`.
|
* @returns {Function} Returns `func`.
|
||||||
*/
|
*/
|
||||||
var baseSetToString = !nativeDefineProperty ? identity : function(func, string) {
|
var baseSetToString = !defineProperty ? identity : function(func, string) {
|
||||||
return nativeDefineProperty(func, 'toString', {
|
return defineProperty(func, 'toString', {
|
||||||
'configurable': true,
|
'configurable': true,
|
||||||
'enumerable': false,
|
'enumerable': false,
|
||||||
'value': constant(string),
|
'value': constant(string),
|
||||||
@@ -3960,6 +4011,17 @@
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.slice` without an iteratee call guard.
|
* The base implementation of `_.slice` without an iteratee call guard.
|
||||||
*
|
*
|
||||||
@@ -4422,7 +4484,9 @@
|
|||||||
if (isDeep) {
|
if (isDeep) {
|
||||||
return buffer.slice();
|
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);
|
buffer.copy(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -6534,24 +6598,27 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialized version of `arrayShuffle` which mutates `array`.
|
* A specialized version of `_.shuffle` which mutates and sets the size of `array`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to shuffle.
|
* @param {Array} array The array to shuffle.
|
||||||
|
* @param {number} [size=array.length] The size of `array`.
|
||||||
* @returns {Array} Returns `array`.
|
* @returns {Array} Returns `array`.
|
||||||
*/
|
*/
|
||||||
function shuffleSelf(array) {
|
function shuffleSelf(array, size) {
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = array.length,
|
length = array.length,
|
||||||
lastIndex = length - 1;
|
lastIndex = length - 1;
|
||||||
|
|
||||||
while (++index < length) {
|
size = size === undefined ? length : baseClamp(size, 0, length);
|
||||||
|
while (++index < size) {
|
||||||
var rand = baseRandom(index, lastIndex),
|
var rand = baseRandom(index, lastIndex),
|
||||||
value = array[rand];
|
value = array[rand];
|
||||||
|
|
||||||
array[rand] = array[index];
|
array[rand] = array[index];
|
||||||
array[index] = value;
|
array[index] = value;
|
||||||
}
|
}
|
||||||
|
array.length = size;
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9629,7 +9696,8 @@
|
|||||||
* // => 2
|
* // => 2
|
||||||
*/
|
*/
|
||||||
function sample(collection) {
|
function sample(collection) {
|
||||||
return arraySample(isArrayLike(collection) ? collection : values(collection));
|
var func = isArray(collection) ? arraySample : baseSample;
|
||||||
|
return func(collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -9658,7 +9726,8 @@
|
|||||||
} else {
|
} else {
|
||||||
n = toInteger(n);
|
n = toInteger(n);
|
||||||
}
|
}
|
||||||
return arraySampleSize(isArrayLike(collection) ? collection : values(collection), n);
|
var func = isArray(collection) ? arraySampleSize : baseSampleSize;
|
||||||
|
return func(collection, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -9677,10 +9746,8 @@
|
|||||||
* // => [4, 1, 3, 2]
|
* // => [4, 1, 3, 2]
|
||||||
*/
|
*/
|
||||||
function shuffle(collection) {
|
function shuffle(collection) {
|
||||||
return shuffleSelf(isArrayLike(collection)
|
var func = isArray(collection) ? arrayShuffle : baseShuffle;
|
||||||
? copyArray(collection)
|
return func(collection);
|
||||||
: values(collection)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11506,7 +11573,7 @@
|
|||||||
// The use of `Object#toString` avoids issues with the `typeof` operator
|
// 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 8-9 which returns 'object' for typed array and other constructors.
|
||||||
var tag = isObject(value) ? objectToString.call(value) : '';
|
var tag = isObject(value) ? objectToString.call(value) : '';
|
||||||
return tag == funcTag || tag == genTag;
|
return tag == funcTag || tag == genTag || tag == proxyTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11779,7 +11846,7 @@
|
|||||||
*/
|
*/
|
||||||
function isNative(value) {
|
function isNative(value) {
|
||||||
if (isMaskable(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);
|
return baseIsNative(value);
|
||||||
}
|
}
|
||||||
@@ -14272,7 +14339,7 @@
|
|||||||
} else if (radix) {
|
} else if (radix) {
|
||||||
radix = +radix;
|
radix = +radix;
|
||||||
}
|
}
|
||||||
return nativeParseInt(toString(string), radix || 0);
|
return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
define(['./_MapCache'], function(MapCache) {
|
define(['./_MapCache'], function(MapCache) {
|
||||||
|
|
||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Error message constants. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
define([], function() {
|
define([], function() {
|
||||||
|
|
||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Error message constants. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "lodash-amd",
|
"name": "lodash-amd",
|
||||||
"version": "4.16.1",
|
"version": "4.16.3",
|
||||||
"description": "Lodash exported as AMD modules.",
|
"description": "Lodash exported as AMD modules.",
|
||||||
"keywords": "amd, modules, stdlib, util",
|
"keywords": "amd, modules, stdlib, util",
|
||||||
"homepage": "https://lodash.com/custom-builds",
|
"homepage": "https://lodash.com/custom-builds",
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
define(['./_root', './toString'], function(root, toString) {
|
define(['./_root', './toString'], function(root, toString) {
|
||||||
|
|
||||||
|
/** Used to match leading and trailing whitespace. */
|
||||||
|
var reTrimStart = /^\s+/;
|
||||||
|
|
||||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||||
var nativeParseInt = root.parseInt;
|
var nativeParseInt = root.parseInt;
|
||||||
|
|
||||||
@@ -33,7 +36,7 @@ define(['./_root', './toString'], function(root, toString) {
|
|||||||
} else if (radix) {
|
} else if (radix) {
|
||||||
radix = +radix;
|
radix = +radix;
|
||||||
}
|
}
|
||||||
return nativeParseInt(toString(string), radix || 0);
|
return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return parseInt;
|
return parseInt;
|
||||||
|
|||||||
2
rest.js
2
rest.js
@@ -3,7 +3,7 @@ define(['./_baseRest', './toInteger'], function(baseRest, toInteger) {
|
|||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
|
|
||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Error message constants. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./_arraySample', './isArrayLike', './values'], function(arraySample, isArrayLike, values) {
|
define(['./_arraySample', './_baseSample', './isArray'], function(arraySample, baseSample, isArray) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a random element from `collection`.
|
* Gets a random element from `collection`.
|
||||||
@@ -15,7 +15,8 @@ define(['./_arraySample', './isArrayLike', './values'], function(arraySample, is
|
|||||||
* // => 2
|
* // => 2
|
||||||
*/
|
*/
|
||||||
function sample(collection) {
|
function sample(collection) {
|
||||||
return arraySample(isArrayLike(collection) ? collection : values(collection));
|
var func = isArray(collection) ? arraySample : baseSample;
|
||||||
|
return func(collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sample;
|
return sample;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./_arraySampleSize', './isArrayLike', './_isIterateeCall', './toInteger', './values'], function(arraySampleSize, isArrayLike, isIterateeCall, toInteger, values) {
|
define(['./_arraySampleSize', './_baseSampleSize', './isArray', './_isIterateeCall', './toInteger'], function(arraySampleSize, baseSampleSize, isArray, isIterateeCall, toInteger) {
|
||||||
|
|
||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
@@ -29,7 +29,8 @@ define(['./_arraySampleSize', './isArrayLike', './_isIterateeCall', './toInteger
|
|||||||
} else {
|
} else {
|
||||||
n = toInteger(n);
|
n = toInteger(n);
|
||||||
}
|
}
|
||||||
return arraySampleSize(isArrayLike(collection) ? collection : values(collection), n);
|
var func = isArray(collection) ? arraySampleSize : baseSampleSize;
|
||||||
|
return func(collection, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sampleSize;
|
return sampleSize;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./_copyArray', './isArrayLike', './_shuffleSelf', './values'], function(copyArray, isArrayLike, shuffleSelf, values) {
|
define(['./_arrayShuffle', './_baseShuffle', './isArray'], function(arrayShuffle, baseShuffle, isArray) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an array of shuffled values, using a version of the
|
* Creates an array of shuffled values, using a version of the
|
||||||
@@ -16,10 +16,8 @@ define(['./_copyArray', './isArrayLike', './_shuffleSelf', './values'], function
|
|||||||
* // => [4, 1, 3, 2]
|
* // => [4, 1, 3, 2]
|
||||||
*/
|
*/
|
||||||
function shuffle(collection) {
|
function shuffle(collection) {
|
||||||
return shuffleSelf(isArrayLike(collection)
|
var func = isArray(collection) ? arrayShuffle : baseShuffle;
|
||||||
? copyArray(collection)
|
return func(collection);
|
||||||
: values(collection)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return shuffle;
|
return shuffle;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ define(['./_apply', './_arrayPush', './_baseRest', './_castSlice', './toInteger'
|
|||||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||||
var undefined;
|
var undefined;
|
||||||
|
|
||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Error message constants. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
define(['./debounce', './isObject'], function(debounce, isObject) {
|
define(['./debounce', './isObject'], function(debounce, isObject) {
|
||||||
|
|
||||||
/** Used as the `TypeError` message for "Functions" methods. */
|
/** Error message constants. */
|
||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user