mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 22:47:50 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae51b52aa1 | ||
|
|
ce259221bd | ||
|
|
3514f50902 |
33
LICENSE
33
LICENSE
@@ -1,22 +1,23 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
|
||||
Based on Underscore.js, copyright 2009-2016 Jeremy Ashkenas,
|
||||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# lodash-amd v4.2.1
|
||||
# lodash-amd v4.5.0
|
||||
|
||||
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.2.1-amd) for more details.
|
||||
See the [package source](https://github.com/lodash/lodash/tree/4.5.0-amd) for more details.
|
||||
|
||||
1
_Hash.js
1
_Hash.js
@@ -7,6 +7,7 @@ define(['./_nativeCreate'], function(nativeCreate) {
|
||||
* Creates an hash object.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @returns {Object} Returns the new hash object.
|
||||
*/
|
||||
function Hash() {}
|
||||
|
||||
@@ -7,6 +7,7 @@ define(['./_baseCreate', './_baseLodash'], function(baseCreate, baseLodash) {
|
||||
* Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {*} value The value to wrap.
|
||||
*/
|
||||
function LazyWrapper(value) {
|
||||
|
||||
@@ -4,6 +4,7 @@ define(['./_mapClear', './_mapDelete', './_mapGet', './_mapHas', './_mapSet'], f
|
||||
* Creates a map cache object to store key-value pairs.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {Array} [values] The values to cache.
|
||||
*/
|
||||
function MapCache(values) {
|
||||
|
||||
@@ -5,6 +5,7 @@ define(['./_MapCache', './_cachePush'], function(MapCache, cachePush) {
|
||||
* Creates a set cache object to store unique values.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {Array} [values] The values to cache.
|
||||
*/
|
||||
function SetCache(values) {
|
||||
|
||||
@@ -4,6 +4,7 @@ define(['./_stackClear', './_stackDelete', './_stackGet', './_stackHas', './_sta
|
||||
* Creates a stack cache object to store key-value pairs.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {Array} [values] The values to cache.
|
||||
*/
|
||||
function Stack(values) {
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
define(['./isArrayLikeObject'], function(isArrayLikeObject) {
|
||||
|
||||
/**
|
||||
* Converts `value` to an array-like object if it's not one.
|
||||
* Casts `value` to an empty array if it's not an array like object.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to process.
|
||||
* @param {*} value The value to inspect.
|
||||
* @returns {Array} Returns the array-like object.
|
||||
*/
|
||||
function toArrayLikeObject(value) {
|
||||
function baseCastArrayLikeObject(value) {
|
||||
return isArrayLikeObject(value) ? value : [];
|
||||
}
|
||||
|
||||
return toArrayLikeObject;
|
||||
return baseCastArrayLikeObject;
|
||||
});
|
||||
15
_baseCastFunction.js
Normal file
15
_baseCastFunction.js
Normal file
@@ -0,0 +1,15 @@
|
||||
define(['./identity'], function(identity) {
|
||||
|
||||
/**
|
||||
* Casts `value` to `identity` if it's not a function.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to inspect.
|
||||
* @returns {Array} Returns the array-like object.
|
||||
*/
|
||||
function baseCastFunction(value) {
|
||||
return typeof value == 'function' ? value : identity;
|
||||
}
|
||||
|
||||
return baseCastFunction;
|
||||
});
|
||||
15
_baseCastPath.js
Normal file
15
_baseCastPath.js
Normal file
@@ -0,0 +1,15 @@
|
||||
define(['./isArray', './_stringToPath'], function(isArray, stringToPath) {
|
||||
|
||||
/**
|
||||
* Casts `value` to a path array if it's not one.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to inspect.
|
||||
* @returns {Array} Returns the cast property path array.
|
||||
*/
|
||||
function baseCastPath(value) {
|
||||
return isArray(value) ? value : stringToPath(value);
|
||||
}
|
||||
|
||||
return baseCastPath;
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_baseForOwn', './_copyArray', './_copySymbols', './_getTag', './_initCloneArray', './_initCloneByTag', './_initCloneObject', './isArray', './_isHostObject', './isObject'], function(Stack, arrayEach, assignValue, baseAssign, baseForOwn, copyArray, copySymbols, getTag, initCloneArray, initCloneByTag, initCloneObject, isArray, isHostObject, isObject) {
|
||||
define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_baseForOwn', './_cloneBuffer', './_copyArray', './_copySymbols', './_getTag', './_initCloneArray', './_initCloneByTag', './_initCloneObject', './isArray', './isBuffer', './_isHostObject', './isObject'], function(Stack, arrayEach, assignValue, baseAssign, baseForOwn, cloneBuffer, copyArray, copySymbols, getTag, initCloneArray, initCloneByTag, initCloneObject, isArray, isBuffer, isHostObject, isObject) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -81,6 +81,9 @@ define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_baseF
|
||||
var tag = getTag(value),
|
||||
isFunc = tag == funcTag || tag == genTag;
|
||||
|
||||
if (isBuffer(value)) {
|
||||
return cloneBuffer(value, isDeep);
|
||||
}
|
||||
if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
|
||||
if (isHostObject(value)) {
|
||||
return object ? value : {};
|
||||
@@ -90,9 +93,10 @@ define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_baseF
|
||||
return copySymbols(value, baseAssign(result, value));
|
||||
}
|
||||
} else {
|
||||
return cloneableTags[tag]
|
||||
? initCloneByTag(value, tag, isDeep)
|
||||
: (object ? value : {});
|
||||
if (!cloneableTags[tag]) {
|
||||
return object ? value : {};
|
||||
}
|
||||
result = initCloneByTag(value, tag, isDeep);
|
||||
}
|
||||
}
|
||||
// Check for circular references and return its corresponding clone.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* The base implementation of `_.create` without support for assigning
|
||||
@@ -11,17 +11,9 @@ define(['./isObject'], function(isObject) {
|
||||
* @param {Object} prototype The object to inherit from.
|
||||
* @returns {Object} Returns the new object.
|
||||
*/
|
||||
var baseCreate = (function() {
|
||||
function object() {}
|
||||
return function(prototype) {
|
||||
if (isObject(prototype)) {
|
||||
object.prototype = prototype;
|
||||
var result = new object;
|
||||
object.prototype = undefined;
|
||||
}
|
||||
return result || {};
|
||||
};
|
||||
}());
|
||||
function baseCreate(proto) {
|
||||
return isObject(proto) ? objectCreate(proto) : {};
|
||||
}
|
||||
|
||||
return baseCreate;
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ define([], function() {
|
||||
* @private
|
||||
* @param {Function} func The function to delay.
|
||||
* @param {number} wait The number of milliseconds to delay invocation.
|
||||
* @param {Object} args The arguments provide to `func`.
|
||||
* @param {Object} args The arguments to provide to `func`.
|
||||
* @returns {number} Returns the timer id.
|
||||
*/
|
||||
function baseDelay(func, wait, args) {
|
||||
|
||||
@@ -5,12 +5,12 @@ define(['./_arrayPush', './isArguments', './isArray', './isArrayLikeObject'], fu
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to flatten.
|
||||
* @param {boolean} [isDeep] Specify a deep flatten.
|
||||
* @param {number} depth The maximum recursion depth.
|
||||
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
|
||||
* @param {Array} [result=[]] The initial result value.
|
||||
* @returns {Array} Returns the new flattened array.
|
||||
*/
|
||||
function baseFlatten(array, isDeep, isStrict, result) {
|
||||
function baseFlatten(array, depth, isStrict, result) {
|
||||
result || (result = []);
|
||||
|
||||
var index = -1,
|
||||
@@ -18,11 +18,11 @@ define(['./_arrayPush', './isArguments', './isArray', './isArrayLikeObject'], fu
|
||||
|
||||
while (++index < length) {
|
||||
var value = array[index];
|
||||
if (isArrayLikeObject(value) &&
|
||||
if (depth > 0 && isArrayLikeObject(value) &&
|
||||
(isStrict || isArray(value) || isArguments(value))) {
|
||||
if (isDeep) {
|
||||
if (depth > 1) {
|
||||
// Recursively flatten arrays (susceptible to call stack limits).
|
||||
baseFlatten(value, isDeep, isStrict, result);
|
||||
baseFlatten(value, depth - 1, isStrict, result);
|
||||
} else {
|
||||
arrayPush(result, value);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ define(['./_arrayFilter', './isFunction'], function(arrayFilter, isFunction) {
|
||||
|
||||
/**
|
||||
* The base implementation of `_.functions` which creates an array of
|
||||
* `object` function property names filtered from those provided.
|
||||
* `object` function property names filtered from `props`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to inspect.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_baseToPath', './_isKey'], function(baseToPath, isKey) {
|
||||
define(['./_baseCastPath', './_isKey'], function(baseCastPath, isKey) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -12,7 +12,7 @@ define(['./_baseToPath', './_isKey'], function(baseToPath, isKey) {
|
||||
* @returns {*} Returns the resolved value.
|
||||
*/
|
||||
function baseGet(object, path) {
|
||||
path = isKey(path, object) ? [path + ''] : baseToPath(path);
|
||||
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
|
||||
|
||||
var index = 0,
|
||||
length = path.length;
|
||||
|
||||
@@ -40,11 +40,17 @@ define(['./_SetCache', './_arrayIncludes', './_arrayIncludesWith', './_arrayMap'
|
||||
var value = array[index],
|
||||
computed = iteratee ? iteratee(value) : value;
|
||||
|
||||
if (!(seen ? cacheHas(seen, computed) : includes(result, computed, comparator))) {
|
||||
if (!(seen
|
||||
? cacheHas(seen, computed)
|
||||
: includes(result, computed, comparator)
|
||||
)) {
|
||||
var othIndex = othLength;
|
||||
while (--othIndex) {
|
||||
var cache = caches[othIndex];
|
||||
if (!(cache ? cacheHas(cache, computed) : includes(arrays[othIndex], computed, comparator))) {
|
||||
if (!(cache
|
||||
? cacheHas(cache, computed)
|
||||
: includes(arrays[othIndex], computed, comparator))
|
||||
) {
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_apply', './_baseToPath', './_isKey', './last', './_parent'], function(apply, baseToPath, isKey, last, parent) {
|
||||
define(['./_apply', './_baseCastPath', './_isKey', './last', './_parent'], function(apply, baseCastPath, isKey, last, parent) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -15,7 +15,7 @@ define(['./_apply', './_baseToPath', './_isKey', './last', './_parent'], functio
|
||||
*/
|
||||
function baseInvoke(object, path, args) {
|
||||
if (!isKey(path, object)) {
|
||||
path = baseToPath(path);
|
||||
path = baseCastPath(path);
|
||||
object = parent(object, path);
|
||||
path = last(path);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ define([], function() {
|
||||
* property of prototypes or treat sparse arrays as dense.
|
||||
*
|
||||
* @private
|
||||
* @type Function
|
||||
* @param {Object} object The object to query.
|
||||
* @returns {Array} Returns the array of property names.
|
||||
*/
|
||||
|
||||
@@ -17,7 +17,10 @@ define(['./_Stack', './_arrayEach', './_assignMergeValue', './_baseMergeDeep', '
|
||||
if (object === source) {
|
||||
return;
|
||||
}
|
||||
var props = (isArray(source) || isTypedArray(source)) ? undefined : keysIn(source);
|
||||
var props = (isArray(source) || isTypedArray(source))
|
||||
? undefined
|
||||
: keysIn(source);
|
||||
|
||||
arrayEach(props || source, function(srcValue, key) {
|
||||
if (props) {
|
||||
key = srcValue;
|
||||
@@ -28,7 +31,10 @@ define(['./_Stack', './_arrayEach', './_assignMergeValue', './_baseMergeDeep', '
|
||||
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
||||
}
|
||||
else {
|
||||
var newValue = customizer ? customizer(object[key], srcValue, (key + ''), object, source, stack) : undefined;
|
||||
var newValue = customizer
|
||||
? customizer(object[key], srcValue, (key + ''), object, source, stack)
|
||||
: undefined;
|
||||
|
||||
if (newValue === undefined) {
|
||||
newValue = srcValue;
|
||||
}
|
||||
|
||||
@@ -26,21 +26,24 @@ define(['./_assignMergeValue', './_baseClone', './_copyArray', './isArguments',
|
||||
assignMergeValue(object, key, stacked);
|
||||
return;
|
||||
}
|
||||
var newValue = customizer ? customizer(objValue, srcValue, (key + ''), object, source, stack) : undefined,
|
||||
isCommon = newValue === undefined;
|
||||
var newValue = customizer
|
||||
? customizer(objValue, srcValue, (key + ''), object, source, stack)
|
||||
: undefined;
|
||||
|
||||
var isCommon = newValue === undefined;
|
||||
|
||||
if (isCommon) {
|
||||
newValue = srcValue;
|
||||
if (isArray(srcValue) || isTypedArray(srcValue)) {
|
||||
if (isArray(objValue)) {
|
||||
newValue = srcIndex ? copyArray(objValue) : objValue;
|
||||
newValue = objValue;
|
||||
}
|
||||
else if (isArrayLikeObject(objValue)) {
|
||||
newValue = copyArray(objValue);
|
||||
}
|
||||
else {
|
||||
isCommon = false;
|
||||
newValue = baseClone(srcValue);
|
||||
newValue = baseClone(srcValue, true);
|
||||
}
|
||||
}
|
||||
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
||||
@@ -49,10 +52,10 @@ define(['./_assignMergeValue', './_baseClone', './_copyArray', './isArguments',
|
||||
}
|
||||
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
||||
isCommon = false;
|
||||
newValue = baseClone(srcValue);
|
||||
newValue = baseClone(srcValue, true);
|
||||
}
|
||||
else {
|
||||
newValue = srcIndex ? baseClone(objValue) : objValue;
|
||||
newValue = objValue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_baseToPath', './_isIndex', './_isKey', './last', './_parent'], function(baseToPath, isIndex, isKey, last, parent) {
|
||||
define(['./_baseCastPath', './_isIndex', './_isKey', './last', './_parent'], function(baseCastPath, isIndex, isKey, last, parent) {
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var arrayProto = Array.prototype;
|
||||
@@ -27,7 +27,7 @@ define(['./_baseToPath', './_isIndex', './_isKey', './last', './_parent'], funct
|
||||
splice.call(array, index, 1);
|
||||
}
|
||||
else if (!isKey(index, array)) {
|
||||
var path = baseToPath(index),
|
||||
var path = baseCastPath(index),
|
||||
object = parent(array, path);
|
||||
|
||||
if (object != null) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_assignValue', './_baseToPath', './_isIndex', './_isKey', './isObject'], function(assignValue, baseToPath, isIndex, isKey, isObject) {
|
||||
define(['./_assignValue', './_baseCastPath', './_isIndex', './_isKey', './isObject'], function(assignValue, baseCastPath, isIndex, isKey, isObject) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -14,7 +14,7 @@ define(['./_assignValue', './_baseToPath', './_isIndex', './_isKey', './isObject
|
||||
* @returns {Object} Returns `object`.
|
||||
*/
|
||||
function baseSet(object, path, value, customizer) {
|
||||
path = isKey(path, object) ? [path + ''] : baseToPath(path);
|
||||
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
|
||||
|
||||
var index = -1,
|
||||
length = path.length,
|
||||
@@ -29,7 +29,9 @@ define(['./_assignValue', './_baseToPath', './_isIndex', './_isKey', './isObject
|
||||
var objValue = nested[key];
|
||||
newValue = customizer ? customizer(objValue, key, nested) : undefined;
|
||||
if (newValue === undefined) {
|
||||
newValue = objValue == null ? (isIndex(path[index + 1]) ? [] : {}) : objValue;
|
||||
newValue = objValue == null
|
||||
? (isIndex(path[index + 1]) ? [] : {})
|
||||
: objValue;
|
||||
}
|
||||
}
|
||||
assignValue(nested, key, newValue);
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
define(['./isArray', './_stringToPath'], function(isArray, stringToPath) {
|
||||
|
||||
/**
|
||||
* The base implementation of `_.toPath` which only converts `value` to a
|
||||
* path if it's not one.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to process.
|
||||
* @returns {Array} Returns the property path array.
|
||||
*/
|
||||
function baseToPath(value) {
|
||||
return isArray(value) ? value : stringToPath(value);
|
||||
}
|
||||
|
||||
return baseToPath;
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_baseToPath', './has', './_isKey', './last', './_parent'], function(baseToPath, has, isKey, last, parent) {
|
||||
define(['./_baseCastPath', './has', './_isKey', './last', './_parent'], function(baseCastPath, has, isKey, last, parent) {
|
||||
|
||||
/**
|
||||
* The base implementation of `_.unset`.
|
||||
@@ -9,7 +9,7 @@ define(['./_baseToPath', './has', './_isKey', './last', './_parent'], function(b
|
||||
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
|
||||
*/
|
||||
function baseUnset(object, path) {
|
||||
path = isKey(path, object) ? [path + ''] : baseToPath(path);
|
||||
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
|
||||
object = parent(object, path);
|
||||
var key = last(path);
|
||||
return (object != null && has(object, key)) ? delete object[key] : true;
|
||||
|
||||
20
_cloneArrayBuffer.js
Normal file
20
_cloneArrayBuffer.js
Normal file
@@ -0,0 +1,20 @@
|
||||
define(['./_Uint8Array'], function(Uint8Array) {
|
||||
|
||||
/**
|
||||
* Creates a clone of `arrayBuffer`.
|
||||
*
|
||||
* @private
|
||||
* @param {ArrayBuffer} arrayBuffer The array buffer to clone.
|
||||
* @returns {ArrayBuffer} Returns the cloned array buffer.
|
||||
*/
|
||||
function cloneArrayBuffer(arrayBuffer) {
|
||||
var Ctor = arrayBuffer.constructor,
|
||||
result = new Ctor(arrayBuffer.byteLength),
|
||||
view = new Uint8Array(result);
|
||||
|
||||
view.set(new Uint8Array(arrayBuffer));
|
||||
return result;
|
||||
}
|
||||
|
||||
return cloneArrayBuffer;
|
||||
});
|
||||
@@ -1,18 +1,21 @@
|
||||
define(['./_Uint8Array'], function(Uint8Array) {
|
||||
define([], function() {
|
||||
|
||||
/**
|
||||
* Creates a clone of `buffer`.
|
||||
* Creates a clone of `buffer`.
|
||||
*
|
||||
* @private
|
||||
* @param {ArrayBuffer} buffer The array buffer to clone.
|
||||
* @returns {ArrayBuffer} Returns the cloned array buffer.
|
||||
* @param {Buffer} buffer The buffer to clone.
|
||||
* @param {boolean} [isDeep] Specify a deep clone.
|
||||
* @returns {Buffer} Returns the cloned buffer.
|
||||
*/
|
||||
function cloneBuffer(buffer) {
|
||||
function cloneBuffer(buffer, isDeep) {
|
||||
if (isDeep) {
|
||||
return buffer.slice();
|
||||
}
|
||||
var Ctor = buffer.constructor,
|
||||
result = new Ctor(buffer.byteLength),
|
||||
view = new Uint8Array(result);
|
||||
result = new Ctor(buffer.length);
|
||||
|
||||
view.set(new Uint8Array(buffer));
|
||||
buffer.copy(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_cloneBuffer'], function(cloneBuffer) {
|
||||
define(['./_cloneArrayBuffer'], function(cloneArrayBuffer) {
|
||||
|
||||
/**
|
||||
* Creates a clone of `typedArray`.
|
||||
@@ -9,10 +9,11 @@ define(['./_cloneBuffer'], function(cloneBuffer) {
|
||||
* @returns {Object} Returns the cloned typed array.
|
||||
*/
|
||||
function cloneTypedArray(typedArray, isDeep) {
|
||||
var buffer = typedArray.buffer,
|
||||
var arrayBuffer = typedArray.buffer,
|
||||
buffer = isDeep ? cloneArrayBuffer(arrayBuffer) : arrayBuffer,
|
||||
Ctor = typedArray.constructor;
|
||||
|
||||
return new Ctor(isDeep ? cloneBuffer(buffer) : buffer, typedArray.byteOffset, typedArray.length);
|
||||
return new Ctor(buffer, typedArray.byteOffset, typedArray.length);
|
||||
}
|
||||
|
||||
return cloneTypedArray;
|
||||
|
||||
@@ -18,8 +18,11 @@ define(['./_assignValue'], function(assignValue) {
|
||||
length = props.length;
|
||||
|
||||
while (++index < length) {
|
||||
var key = props[index],
|
||||
newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key];
|
||||
var key = props[index];
|
||||
|
||||
var newValue = customizer
|
||||
? customizer(object[key], source[key], key, object, source)
|
||||
: source[key];
|
||||
|
||||
assignValue(object, key, newValue);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,10 @@ define(['./_isIterateeCall', './rest'], function(isIterateeCall, rest) {
|
||||
customizer = length > 1 ? sources[length - 1] : undefined,
|
||||
guard = length > 2 ? sources[2] : undefined;
|
||||
|
||||
customizer = typeof customizer == 'function' ? (length--, customizer) : undefined;
|
||||
customizer = typeof customizer == 'function'
|
||||
? (length--, customizer)
|
||||
: undefined;
|
||||
|
||||
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
||||
customizer = length < 3 ? undefined : customizer;
|
||||
length = 1;
|
||||
|
||||
@@ -26,8 +26,11 @@ define(['./_stringToArray', './toString'], function(stringToArray, toString) {
|
||||
return function(string) {
|
||||
string = toString(string);
|
||||
|
||||
var strSymbols = reHasComplexSymbol.test(string) ? stringToArray(string) : undefined,
|
||||
chr = strSymbols ? strSymbols[0] : string.charAt(0),
|
||||
var strSymbols = reHasComplexSymbol.test(string)
|
||||
? stringToArray(string)
|
||||
: undefined;
|
||||
|
||||
var chr = strSymbols ? strSymbols[0] : string.charAt(0),
|
||||
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
|
||||
|
||||
return chr[methodName]() + trailing;
|
||||
|
||||
@@ -24,7 +24,7 @@ define(['./_LodashWrapper', './_baseFlatten', './_getData', './_getFuncName', '.
|
||||
*/
|
||||
function createFlow(fromRight) {
|
||||
return rest(function(funcs) {
|
||||
funcs = baseFlatten(funcs);
|
||||
funcs = baseFlatten(funcs, 1);
|
||||
|
||||
var length = funcs.length,
|
||||
index = length,
|
||||
@@ -49,7 +49,10 @@ define(['./_LodashWrapper', './_baseFlatten', './_getData', './_getFuncName', '.
|
||||
var funcName = getFuncName(func),
|
||||
data = funcName == 'wrapper' ? getData(func) : undefined;
|
||||
|
||||
if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) {
|
||||
if (data && isLaziable(data[0]) &&
|
||||
data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) &&
|
||||
!data[4].length && data[9] == 1
|
||||
) {
|
||||
wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
|
||||
} else {
|
||||
wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);
|
||||
@@ -59,7 +62,8 @@ define(['./_LodashWrapper', './_baseFlatten', './_getData', './_getFuncName', '.
|
||||
var args = arguments,
|
||||
value = args[0];
|
||||
|
||||
if (wrapper && args.length == 1 && isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
|
||||
if (wrapper && args.length == 1 &&
|
||||
isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
|
||||
return wrapper.plant(value).value();
|
||||
}
|
||||
var index = 0,
|
||||
|
||||
@@ -57,7 +57,10 @@ define(['./_composeArgs', './_composeArgsRight', './_createCtorWrapper', './_cre
|
||||
|
||||
length -= argsHolders.length;
|
||||
if (length < arity) {
|
||||
return createRecurryWrapper(func, bitmask, createHybridWrapper, placeholder, thisArg, args, argsHolders, argPos, ary, arity - length);
|
||||
return createRecurryWrapper(
|
||||
func, bitmask, createHybridWrapper, placeholder, thisArg, args,
|
||||
argsHolders, argPos, ary, arity - length
|
||||
);
|
||||
}
|
||||
}
|
||||
var thisBinding = isBind ? thisArg : this,
|
||||
|
||||
@@ -9,7 +9,7 @@ define(['./_apply', './_arrayMap', './_baseFlatten', './_baseIteratee', './rest'
|
||||
*/
|
||||
function createOver(arrayFunc) {
|
||||
return rest(function(iteratees) {
|
||||
iteratees = arrayMap(baseFlatten(iteratees), baseIteratee);
|
||||
iteratees = arrayMap(baseFlatten(iteratees, 1), baseIteratee);
|
||||
return rest(function(args) {
|
||||
var thisArg = this;
|
||||
return arrayFunc(iteratees, function(iteratee) {
|
||||
|
||||
@@ -41,9 +41,12 @@ define(['./_copyArray', './_isLaziable', './_setData'], function(copyArray, isLa
|
||||
if (!(bitmask & CURRY_BOUND_FLAG)) {
|
||||
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
|
||||
}
|
||||
var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, arity],
|
||||
result = wrapFunc.apply(undefined, newData);
|
||||
var newData = [
|
||||
func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight,
|
||||
newHoldersRight, newArgPos, ary, arity
|
||||
];
|
||||
|
||||
var result = wrapFunc.apply(undefined, newData);
|
||||
if (isLaziable(func)) {
|
||||
setData(result, newData);
|
||||
}
|
||||
|
||||
@@ -62,8 +62,12 @@ define(['./_baseSetData', './_createBaseWrapper', './_createCurryWrapper', './_c
|
||||
|
||||
partials = holders = undefined;
|
||||
}
|
||||
var data = isBindKey ? undefined : getData(func),
|
||||
newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];
|
||||
var data = isBindKey ? undefined : getData(func);
|
||||
|
||||
var newData = [
|
||||
func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
|
||||
argPos, ary, arity
|
||||
];
|
||||
|
||||
if (data) {
|
||||
mergeData(newData, data);
|
||||
|
||||
25
_getTag.js
25
_getTag.js
@@ -1,9 +1,10 @@
|
||||
define(['./_Map', './_Set'], function(Map, Set) {
|
||||
define(['./_Map', './_Set', './_WeakMap'], function(Map, Set, WeakMap) {
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var mapTag = '[object Map]',
|
||||
objectTag = '[object Object]',
|
||||
setTag = '[object Set]';
|
||||
setTag = '[object Set]',
|
||||
weakMapTag = '[object WeakMap]';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
@@ -17,9 +18,10 @@ define(['./_Map', './_Set'], function(Map, Set) {
|
||||
*/
|
||||
var objectToString = objectProto.toString;
|
||||
|
||||
/** Used to detect maps and sets. */
|
||||
/** Used to detect maps, sets, and weakmaps. */
|
||||
var mapCtorString = Map ? funcToString.call(Map) : '',
|
||||
setCtorString = Set ? funcToString.call(Set) : '';
|
||||
setCtorString = Set ? funcToString.call(Set) : '',
|
||||
weakMapCtorString = WeakMap ? funcToString.call(WeakMap) : '';
|
||||
|
||||
/**
|
||||
* Gets the `toStringTag` of `value`.
|
||||
@@ -32,19 +34,20 @@ define(['./_Map', './_Set'], function(Map, Set) {
|
||||
return objectToString.call(value);
|
||||
}
|
||||
|
||||
// Fallback for IE 11 providing `toStringTag` values for maps and sets.
|
||||
if ((Map && getTag(new Map) != mapTag) || (Set && getTag(new Set) != setTag)) {
|
||||
// Fallback for IE 11 providing `toStringTag` values for maps, sets, and weakmaps.
|
||||
if ((Map && getTag(new Map) != mapTag) ||
|
||||
(Set && getTag(new Set) != setTag) ||
|
||||
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
|
||||
getTag = function(value) {
|
||||
var result = objectToString.call(value),
|
||||
Ctor = result == objectTag ? value.constructor : null,
|
||||
ctorString = typeof Ctor == 'function' ? funcToString.call(Ctor) : '';
|
||||
|
||||
if (ctorString) {
|
||||
if (ctorString == mapCtorString) {
|
||||
return mapTag;
|
||||
}
|
||||
if (ctorString == setCtorString) {
|
||||
return setTag;
|
||||
switch (ctorString) {
|
||||
case mapCtorString: return mapTag;
|
||||
case setCtorString: return setTag;
|
||||
case weakMapCtorString: return weakMapTag;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_baseToPath', './isArguments', './isArray', './_isIndex', './_isKey', './isLength', './isString', './last', './_parent'], function(baseToPath, isArguments, isArray, isIndex, isKey, isLength, isString, last, parent) {
|
||||
define(['./_baseCastPath', './isArguments', './isArray', './_isIndex', './_isKey', './isLength', './isString', './last', './_parent'], function(baseCastPath, isArguments, isArray, isIndex, isKey, isLength, isString, last, parent) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -18,7 +18,7 @@ define(['./_baseToPath', './isArguments', './isArray', './_isIndex', './_isKey',
|
||||
}
|
||||
var result = hasFunc(object, path);
|
||||
if (!result && !isKey(path)) {
|
||||
path = baseToPath(path);
|
||||
path = baseCastPath(path);
|
||||
object = parent(object, path);
|
||||
if (object != null) {
|
||||
path = last(path);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_cloneBuffer', './_cloneMap', './_cloneRegExp', './_cloneSet', './_cloneSymbol', './_cloneTypedArray'], function(cloneBuffer, cloneMap, cloneRegExp, cloneSet, cloneSymbol, cloneTypedArray) {
|
||||
define(['./_cloneArrayBuffer', './_cloneMap', './_cloneRegExp', './_cloneSet', './_cloneSymbol', './_cloneTypedArray'], function(cloneArrayBuffer, cloneMap, cloneRegExp, cloneSet, cloneSymbol, cloneTypedArray) {
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var boolTag = '[object Boolean]',
|
||||
@@ -37,7 +37,7 @@ define(['./_cloneBuffer', './_cloneMap', './_cloneRegExp', './_cloneSet', './_cl
|
||||
var Ctor = object.constructor;
|
||||
switch (tag) {
|
||||
case arrayBufferTag:
|
||||
return cloneBuffer(object);
|
||||
return cloneArrayBuffer(object);
|
||||
|
||||
case boolTag:
|
||||
case dateTag:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
define(['./eq', './isArrayLike', './_isIndex', './isObject'], function(eq, isArrayLike, isIndex, isObject) {
|
||||
|
||||
/**
|
||||
* Checks if the provided arguments are from an iteratee call.
|
||||
* Checks if the given arguments are from an iteratee call.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The potential iteratee value argument.
|
||||
|
||||
@@ -10,7 +10,7 @@ define([], function() {
|
||||
function isKeyable(value) {
|
||||
var type = typeof value;
|
||||
return type == 'number' || type == 'boolean' ||
|
||||
(type == 'string' && value !== '__proto__') || value == null;
|
||||
(type == 'string' && value != '__proto__') || value == null;
|
||||
}
|
||||
|
||||
return isKeyable;
|
||||
|
||||
@@ -34,7 +34,8 @@ define(['./_baseWrapperValue', './_getView', './isArray'], function(baseWrapperV
|
||||
resIndex = 0,
|
||||
takeCount = nativeMin(length, this.__takeCount__);
|
||||
|
||||
if (!isArr || arrLength < LARGE_ARRAY_SIZE || (arrLength == length && takeCount == length)) {
|
||||
if (!isArr || arrLength < LARGE_ARRAY_SIZE ||
|
||||
(arrLength == length && takeCount == length)) {
|
||||
return baseWrapperValue(array, this.__actions__);
|
||||
}
|
||||
var result = [];
|
||||
|
||||
@@ -8,7 +8,11 @@ define(['./_Hash', './_Map'], function(Hash, Map) {
|
||||
* @memberOf MapCache
|
||||
*/
|
||||
function mapClear() {
|
||||
this.__data__ = { 'hash': new Hash, 'map': Map ? new Map : [], 'string': new Hash };
|
||||
this.__data__ = {
|
||||
'hash': new Hash,
|
||||
'map': Map ? new Map : [],
|
||||
'string': new Hash
|
||||
};
|
||||
}
|
||||
|
||||
return mapClear;
|
||||
|
||||
15
_root.js
15
_root.js
@@ -1,5 +1,8 @@
|
||||
define(['./_checkGlobal'], function(checkGlobal) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/** Used to determine if values are of the language type `Object`. */
|
||||
var objectTypes = {
|
||||
'function': true,
|
||||
@@ -7,10 +10,14 @@ define(['./_checkGlobal'], function(checkGlobal) {
|
||||
};
|
||||
|
||||
/** Detect free variable `exports`. */
|
||||
var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null;
|
||||
var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
|
||||
? exports
|
||||
: undefined;
|
||||
|
||||
/** Detect free variable `module`. */
|
||||
var freeModule = (objectTypes[typeof module] && module && !module.nodeType) ? module : null;
|
||||
var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
|
||||
? module
|
||||
: undefined;
|
||||
|
||||
/** Detect free variable `global` from Node.js. */
|
||||
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
|
||||
@@ -30,7 +37,9 @@ define(['./_checkGlobal'], function(checkGlobal) {
|
||||
* The `this` value is used if it's the global object to avoid Greasemonkey's
|
||||
* restricted `window` object, otherwise the `window` object is used.
|
||||
*/
|
||||
var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')();
|
||||
var root = freeGlobal ||
|
||||
((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) ||
|
||||
freeSelf || thisGlobal || Function('return this')();
|
||||
|
||||
return root;
|
||||
});
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
define(['./identity'], function(identity) {
|
||||
|
||||
/**
|
||||
* Converts `value` to a function if it's not one.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to process.
|
||||
* @returns {Function} Returns the function.
|
||||
*/
|
||||
function toFunction(value) {
|
||||
return typeof value == 'function' ? value : identity;
|
||||
}
|
||||
|
||||
return toFunction;
|
||||
});
|
||||
3
add.js
3
add.js
@@ -19,6 +19,9 @@ define([], function() {
|
||||
*/
|
||||
function add(augend, addend) {
|
||||
var result;
|
||||
if (augend === undefined && addend === undefined) {
|
||||
return 0;
|
||||
}
|
||||
if (augend !== undefined) {
|
||||
result = augend;
|
||||
}
|
||||
|
||||
3
array.js
3
array.js
@@ -1,4 +1,4 @@
|
||||
define(['./chunk', './compact', './concat', './difference', './differenceBy', './differenceWith', './drop', './dropRight', './dropRightWhile', './dropWhile', './fill', './findIndex', './findLastIndex', './flatten', './flattenDeep', './fromPairs', './head', './indexOf', './initial', './intersection', './intersectionBy', './intersectionWith', './join', './last', './lastIndexOf', './pull', './pullAll', './pullAllBy', './pullAt', './remove', './reverse', './slice', './sortedIndex', './sortedIndexBy', './sortedIndexOf', './sortedLastIndex', './sortedLastIndexBy', './sortedLastIndexOf', './sortedUniq', './sortedUniqBy', './tail', './take', './takeRight', './takeRightWhile', './takeWhile', './union', './unionBy', './unionWith', './uniq', './uniqBy', './uniqWith', './unzip', './unzipWith', './without', './xor', './xorBy', './xorWith', './zip', './zipObject', './zipObjectDeep', './zipWith'], function(chunk, compact, concat, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, fill, findIndex, findLastIndex, flatten, flattenDeep, fromPairs, head, indexOf, initial, intersection, intersectionBy, intersectionWith, join, last, lastIndexOf, pull, pullAll, pullAllBy, pullAt, remove, reverse, slice, sortedIndex, sortedIndexBy, sortedIndexOf, sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf, sortedUniq, sortedUniqBy, tail, take, takeRight, takeRightWhile, takeWhile, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, without, xor, xorBy, xorWith, zip, zipObject, zipObjectDeep, zipWith) {
|
||||
define(['./chunk', './compact', './concat', './difference', './differenceBy', './differenceWith', './drop', './dropRight', './dropRightWhile', './dropWhile', './fill', './findIndex', './findLastIndex', './flatten', './flattenDeep', './flattenDepth', './fromPairs', './head', './indexOf', './initial', './intersection', './intersectionBy', './intersectionWith', './join', './last', './lastIndexOf', './pull', './pullAll', './pullAllBy', './pullAt', './remove', './reverse', './slice', './sortedIndex', './sortedIndexBy', './sortedIndexOf', './sortedLastIndex', './sortedLastIndexBy', './sortedLastIndexOf', './sortedUniq', './sortedUniqBy', './tail', './take', './takeRight', './takeRightWhile', './takeWhile', './union', './unionBy', './unionWith', './uniq', './uniqBy', './uniqWith', './unzip', './unzipWith', './without', './xor', './xorBy', './xorWith', './zip', './zipObject', './zipObjectDeep', './zipWith'], function(chunk, compact, concat, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, fill, findIndex, findLastIndex, flatten, flattenDeep, flattenDepth, fromPairs, head, indexOf, initial, intersection, intersectionBy, intersectionWith, join, last, lastIndexOf, pull, pullAll, pullAllBy, pullAt, remove, reverse, slice, sortedIndex, sortedIndexBy, sortedIndexOf, sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf, sortedUniq, sortedUniqBy, tail, take, takeRight, takeRightWhile, takeWhile, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, without, xor, xorBy, xorWith, zip, zipObject, zipObjectDeep, zipWith) {
|
||||
return {
|
||||
'chunk': chunk,
|
||||
'compact': compact,
|
||||
@@ -15,6 +15,7 @@ define(['./chunk', './compact', './concat', './difference', './differenceBy', '.
|
||||
'findLastIndex': findLastIndex,
|
||||
'flatten': flatten,
|
||||
'flattenDeep': flattenDeep,
|
||||
'flattenDepth': flattenDepth,
|
||||
'fromPairs': fromPairs,
|
||||
'head': head,
|
||||
'indexOf': indexOf,
|
||||
|
||||
2
at.js
2
at.js
@@ -21,7 +21,7 @@ define(['./_baseAt', './_baseFlatten', './rest'], function(baseAt, baseFlatten,
|
||||
* // => ['a', 'c']
|
||||
*/
|
||||
var at = rest(function(object, paths) {
|
||||
return baseAt(object, baseFlatten(paths));
|
||||
return baseAt(object, baseFlatten(paths, 1));
|
||||
});
|
||||
|
||||
return at;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_apply', './isObject', './rest'], function(apply, isObject, rest) {
|
||||
define(['./_apply', './isError', './rest'], function(apply, isError, rest) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -27,7 +27,7 @@ define(['./_apply', './isObject', './rest'], function(apply, isObject, rest) {
|
||||
try {
|
||||
return apply(func, undefined, args);
|
||||
} catch (e) {
|
||||
return isObject(e) ? e : new Error(e);
|
||||
return isError(e) ? e : new Error(e);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
3
bind.js
3
bind.js
@@ -50,5 +50,8 @@ define(['./_createWrapper', './_replaceHolders', './rest'], function(createWrapp
|
||||
return createWrapper(func, bitmask, thisArg, partials, holders);
|
||||
});
|
||||
|
||||
// Assign default placeholders.
|
||||
bind.placeholder = {};
|
||||
|
||||
return bind;
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@ define(['./_arrayEach', './_baseFlatten', './bind', './rest'], function(arrayEac
|
||||
* // => logs 'clicked docs' when clicked
|
||||
*/
|
||||
var bindAll = rest(function(object, methodNames) {
|
||||
arrayEach(baseFlatten(methodNames), function(key) {
|
||||
arrayEach(baseFlatten(methodNames, 1), function(key) {
|
||||
object[key] = bind(object[key], object);
|
||||
});
|
||||
return object;
|
||||
|
||||
@@ -60,5 +60,8 @@ define(['./_createWrapper', './_replaceHolders', './rest'], function(createWrapp
|
||||
return createWrapper(key, bitmask, object, partials, holders);
|
||||
});
|
||||
|
||||
// Assign default placeholders.
|
||||
bindKey.placeholder = {};
|
||||
|
||||
return bindKey;
|
||||
});
|
||||
|
||||
44
castArray.js
Normal file
44
castArray.js
Normal file
@@ -0,0 +1,44 @@
|
||||
define(['./isArray'], function(isArray) {
|
||||
|
||||
/**
|
||||
* Casts `value` as an array if it's not one.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Lang
|
||||
* @param {*} value The value to inspect.
|
||||
* @returns {Array} Returns the cast array.
|
||||
* @example
|
||||
*
|
||||
* _.castArray(1);
|
||||
* // => [1]
|
||||
*
|
||||
* _.castArray({ 'a': 1 });
|
||||
* // => [{ 'a': 1 }]
|
||||
*
|
||||
* _.castArray('abc');
|
||||
* // => ['abc']
|
||||
*
|
||||
* _.castArray(null);
|
||||
* // => [null]
|
||||
*
|
||||
* _.castArray(undefined);
|
||||
* // => [undefined]
|
||||
*
|
||||
* _.castArray();
|
||||
* // => []
|
||||
*
|
||||
* var array = [1, 2, 3];
|
||||
* console.log(_.castArray(array) === array);
|
||||
* // => true
|
||||
*/
|
||||
function castArray() {
|
||||
if (!arguments.length) {
|
||||
return [];
|
||||
}
|
||||
var value = arguments[0];
|
||||
return isArray(value) ? value : [value];
|
||||
}
|
||||
|
||||
return castArray;
|
||||
});
|
||||
@@ -25,7 +25,7 @@ define(['./_arrayConcat', './_baseFlatten', './isArray', './rest'], function(arr
|
||||
if (!isArray(array)) {
|
||||
array = array == null ? [] : [Object(array)];
|
||||
}
|
||||
values = baseFlatten(values);
|
||||
values = baseFlatten(values, 1);
|
||||
return arrayConcat(array, values);
|
||||
});
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ define(['./_baseAssign', './_baseCreate'], function(baseAssign, baseCreate) {
|
||||
|
||||
/**
|
||||
* Creates an object that inherits from the `prototype` object. If a `properties`
|
||||
* object is provided its own enumerable properties are assigned to the created object.
|
||||
* object is given its own enumerable properties are assigned to the created object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
3
curry.js
3
curry.js
@@ -53,5 +53,8 @@ define(['./_createWrapper'], function(createWrapper) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Assign default placeholders.
|
||||
curry.placeholder = {};
|
||||
|
||||
return curry;
|
||||
});
|
||||
|
||||
@@ -50,5 +50,8 @@ define(['./_createWrapper'], function(createWrapper) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Assign default placeholders.
|
||||
curryRight.placeholder = {};
|
||||
|
||||
return curryRight;
|
||||
});
|
||||
|
||||
@@ -136,11 +136,13 @@ define(['./isObject', './now', './toNumber'], function(isObject, now, toNumber)
|
||||
if (maxWait === false) {
|
||||
var leadingCall = leading && !timeoutId;
|
||||
} else {
|
||||
if (!maxTimeoutId && !leading) {
|
||||
if (!lastCalled && !maxTimeoutId && !leading) {
|
||||
lastCalled = stamp;
|
||||
}
|
||||
var remaining = maxWait - (stamp - lastCalled),
|
||||
isCalled = remaining <= 0 || remaining > maxWait;
|
||||
var remaining = maxWait - (stamp - lastCalled);
|
||||
|
||||
var isCalled = (remaining <= 0 || remaining > maxWait) &&
|
||||
(leading || maxTimeoutId);
|
||||
|
||||
if (isCalled) {
|
||||
if (maxTimeoutId) {
|
||||
|
||||
@@ -2,7 +2,7 @@ define(['./_baseDifference', './_baseFlatten', './isArrayLikeObject', './rest'],
|
||||
|
||||
/**
|
||||
* Creates an array of unique `array` values not included in the other
|
||||
* provided arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
|
||||
* given arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
|
||||
* for equality comparisons.
|
||||
*
|
||||
* @static
|
||||
@@ -18,7 +18,7 @@ define(['./_baseDifference', './_baseFlatten', './isArrayLikeObject', './rest'],
|
||||
*/
|
||||
var difference = rest(function(array, values) {
|
||||
return isArrayLikeObject(array)
|
||||
? baseDifference(array, baseFlatten(values, false, true))
|
||||
? baseDifference(array, baseFlatten(values, 1, true))
|
||||
: [];
|
||||
});
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ define(['./_baseDifference', './_baseFlatten', './_baseIteratee', './isArrayLike
|
||||
iteratee = undefined;
|
||||
}
|
||||
return isArrayLikeObject(array)
|
||||
? baseDifference(array, baseFlatten(values, false, true), baseIteratee(iteratee))
|
||||
? baseDifference(array, baseFlatten(values, 1, true), baseIteratee(iteratee))
|
||||
: [];
|
||||
});
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ define(['./_baseDifference', './_baseFlatten', './isArrayLikeObject', './last',
|
||||
comparator = undefined;
|
||||
}
|
||||
return isArrayLikeObject(array)
|
||||
? baseDifference(array, baseFlatten(values, false, true), undefined, comparator)
|
||||
? baseDifference(array, baseFlatten(values, 1, true), undefined, comparator)
|
||||
: [];
|
||||
});
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ define(['./_baseFlatten', './map'], function(baseFlatten, map) {
|
||||
* // => [1, 1, 2, 2]
|
||||
*/
|
||||
function flatMap(collection, iteratee) {
|
||||
return baseFlatten(map(collection, iteratee));
|
||||
return baseFlatten(map(collection, iteratee), 1);
|
||||
}
|
||||
|
||||
return flatMap;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
define(['./_baseFlatten'], function(baseFlatten) {
|
||||
|
||||
/**
|
||||
* Flattens `array` a single level.
|
||||
* Flattens `array` a single level deep.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -10,12 +10,12 @@ define(['./_baseFlatten'], function(baseFlatten) {
|
||||
* @returns {Array} Returns the new flattened array.
|
||||
* @example
|
||||
*
|
||||
* _.flatten([1, [2, 3, [4]]]);
|
||||
* // => [1, 2, 3, [4]]
|
||||
* _.flatten([1, [2, [3, [4]], 5]]);
|
||||
* // => [1, 2, [3, [4]], 5]
|
||||
*/
|
||||
function flatten(array) {
|
||||
var length = array ? array.length : 0;
|
||||
return length ? baseFlatten(array) : [];
|
||||
return length ? baseFlatten(array, 1) : [];
|
||||
}
|
||||
|
||||
return flatten;
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
define(['./_baseFlatten'], function(baseFlatten) {
|
||||
|
||||
/** Used as references for various `Number` constants. */
|
||||
var INFINITY = 1 / 0;
|
||||
|
||||
/**
|
||||
* This method is like `_.flatten` except that it recursively flattens `array`.
|
||||
* Recursively flattens `array`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Array
|
||||
* @param {Array} array The array to recursively flatten.
|
||||
* @param {Array} array The array to flatten.
|
||||
* @returns {Array} Returns the new flattened array.
|
||||
* @example
|
||||
*
|
||||
* _.flattenDeep([1, [2, 3, [4]]]);
|
||||
* // => [1, 2, 3, 4]
|
||||
* _.flattenDeep([1, [2, [3, [4]], 5]]);
|
||||
* // => [1, 2, 3, 4, 5]
|
||||
*/
|
||||
function flattenDeep(array) {
|
||||
var length = array ? array.length : 0;
|
||||
return length ? baseFlatten(array, true) : [];
|
||||
return length ? baseFlatten(array, INFINITY) : [];
|
||||
}
|
||||
|
||||
return flattenDeep;
|
||||
|
||||
35
flattenDepth.js
Normal file
35
flattenDepth.js
Normal file
@@ -0,0 +1,35 @@
|
||||
define(['./_baseFlatten', './toInteger'], function(baseFlatten, toInteger) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/**
|
||||
* Recursively flatten `array` up to `depth` times.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Array
|
||||
* @param {Array} array The array to flatten.
|
||||
* @param {number} [depth=1] The maximum recursion depth.
|
||||
* @returns {Array} Returns the new flattened array.
|
||||
* @example
|
||||
*
|
||||
* var array = [1, [2, [3, [4]], 5]];
|
||||
*
|
||||
* _.flattenDepth(array, 1);
|
||||
* // => [1, 2, [3, [4]], 5]
|
||||
*
|
||||
* _.flattenDepth(array, 2);
|
||||
* // => [1, 2, 3, [4], 5]
|
||||
*/
|
||||
function flattenDepth(array, depth) {
|
||||
var length = array ? array.length : 0;
|
||||
if (!length) {
|
||||
return [];
|
||||
}
|
||||
depth = depth === undefined ? 1 : toInteger(depth);
|
||||
return baseFlatten(array, depth);
|
||||
}
|
||||
|
||||
return flattenDepth;
|
||||
});
|
||||
6
flow.js
6
flow.js
@@ -1,9 +1,9 @@
|
||||
define(['./_createFlow'], function(createFlow) {
|
||||
|
||||
/**
|
||||
* Creates a function that returns the result of invoking the provided
|
||||
* functions with the `this` binding of the created function, where each
|
||||
* successive invocation is supplied the return value of the previous.
|
||||
* Creates a function that returns the result of invoking the given functions
|
||||
* with the `this` binding of the created function, where each successive
|
||||
* invocation is supplied the return value of the previous.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -2,7 +2,7 @@ define(['./_createFlow'], function(createFlow) {
|
||||
|
||||
/**
|
||||
* This method is like `_.flow` except that it creates a function that
|
||||
* invokes the provided functions from right to left.
|
||||
* invokes the given functions from right to left.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_arrayEach', './_baseEach', './isArray', './_toFunction'], function(arrayEach, baseEach, isArray, toFunction) {
|
||||
define(['./_arrayEach', './_baseCastFunction', './_baseEach', './isArray'], function(arrayEach, baseCastFunction, baseEach, isArray) {
|
||||
|
||||
/**
|
||||
* Iterates over elements of `collection` invoking `iteratee` for each element.
|
||||
@@ -31,7 +31,7 @@ define(['./_arrayEach', './_baseEach', './isArray', './_toFunction'], function(a
|
||||
function forEach(collection, iteratee) {
|
||||
return (typeof iteratee == 'function' && isArray(collection))
|
||||
? arrayEach(collection, iteratee)
|
||||
: baseEach(collection, toFunction(iteratee));
|
||||
: baseEach(collection, baseCastFunction(iteratee));
|
||||
}
|
||||
|
||||
return forEach;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_arrayEachRight', './_baseEachRight', './isArray', './_toFunction'], function(arrayEachRight, baseEachRight, isArray, toFunction) {
|
||||
define(['./_arrayEachRight', './_baseCastFunction', './_baseEachRight', './isArray'], function(arrayEachRight, baseCastFunction, baseEachRight, isArray) {
|
||||
|
||||
/**
|
||||
* This method is like `_.forEach` except that it iterates over elements of
|
||||
@@ -21,7 +21,7 @@ define(['./_arrayEachRight', './_baseEachRight', './isArray', './_toFunction'],
|
||||
function forEachRight(collection, iteratee) {
|
||||
return (typeof iteratee == 'function' && isArray(collection))
|
||||
? arrayEachRight(collection, iteratee)
|
||||
: baseEachRight(collection, toFunction(iteratee));
|
||||
: baseEachRight(collection, baseCastFunction(iteratee));
|
||||
}
|
||||
|
||||
return forEachRight;
|
||||
|
||||
6
forIn.js
6
forIn.js
@@ -1,4 +1,4 @@
|
||||
define(['./_baseFor', './keysIn', './_toFunction'], function(baseFor, keysIn, toFunction) {
|
||||
define(['./_baseCastFunction', './_baseFor', './keysIn'], function(baseCastFunction, baseFor, keysIn) {
|
||||
|
||||
/**
|
||||
* Iterates over own and inherited enumerable properties of an object invoking
|
||||
@@ -27,7 +27,9 @@ define(['./_baseFor', './keysIn', './_toFunction'], function(baseFor, keysIn, to
|
||||
* // => logs 'a', 'b', then 'c' (iteration order is not guaranteed)
|
||||
*/
|
||||
function forIn(object, iteratee) {
|
||||
return object == null ? object : baseFor(object, toFunction(iteratee), keysIn);
|
||||
return object == null
|
||||
? object
|
||||
: baseFor(object, baseCastFunction(iteratee), keysIn);
|
||||
}
|
||||
|
||||
return forIn;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_baseForRight', './keysIn', './_toFunction'], function(baseForRight, keysIn, toFunction) {
|
||||
define(['./_baseCastFunction', './_baseForRight', './keysIn'], function(baseCastFunction, baseForRight, keysIn) {
|
||||
|
||||
/**
|
||||
* This method is like `_.forIn` except that it iterates over properties of
|
||||
@@ -25,7 +25,9 @@ define(['./_baseForRight', './keysIn', './_toFunction'], function(baseForRight,
|
||||
* // => logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'
|
||||
*/
|
||||
function forInRight(object, iteratee) {
|
||||
return object == null ? object : baseForRight(object, toFunction(iteratee), keysIn);
|
||||
return object == null
|
||||
? object
|
||||
: baseForRight(object, baseCastFunction(iteratee), keysIn);
|
||||
}
|
||||
|
||||
return forInRight;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_baseForOwn', './_toFunction'], function(baseForOwn, toFunction) {
|
||||
define(['./_baseCastFunction', './_baseForOwn'], function(baseCastFunction, baseForOwn) {
|
||||
|
||||
/**
|
||||
* Iterates over own enumerable properties of an object invoking `iteratee`
|
||||
@@ -27,7 +27,7 @@ define(['./_baseForOwn', './_toFunction'], function(baseForOwn, toFunction) {
|
||||
* // => logs 'a' then 'b' (iteration order is not guaranteed)
|
||||
*/
|
||||
function forOwn(object, iteratee) {
|
||||
return object && baseForOwn(object, toFunction(iteratee));
|
||||
return object && baseForOwn(object, baseCastFunction(iteratee));
|
||||
}
|
||||
|
||||
return forOwn;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_baseForOwnRight', './_toFunction'], function(baseForOwnRight, toFunction) {
|
||||
define(['./_baseCastFunction', './_baseForOwnRight'], function(baseCastFunction, baseForOwnRight) {
|
||||
|
||||
/**
|
||||
* This method is like `_.forOwn` except that it iterates over properties of
|
||||
@@ -25,7 +25,7 @@ define(['./_baseForOwnRight', './_toFunction'], function(baseForOwnRight, toFunc
|
||||
* // => logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'
|
||||
*/
|
||||
function forOwnRight(object, iteratee) {
|
||||
return object && baseForOwnRight(object, toFunction(iteratee));
|
||||
return object && baseForOwnRight(object, baseCastFunction(iteratee));
|
||||
}
|
||||
|
||||
return forOwnRight;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
define([], function() {
|
||||
|
||||
/**
|
||||
* This method returns the first argument provided to it.
|
||||
* This method returns the first argument given to it.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
define(['./_arrayMap', './_baseIntersection', './rest', './_toArrayLikeObject'], function(arrayMap, baseIntersection, rest, toArrayLikeObject) {
|
||||
define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './rest'], function(arrayMap, baseCastArrayLikeObject, baseIntersection, rest) {
|
||||
|
||||
/**
|
||||
* Creates an array of unique values that are included in all of the provided
|
||||
* arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
|
||||
* Creates an array of unique values that are included in all given arrays
|
||||
* using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
|
||||
* for equality comparisons.
|
||||
*
|
||||
* @static
|
||||
@@ -16,7 +16,7 @@ define(['./_arrayMap', './_baseIntersection', './rest', './_toArrayLikeObject'],
|
||||
* // => [2]
|
||||
*/
|
||||
var intersection = rest(function(arrays) {
|
||||
var mapped = arrayMap(arrays, toArrayLikeObject);
|
||||
var mapped = arrayMap(arrays, baseCastArrayLikeObject);
|
||||
return (mapped.length && mapped[0] === arrays[0])
|
||||
? baseIntersection(mapped)
|
||||
: [];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_arrayMap', './_baseIntersection', './_baseIteratee', './last', './rest', './_toArrayLikeObject'], function(arrayMap, baseIntersection, baseIteratee, last, rest, toArrayLikeObject) {
|
||||
define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './_baseIteratee', './last', './rest'], function(arrayMap, baseCastArrayLikeObject, baseIntersection, baseIteratee, last, rest) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -25,7 +25,7 @@ define(['./_arrayMap', './_baseIntersection', './_baseIteratee', './last', './re
|
||||
*/
|
||||
var intersectionBy = rest(function(arrays) {
|
||||
var iteratee = last(arrays),
|
||||
mapped = arrayMap(arrays, toArrayLikeObject);
|
||||
mapped = arrayMap(arrays, baseCastArrayLikeObject);
|
||||
|
||||
if (iteratee === last(mapped)) {
|
||||
iteratee = undefined;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_arrayMap', './_baseIntersection', './last', './rest', './_toArrayLikeObject'], function(arrayMap, baseIntersection, last, rest, toArrayLikeObject) {
|
||||
define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './last', './rest'], function(arrayMap, baseCastArrayLikeObject, baseIntersection, last, rest) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -24,7 +24,7 @@ define(['./_arrayMap', './_baseIntersection', './last', './rest', './_toArrayLik
|
||||
*/
|
||||
var intersectionWith = rest(function(arrays) {
|
||||
var comparator = last(arrays),
|
||||
mapped = arrayMap(arrays, toArrayLikeObject);
|
||||
mapped = arrayMap(arrays, baseCastArrayLikeObject);
|
||||
|
||||
if (comparator === last(mapped)) {
|
||||
comparator = undefined;
|
||||
|
||||
@@ -5,7 +5,7 @@ define([], function() {
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @type Function
|
||||
* @type {Function}
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||||
|
||||
35
isArrayBuffer.js
Normal file
35
isArrayBuffer.js
Normal file
@@ -0,0 +1,35 @@
|
||||
define(['./isObjectLike'], function(isObjectLike) {
|
||||
|
||||
var arrayBufferTag = '[object ArrayBuffer]';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/**
|
||||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var objectToString = objectProto.toString;
|
||||
|
||||
/**
|
||||
* Checks if `value` is classified as an `ArrayBuffer` object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isArrayBuffer(new ArrayBuffer(2));
|
||||
* // => true
|
||||
*
|
||||
* _.isArrayBuffer(new Array(2));
|
||||
* // => false
|
||||
*/
|
||||
function isArrayBuffer(value) {
|
||||
return isObjectLike(value) && objectToString.call(value) == arrayBufferTag;
|
||||
}
|
||||
|
||||
return isArrayBuffer;
|
||||
});
|
||||
@@ -7,7 +7,6 @@ define(['./_getLength', './isFunction', './isLength'], function(getLength, isFun
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @type Function
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
||||
|
||||
@@ -6,7 +6,6 @@ define(['./isArrayLike', './isObjectLike'], function(isArrayLike, isObjectLike)
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @type Function
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is an array-like object, else `false`.
|
||||
|
||||
51
isBuffer.js
Normal file
51
isBuffer.js
Normal file
@@ -0,0 +1,51 @@
|
||||
define(['./constant', './_root'], function(constant, root) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/** Used to determine if values are of the language type `Object`. */
|
||||
var objectTypes = {
|
||||
'function': true,
|
||||
'object': true
|
||||
};
|
||||
|
||||
/** Detect free variable `exports`. */
|
||||
var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
|
||||
? exports
|
||||
: undefined;
|
||||
|
||||
/** Detect free variable `module`. */
|
||||
var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
|
||||
? module
|
||||
: undefined;
|
||||
|
||||
/** Detect the popular CommonJS extension `module.exports`. */
|
||||
var moduleExports = (freeModule && freeModule.exports === freeExports)
|
||||
? freeExports
|
||||
: undefined;
|
||||
|
||||
/** Built-in value references. */
|
||||
var Buffer = moduleExports ? root.Buffer : undefined;
|
||||
|
||||
/**
|
||||
* Checks if `value` is a buffer.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isBuffer(new Buffer(2));
|
||||
* // => true
|
||||
*
|
||||
* _.isBuffer(new Uint8Array(2));
|
||||
* // => false
|
||||
*/
|
||||
var isBuffer = !Buffer ? constant(false) : function(value) {
|
||||
return value instanceof Buffer;
|
||||
};
|
||||
|
||||
return isBuffer;
|
||||
});
|
||||
@@ -35,7 +35,8 @@ define(['./isArguments', './isArray', './isArrayLike', './isFunction', './isStri
|
||||
*/
|
||||
function isEmpty(value) {
|
||||
if (isArrayLike(value) &&
|
||||
(isArray(value) || isString(value) || isFunction(value.splice) || isArguments(value))) {
|
||||
(isArray(value) || isString(value) ||
|
||||
isFunction(value.splice) || isArguments(value))) {
|
||||
return !value.length;
|
||||
}
|
||||
for (var key in value) {
|
||||
|
||||
@@ -4,10 +4,10 @@ define(['./_baseIsEqual'], function(baseIsEqual) {
|
||||
var undefined;
|
||||
|
||||
/**
|
||||
* This method is like `_.isEqual` except that it accepts `customizer` which is
|
||||
* invoked to compare values. If `customizer` returns `undefined` comparisons are
|
||||
* handled by the method instead. The `customizer` is invoked with up to six arguments:
|
||||
* (objValue, othValue [, index|key, object, other, stack]).
|
||||
* This method is like `_.isEqual` except that it accepts `customizer` which
|
||||
* is invoked to compare values. If `customizer` returns `undefined` comparisons
|
||||
* are handled by the method instead. The `customizer` is invoked with up to
|
||||
* six arguments: (objValue, othValue [, index|key, object, other, stack]).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -30,8 +30,12 @@ define(['./isObjectLike'], function(isObjectLike) {
|
||||
* // => false
|
||||
*/
|
||||
function isError(value) {
|
||||
return isObjectLike(value) &&
|
||||
typeof value.message == 'string' && objectToString.call(value) == errorTag;
|
||||
if (!isObjectLike(value)) {
|
||||
return false;
|
||||
}
|
||||
var Ctor = value.constructor;
|
||||
return (objectToString.call(value) == errorTag) ||
|
||||
(typeof Ctor == 'function' && objectToString.call(Ctor.prototype) == errorTag);
|
||||
}
|
||||
|
||||
return isError;
|
||||
|
||||
@@ -28,7 +28,8 @@ define([], function() {
|
||||
* // => false
|
||||
*/
|
||||
function isLength(value) {
|
||||
return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
||||
return typeof value == 'number' &&
|
||||
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
||||
}
|
||||
|
||||
return isLength;
|
||||
|
||||
27
isMap.js
Normal file
27
isMap.js
Normal file
@@ -0,0 +1,27 @@
|
||||
define(['./_getTag', './isObjectLike'], function(getTag, isObjectLike) {
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var mapTag = '[object Map]';
|
||||
|
||||
/**
|
||||
* Checks if `value` is classified as a `Map` object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isMap(new Map);
|
||||
* // => true
|
||||
*
|
||||
* _.isMap(new WeakMap);
|
||||
* // => false
|
||||
*/
|
||||
function isMap(value) {
|
||||
return isObjectLike(value) && getTag(value) == mapTag;
|
||||
}
|
||||
|
||||
return isMap;
|
||||
});
|
||||
@@ -1,8 +1,9 @@
|
||||
define(['./_baseIsMatch', './_getMatchData'], function(baseIsMatch, getMatchData) {
|
||||
|
||||
/**
|
||||
* Performs a deep comparison between `object` and `source` to determine if
|
||||
* `object` contains equivalent property values.
|
||||
* Performs a partial deep comparison between `object` and `source` to
|
||||
* determine if `object` contains equivalent property values. This method is
|
||||
* equivalent to a `_.matches` function when `source` is partially applied.
|
||||
*
|
||||
* **Note:** This method supports comparing the same values as `_.isEqual`.
|
||||
*
|
||||
|
||||
@@ -49,7 +49,8 @@ define(['./_isHostObject', './isObjectLike'], function(isHostObject, isObjectLik
|
||||
* // => true
|
||||
*/
|
||||
function isPlainObject(value) {
|
||||
if (!isObjectLike(value) || objectToString.call(value) != objectTag || isHostObject(value)) {
|
||||
if (!isObjectLike(value) ||
|
||||
objectToString.call(value) != objectTag || isHostObject(value)) {
|
||||
return false;
|
||||
}
|
||||
var proto = objectProto;
|
||||
|
||||
27
isSet.js
Normal file
27
isSet.js
Normal file
@@ -0,0 +1,27 @@
|
||||
define(['./_getTag', './isObjectLike'], function(getTag, isObjectLike) {
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var setTag = '[object Set]';
|
||||
|
||||
/**
|
||||
* Checks if `value` is classified as a `Set` object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isSet(new Set);
|
||||
* // => true
|
||||
*
|
||||
* _.isSet(new WeakSet);
|
||||
* // => false
|
||||
*/
|
||||
function isSet(value) {
|
||||
return isObjectLike(value) && getTag(value) == setTag;
|
||||
}
|
||||
|
||||
return isSet;
|
||||
});
|
||||
@@ -67,7 +67,8 @@ define(['./isLength', './isObjectLike'], function(isLength, isObjectLike) {
|
||||
* // => false
|
||||
*/
|
||||
function isTypedArray(value) {
|
||||
return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
|
||||
return isObjectLike(value) &&
|
||||
isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
|
||||
}
|
||||
|
||||
return isTypedArray;
|
||||
|
||||
27
isWeakMap.js
Normal file
27
isWeakMap.js
Normal file
@@ -0,0 +1,27 @@
|
||||
define(['./_getTag', './isObjectLike'], function(getTag, isObjectLike) {
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var weakMapTag = '[object WeakMap]';
|
||||
|
||||
/**
|
||||
* Checks if `value` is classified as a `WeakMap` object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isWeakMap(new WeakMap);
|
||||
* // => true
|
||||
*
|
||||
* _.isWeakMap(new Map);
|
||||
* // => false
|
||||
*/
|
||||
function isWeakMap(value) {
|
||||
return isObjectLike(value) && getTag(value) == weakMapTag;
|
||||
}
|
||||
|
||||
return isWeakMap;
|
||||
});
|
||||
36
isWeakSet.js
Normal file
36
isWeakSet.js
Normal file
@@ -0,0 +1,36 @@
|
||||
define(['./isObjectLike'], function(isObjectLike) {
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var weakSetTag = '[object WeakSet]';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/**
|
||||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var objectToString = objectProto.toString;
|
||||
|
||||
/**
|
||||
* Checks if `value` is classified as a `WeakSet` object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isWeakSet(new WeakSet);
|
||||
* // => true
|
||||
*
|
||||
* _.isWeakSet(new Set);
|
||||
* // => false
|
||||
*/
|
||||
function isWeakSet(value) {
|
||||
return isObjectLike(value) && objectToString.call(value) == weakSetTag;
|
||||
}
|
||||
|
||||
return isWeakSet;
|
||||
});
|
||||
@@ -4,7 +4,8 @@ define(['./_baseClone', './_baseIteratee'], function(baseClone, baseIteratee) {
|
||||
* Creates a function that invokes `func` with the arguments of the created
|
||||
* function. If `func` is a property name the created callback returns the
|
||||
* property value for a given element. If `func` is an object the created
|
||||
* callback returns `true` for elements that contain the equivalent object properties, otherwise it returns `false`.
|
||||
* callback returns `true` for elements that contain the equivalent object
|
||||
* properties, otherwise it returns `false`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
9
lang.js
9
lang.js
@@ -1,5 +1,6 @@
|
||||
define(['./clone', './cloneDeep', './cloneDeepWith', './cloneWith', './eq', './gt', './gte', './isArguments', './isArray', './isArrayLike', './isArrayLikeObject', './isBoolean', './isDate', './isElement', './isEmpty', './isEqual', './isEqualWith', './isError', './isFinite', './isFunction', './isInteger', './isLength', './isMatch', './isMatchWith', './isNaN', './isNative', './isNil', './isNull', './isNumber', './isObject', './isObjectLike', './isPlainObject', './isRegExp', './isSafeInteger', './isString', './isSymbol', './isTypedArray', './isUndefined', './lt', './lte', './toArray', './toInteger', './toLength', './toNumber', './toPlainObject', './toSafeInteger', './toString'], function(clone, cloneDeep, cloneDeepWith, cloneWith, eq, gt, gte, isArguments, isArray, isArrayLike, isArrayLikeObject, isBoolean, isDate, isElement, isEmpty, isEqual, isEqualWith, isError, isFinite, isFunction, isInteger, isLength, isMatch, isMatchWith, isNaN, isNative, isNil, isNull, isNumber, isObject, isObjectLike, isPlainObject, isRegExp, isSafeInteger, isString, isSymbol, isTypedArray, isUndefined, lt, lte, toArray, toInteger, toLength, toNumber, toPlainObject, toSafeInteger, toString) {
|
||||
define(['./castArray', './clone', './cloneDeep', './cloneDeepWith', './cloneWith', './eq', './gt', './gte', './isArguments', './isArray', './isArrayBuffer', './isArrayLike', './isArrayLikeObject', './isBoolean', './isBuffer', './isDate', './isElement', './isEmpty', './isEqual', './isEqualWith', './isError', './isFinite', './isFunction', './isInteger', './isLength', './isMap', './isMatch', './isMatchWith', './isNaN', './isNative', './isNil', './isNull', './isNumber', './isObject', './isObjectLike', './isPlainObject', './isRegExp', './isSafeInteger', './isSet', './isString', './isSymbol', './isTypedArray', './isUndefined', './isWeakMap', './isWeakSet', './lt', './lte', './toArray', './toInteger', './toLength', './toNumber', './toPlainObject', './toSafeInteger', './toString'], function(castArray, clone, cloneDeep, cloneDeepWith, cloneWith, eq, gt, gte, isArguments, isArray, isArrayBuffer, isArrayLike, isArrayLikeObject, isBoolean, isBuffer, isDate, isElement, isEmpty, isEqual, isEqualWith, isError, isFinite, isFunction, isInteger, isLength, isMap, isMatch, isMatchWith, isNaN, isNative, isNil, isNull, isNumber, isObject, isObjectLike, isPlainObject, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet, lt, lte, toArray, toInteger, toLength, toNumber, toPlainObject, toSafeInteger, toString) {
|
||||
return {
|
||||
'castArray': castArray,
|
||||
'clone': clone,
|
||||
'cloneDeep': cloneDeep,
|
||||
'cloneDeepWith': cloneDeepWith,
|
||||
@@ -9,9 +10,11 @@ define(['./clone', './cloneDeep', './cloneDeepWith', './cloneWith', './eq', './g
|
||||
'gte': gte,
|
||||
'isArguments': isArguments,
|
||||
'isArray': isArray,
|
||||
'isArrayBuffer': isArrayBuffer,
|
||||
'isArrayLike': isArrayLike,
|
||||
'isArrayLikeObject': isArrayLikeObject,
|
||||
'isBoolean': isBoolean,
|
||||
'isBuffer': isBuffer,
|
||||
'isDate': isDate,
|
||||
'isElement': isElement,
|
||||
'isEmpty': isEmpty,
|
||||
@@ -22,6 +25,7 @@ define(['./clone', './cloneDeep', './cloneDeepWith', './cloneWith', './eq', './g
|
||||
'isFunction': isFunction,
|
||||
'isInteger': isInteger,
|
||||
'isLength': isLength,
|
||||
'isMap': isMap,
|
||||
'isMatch': isMatch,
|
||||
'isMatchWith': isMatchWith,
|
||||
'isNaN': isNaN,
|
||||
@@ -34,10 +38,13 @@ define(['./clone', './cloneDeep', './cloneDeepWith', './cloneWith', './eq', './g
|
||||
'isPlainObject': isPlainObject,
|
||||
'isRegExp': isRegExp,
|
||||
'isSafeInteger': isSafeInteger,
|
||||
'isSet': isSet,
|
||||
'isString': isString,
|
||||
'isSymbol': isSymbol,
|
||||
'isTypedArray': isTypedArray,
|
||||
'isUndefined': isUndefined,
|
||||
'isWeakMap': isWeakMap,
|
||||
'isWeakSet': isWeakSet,
|
||||
'lt': lt,
|
||||
'lte': lte,
|
||||
'toArray': toArray,
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
define(['./_baseClone', './_baseMatches'], function(baseClone, baseMatches) {
|
||||
|
||||
/**
|
||||
* Creates a function that performs a deep partial comparison between a given
|
||||
* Creates a function that performs a partial deep comparison between a given
|
||||
* object and `source`, returning `true` if the given object has equivalent
|
||||
* property values, else `false`.
|
||||
* property values, else `false`. The created function is equivalent to
|
||||
* `_.isMatch` with a `source` partially applied.
|
||||
*
|
||||
* **Note:** This method supports comparing the same values as `_.isEqual`.
|
||||
*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
define(['./_baseClone', './_baseMatchesProperty'], function(baseClone, baseMatchesProperty) {
|
||||
|
||||
/**
|
||||
* Creates a function that performs a deep partial comparison between the
|
||||
* Creates a function that performs a partial deep comparison between the
|
||||
* value at `path` of a given object to `srcValue`, returning `true` if the
|
||||
* object value is equivalent, else `false`.
|
||||
*
|
||||
|
||||
12
merge.js
12
merge.js
@@ -1,12 +1,12 @@
|
||||
define(['./_baseMerge', './_createAssigner'], function(baseMerge, createAssigner) {
|
||||
|
||||
/**
|
||||
* Recursively merges own and inherited enumerable properties of source
|
||||
* objects into the destination object, skipping source properties that resolve
|
||||
* to `undefined`. Array and plain object properties are merged recursively.
|
||||
* Other objects and value types are overridden by assignment. Source objects
|
||||
* are applied from left to right. Subsequent sources overwrite property
|
||||
* assignments of previous sources.
|
||||
* Recursively merges own and inherited enumerable properties of source objects
|
||||
* into the destination object. Source properties that resolve to `undefined`
|
||||
* are skipped if a destination value exists. Array and plain object properties
|
||||
* are merged recursively. Other objects and value types are overridden by
|
||||
* assignment. Source objects are applied from left to right. Subsequent
|
||||
* sources overwrite property assignments of previous sources.
|
||||
*
|
||||
* **Note:** This method mutates `object`.
|
||||
*
|
||||
|
||||
2
now.js
2
now.js
@@ -6,7 +6,7 @@ define([], function() {
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @type Function
|
||||
* @type {Function}
|
||||
* @category Date
|
||||
* @returns {number} Returns the timestamp.
|
||||
* @example
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user