mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
Bump to v4.4.0.
This commit is contained in:
14
README.md
14
README.md
@@ -1,4 +1,4 @@
|
|||||||
# lodash v4.3.0
|
# lodash v4.4.0
|
||||||
|
|
||||||
The [lodash](https://lodash.com/) library exported as [Node.js](https://nodejs.org/) modules.
|
The [lodash](https://lodash.com/) library exported as [Node.js](https://nodejs.org/) modules.
|
||||||
|
|
||||||
@@ -12,23 +12,23 @@ $ npm i --save lodash
|
|||||||
|
|
||||||
In Node.js:
|
In Node.js:
|
||||||
```js
|
```js
|
||||||
// load the full build
|
// Load the full build.
|
||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
// load the core build
|
// Load the core build.
|
||||||
var _ = require('lodash/core');
|
var _ = require('lodash/core');
|
||||||
// load the fp build for immutable auto-curried iteratee-first data-last methods
|
// Load the fp build for immutable auto-curried iteratee-first data-last methods.
|
||||||
var _ = require('lodash/fp');
|
var _ = require('lodash/fp');
|
||||||
|
|
||||||
// or a method category
|
// Load a method category.
|
||||||
var array = require('lodash/array');
|
var array = require('lodash/array');
|
||||||
var object = require('lodash/fp/object');
|
var object = require('lodash/fp/object');
|
||||||
|
|
||||||
// or method for smaller builds with browserify/rollup/webpack
|
// Load a single method for smaller builds with browserify/rollup/webpack.
|
||||||
var chunk = require('lodash/chunk');
|
var chunk = require('lodash/chunk');
|
||||||
var extend = require('lodash/fp/extend');
|
var extend = require('lodash/fp/extend');
|
||||||
```
|
```
|
||||||
|
|
||||||
See the [package source](https://github.com/lodash/lodash/tree/4.3.0-npm) for more details.
|
See the [package source](https://github.com/lodash/lodash/tree/4.4.0-npm) for more details.
|
||||||
|
|
||||||
**Note:**<br>
|
**Note:**<br>
|
||||||
Don’t assign values to the [special variable](http://nodejs.org/api/repl.html#repl_repl_features) `_` when in the REPL.<br>
|
Don’t assign values to the [special variable](http://nodejs.org/api/repl.html#repl_repl_features) `_` when in the REPL.<br>
|
||||||
|
|||||||
1
_Hash.js
1
_Hash.js
@@ -7,6 +7,7 @@ var objectProto = Object.prototype;
|
|||||||
* Creates an hash object.
|
* Creates an hash object.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @constructor
|
||||||
* @returns {Object} Returns the new hash object.
|
* @returns {Object} Returns the new hash object.
|
||||||
*/
|
*/
|
||||||
function Hash() {}
|
function Hash() {}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ var MAX_ARRAY_LENGTH = 4294967295;
|
|||||||
* Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
|
* Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @constructor
|
||||||
* @param {*} value The value to wrap.
|
* @param {*} value The value to wrap.
|
||||||
*/
|
*/
|
||||||
function LazyWrapper(value) {
|
function LazyWrapper(value) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ var mapClear = require('./_mapClear'),
|
|||||||
* Creates a map cache object to store key-value pairs.
|
* Creates a map cache object to store key-value pairs.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @constructor
|
||||||
* @param {Array} [values] The values to cache.
|
* @param {Array} [values] The values to cache.
|
||||||
*/
|
*/
|
||||||
function MapCache(values) {
|
function MapCache(values) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ var MapCache = require('./_MapCache'),
|
|||||||
* Creates a set cache object to store unique values.
|
* Creates a set cache object to store unique values.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @constructor
|
||||||
* @param {Array} [values] The values to cache.
|
* @param {Array} [values] The values to cache.
|
||||||
*/
|
*/
|
||||||
function SetCache(values) {
|
function SetCache(values) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ var stackClear = require('./_stackClear'),
|
|||||||
* Creates a stack cache object to store key-value pairs.
|
* Creates a stack cache object to store key-value pairs.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
* @constructor
|
||||||
* @param {Array} [values] The values to cache.
|
* @param {Array} [values] The values to cache.
|
||||||
*/
|
*/
|
||||||
function Stack(values) {
|
function Stack(values) {
|
||||||
|
|||||||
14
_baseCastArrayLikeObject.js
Normal file
14
_baseCastArrayLikeObject.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
var isArrayLikeObject = require('./isArrayLikeObject');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Casts `value` to an empty array if it's not an array like object.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {*} value The value to inspect.
|
||||||
|
* @returns {Array} Returns the array-like object.
|
||||||
|
*/
|
||||||
|
function baseCastArrayLikeObject(value) {
|
||||||
|
return isArrayLikeObject(value) ? value : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = baseCastArrayLikeObject;
|
||||||
14
_baseCastFunction.js
Normal file
14
_baseCastFunction.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
var identity = require('./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;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = baseCastFunction;
|
||||||
15
_baseCastPath.js
Normal file
15
_baseCastPath.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
var isArray = require('./isArray'),
|
||||||
|
stringToPath = require('./_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);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = baseCastPath;
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
var isObject = require('./isObject');
|
var isObject = require('./isObject');
|
||||||
|
|
||||||
|
/** Built-in value references. */
|
||||||
|
var objectCreate = Object.create;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.create` without support for assigning
|
* The base implementation of `_.create` without support for assigning
|
||||||
* properties to the created object.
|
* properties to the created object.
|
||||||
@@ -8,16 +11,8 @@ var isObject = require('./isObject');
|
|||||||
* @param {Object} prototype The object to inherit from.
|
* @param {Object} prototype The object to inherit from.
|
||||||
* @returns {Object} Returns the new object.
|
* @returns {Object} Returns the new object.
|
||||||
*/
|
*/
|
||||||
var baseCreate = (function() {
|
function baseCreate(proto) {
|
||||||
function object() {}
|
return isObject(proto) ? objectCreate(proto) : {};
|
||||||
return function(prototype) {
|
}
|
||||||
if (isObject(prototype)) {
|
|
||||||
object.prototype = prototype;
|
|
||||||
var result = new object;
|
|
||||||
object.prototype = undefined;
|
|
||||||
}
|
|
||||||
return result || {};
|
|
||||||
};
|
|
||||||
}());
|
|
||||||
|
|
||||||
module.exports = baseCreate;
|
module.exports = baseCreate;
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ var arrayPush = require('./_arrayPush'),
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to flatten.
|
* @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 {boolean} [isStrict] Restrict flattening to arrays-like objects.
|
||||||
* @param {Array} [result=[]] The initial result value.
|
* @param {Array} [result=[]] The initial result value.
|
||||||
* @returns {Array} Returns the new flattened array.
|
* @returns {Array} Returns the new flattened array.
|
||||||
*/
|
*/
|
||||||
function baseFlatten(array, isDeep, isStrict, result) {
|
function baseFlatten(array, depth, isStrict, result) {
|
||||||
result || (result = []);
|
result || (result = []);
|
||||||
|
|
||||||
var index = -1,
|
var index = -1,
|
||||||
@@ -21,11 +21,11 @@ function baseFlatten(array, isDeep, isStrict, result) {
|
|||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var value = array[index];
|
var value = array[index];
|
||||||
if (isArrayLikeObject(value) &&
|
if (depth > 0 && isArrayLikeObject(value) &&
|
||||||
(isStrict || isArray(value) || isArguments(value))) {
|
(isStrict || isArray(value) || isArguments(value))) {
|
||||||
if (isDeep) {
|
if (depth > 1) {
|
||||||
// Recursively flatten arrays (susceptible to call stack limits).
|
// Recursively flatten arrays (susceptible to call stack limits).
|
||||||
baseFlatten(value, isDeep, isStrict, result);
|
baseFlatten(value, depth - 1, isStrict, result);
|
||||||
} else {
|
} else {
|
||||||
arrayPush(result, value);
|
arrayPush(result, value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var baseToPath = require('./_baseToPath'),
|
var baseCastPath = require('./_baseCastPath'),
|
||||||
isKey = require('./_isKey');
|
isKey = require('./_isKey');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10,7 +10,7 @@ var baseToPath = require('./_baseToPath'),
|
|||||||
* @returns {*} Returns the resolved value.
|
* @returns {*} Returns the resolved value.
|
||||||
*/
|
*/
|
||||||
function baseGet(object, path) {
|
function baseGet(object, path) {
|
||||||
path = isKey(path, object) ? [path + ''] : baseToPath(path);
|
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
|
||||||
|
|
||||||
var index = 0,
|
var index = 0,
|
||||||
length = path.length;
|
length = path.length;
|
||||||
|
|||||||
@@ -42,11 +42,17 @@ function baseIntersection(arrays, iteratee, comparator) {
|
|||||||
var value = array[index],
|
var value = array[index],
|
||||||
computed = iteratee ? iteratee(value) : value;
|
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;
|
var othIndex = othLength;
|
||||||
while (--othIndex) {
|
while (--othIndex) {
|
||||||
var cache = caches[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;
|
continue outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
var apply = require('./_apply'),
|
var apply = require('./_apply'),
|
||||||
baseToPath = require('./_baseToPath'),
|
baseCastPath = require('./_baseCastPath'),
|
||||||
isKey = require('./_isKey'),
|
isKey = require('./_isKey'),
|
||||||
last = require('./last'),
|
last = require('./last'),
|
||||||
parent = require('./_parent');
|
parent = require('./_parent');
|
||||||
@@ -16,7 +16,7 @@ var apply = require('./_apply'),
|
|||||||
*/
|
*/
|
||||||
function baseInvoke(object, path, args) {
|
function baseInvoke(object, path, args) {
|
||||||
if (!isKey(path, object)) {
|
if (!isKey(path, object)) {
|
||||||
path = baseToPath(path);
|
path = baseCastPath(path);
|
||||||
object = parent(object, path);
|
object = parent(object, path);
|
||||||
path = last(path);
|
path = last(path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ var nativeKeys = Object.keys;
|
|||||||
* property of prototypes or treat sparse arrays as dense.
|
* property of prototypes or treat sparse arrays as dense.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @type Function
|
|
||||||
* @param {Object} object The object to query.
|
* @param {Object} object The object to query.
|
||||||
* @returns {Array} Returns the array of property names.
|
* @returns {Array} Returns the array of property names.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -21,7 +21,10 @@ function baseMerge(object, source, srcIndex, customizer, stack) {
|
|||||||
if (object === source) {
|
if (object === source) {
|
||||||
return;
|
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) {
|
arrayEach(props || source, function(srcValue, key) {
|
||||||
if (props) {
|
if (props) {
|
||||||
key = srcValue;
|
key = srcValue;
|
||||||
@@ -32,7 +35,10 @@ function baseMerge(object, source, srcIndex, customizer, stack) {
|
|||||||
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
||||||
}
|
}
|
||||||
else {
|
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) {
|
if (newValue === undefined) {
|
||||||
newValue = srcValue;
|
newValue = srcValue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,21 +33,24 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
|
|||||||
assignMergeValue(object, key, stacked);
|
assignMergeValue(object, key, stacked);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var newValue = customizer ? customizer(objValue, srcValue, (key + ''), object, source, stack) : undefined,
|
var newValue = customizer
|
||||||
isCommon = newValue === undefined;
|
? customizer(objValue, srcValue, (key + ''), object, source, stack)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
var isCommon = newValue === undefined;
|
||||||
|
|
||||||
if (isCommon) {
|
if (isCommon) {
|
||||||
newValue = srcValue;
|
newValue = srcValue;
|
||||||
if (isArray(srcValue) || isTypedArray(srcValue)) {
|
if (isArray(srcValue) || isTypedArray(srcValue)) {
|
||||||
if (isArray(objValue)) {
|
if (isArray(objValue)) {
|
||||||
newValue = srcIndex ? copyArray(objValue) : objValue;
|
newValue = objValue;
|
||||||
}
|
}
|
||||||
else if (isArrayLikeObject(objValue)) {
|
else if (isArrayLikeObject(objValue)) {
|
||||||
newValue = copyArray(objValue);
|
newValue = copyArray(objValue);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
isCommon = false;
|
isCommon = false;
|
||||||
newValue = baseClone(srcValue);
|
newValue = baseClone(srcValue, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
||||||
@@ -56,10 +59,10 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
|
|||||||
}
|
}
|
||||||
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
||||||
isCommon = false;
|
isCommon = false;
|
||||||
newValue = baseClone(srcValue);
|
newValue = baseClone(srcValue, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
newValue = srcIndex ? baseClone(objValue) : objValue;
|
newValue = objValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var baseToPath = require('./_baseToPath'),
|
var baseCastPath = require('./_baseCastPath'),
|
||||||
isIndex = require('./_isIndex'),
|
isIndex = require('./_isIndex'),
|
||||||
isKey = require('./_isKey'),
|
isKey = require('./_isKey'),
|
||||||
last = require('./last'),
|
last = require('./last'),
|
||||||
@@ -31,7 +31,7 @@ function basePullAt(array, indexes) {
|
|||||||
splice.call(array, index, 1);
|
splice.call(array, index, 1);
|
||||||
}
|
}
|
||||||
else if (!isKey(index, array)) {
|
else if (!isKey(index, array)) {
|
||||||
var path = baseToPath(index),
|
var path = baseCastPath(index),
|
||||||
object = parent(array, path);
|
object = parent(array, path);
|
||||||
|
|
||||||
if (object != null) {
|
if (object != null) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
var assignValue = require('./_assignValue'),
|
var assignValue = require('./_assignValue'),
|
||||||
baseToPath = require('./_baseToPath'),
|
baseCastPath = require('./_baseCastPath'),
|
||||||
isIndex = require('./_isIndex'),
|
isIndex = require('./_isIndex'),
|
||||||
isKey = require('./_isKey'),
|
isKey = require('./_isKey'),
|
||||||
isObject = require('./isObject');
|
isObject = require('./isObject');
|
||||||
@@ -15,7 +15,7 @@ var assignValue = require('./_assignValue'),
|
|||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
*/
|
*/
|
||||||
function baseSet(object, path, value, customizer) {
|
function baseSet(object, path, value, customizer) {
|
||||||
path = isKey(path, object) ? [path + ''] : baseToPath(path);
|
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
|
||||||
|
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = path.length,
|
length = path.length,
|
||||||
@@ -30,7 +30,9 @@ function baseSet(object, path, value, customizer) {
|
|||||||
var objValue = nested[key];
|
var objValue = nested[key];
|
||||||
newValue = customizer ? customizer(objValue, key, nested) : undefined;
|
newValue = customizer ? customizer(objValue, key, nested) : undefined;
|
||||||
if (newValue === undefined) {
|
if (newValue === undefined) {
|
||||||
newValue = objValue == null ? (isIndex(path[index + 1]) ? [] : {}) : objValue;
|
newValue = objValue == null
|
||||||
|
? (isIndex(path[index + 1]) ? [] : {})
|
||||||
|
: objValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assignValue(nested, key, newValue);
|
assignValue(nested, key, newValue);
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
var isArray = require('./isArray'),
|
|
||||||
stringToPath = require('./_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);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = baseToPath;
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
var baseToPath = require('./_baseToPath'),
|
var baseCastPath = require('./_baseCastPath'),
|
||||||
has = require('./has'),
|
has = require('./has'),
|
||||||
isKey = require('./_isKey'),
|
isKey = require('./_isKey'),
|
||||||
last = require('./last'),
|
last = require('./last'),
|
||||||
@@ -13,7 +13,7 @@ var baseToPath = require('./_baseToPath'),
|
|||||||
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
|
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
|
||||||
*/
|
*/
|
||||||
function baseUnset(object, path) {
|
function baseUnset(object, path) {
|
||||||
path = isKey(path, object) ? [path + ''] : baseToPath(path);
|
path = isKey(path, object) ? [path + ''] : baseCastPath(path);
|
||||||
object = parent(object, path);
|
object = parent(object, path);
|
||||||
var key = last(path);
|
var key = last(path);
|
||||||
return (object != null && has(object, key)) ? delete object[key] : true;
|
return (object != null && has(object, key)) ? delete object[key] : true;
|
||||||
|
|||||||
@@ -9,10 +9,11 @@ var cloneArrayBuffer = require('./_cloneArrayBuffer');
|
|||||||
* @returns {Object} Returns the cloned typed array.
|
* @returns {Object} Returns the cloned typed array.
|
||||||
*/
|
*/
|
||||||
function cloneTypedArray(typedArray, isDeep) {
|
function cloneTypedArray(typedArray, isDeep) {
|
||||||
var buffer = typedArray.buffer,
|
var arrayBuffer = typedArray.buffer,
|
||||||
|
buffer = isDeep ? cloneArrayBuffer(arrayBuffer) : arrayBuffer,
|
||||||
Ctor = typedArray.constructor;
|
Ctor = typedArray.constructor;
|
||||||
|
|
||||||
return new Ctor(isDeep ? cloneArrayBuffer(buffer) : buffer, typedArray.byteOffset, typedArray.length);
|
return new Ctor(buffer, typedArray.byteOffset, typedArray.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = cloneTypedArray;
|
module.exports = cloneTypedArray;
|
||||||
|
|||||||
@@ -18,8 +18,11 @@ function copyObjectWith(source, props, object, customizer) {
|
|||||||
length = props.length;
|
length = props.length;
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var key = props[index],
|
var key = props[index];
|
||||||
newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key];
|
|
||||||
|
var newValue = customizer
|
||||||
|
? customizer(object[key], source[key], key, object, source)
|
||||||
|
: source[key];
|
||||||
|
|
||||||
assignValue(object, key, newValue);
|
assignValue(object, key, newValue);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,10 @@ function createAssigner(assigner) {
|
|||||||
customizer = length > 1 ? sources[length - 1] : undefined,
|
customizer = length > 1 ? sources[length - 1] : undefined,
|
||||||
guard = length > 2 ? sources[2] : undefined;
|
guard = length > 2 ? sources[2] : undefined;
|
||||||
|
|
||||||
customizer = typeof customizer == 'function' ? (length--, customizer) : undefined;
|
customizer = typeof customizer == 'function'
|
||||||
|
? (length--, customizer)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
||||||
customizer = length < 3 ? undefined : customizer;
|
customizer = length < 3 ? undefined : customizer;
|
||||||
length = 1;
|
length = 1;
|
||||||
|
|||||||
@@ -24,8 +24,11 @@ function createCaseFirst(methodName) {
|
|||||||
return function(string) {
|
return function(string) {
|
||||||
string = toString(string);
|
string = toString(string);
|
||||||
|
|
||||||
var strSymbols = reHasComplexSymbol.test(string) ? stringToArray(string) : undefined,
|
var strSymbols = reHasComplexSymbol.test(string)
|
||||||
chr = strSymbols ? strSymbols[0] : string.charAt(0),
|
? stringToArray(string)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
var chr = strSymbols ? strSymbols[0] : string.charAt(0),
|
||||||
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
|
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
|
||||||
|
|
||||||
return chr[methodName]() + trailing;
|
return chr[methodName]() + trailing;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ var FUNC_ERROR_TEXT = 'Expected a function';
|
|||||||
*/
|
*/
|
||||||
function createFlow(fromRight) {
|
function createFlow(fromRight) {
|
||||||
return rest(function(funcs) {
|
return rest(function(funcs) {
|
||||||
funcs = baseFlatten(funcs);
|
funcs = baseFlatten(funcs, 1);
|
||||||
|
|
||||||
var length = funcs.length,
|
var length = funcs.length,
|
||||||
index = length,
|
index = length,
|
||||||
@@ -52,7 +52,10 @@ function createFlow(fromRight) {
|
|||||||
var funcName = getFuncName(func),
|
var funcName = getFuncName(func),
|
||||||
data = funcName == 'wrapper' ? getData(func) : undefined;
|
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]);
|
wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
|
||||||
} else {
|
} else {
|
||||||
wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);
|
wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);
|
||||||
@@ -62,7 +65,8 @@ function createFlow(fromRight) {
|
|||||||
var args = arguments,
|
var args = arguments,
|
||||||
value = args[0];
|
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();
|
return wrapper.plant(value).value();
|
||||||
}
|
}
|
||||||
var index = 0,
|
var index = 0,
|
||||||
|
|||||||
@@ -60,7 +60,10 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials
|
|||||||
|
|
||||||
length -= argsHolders.length;
|
length -= argsHolders.length;
|
||||||
if (length < arity) {
|
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,
|
var thisBinding = isBind ? thisArg : this,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ var apply = require('./_apply'),
|
|||||||
*/
|
*/
|
||||||
function createOver(arrayFunc) {
|
function createOver(arrayFunc) {
|
||||||
return rest(function(iteratees) {
|
return rest(function(iteratees) {
|
||||||
iteratees = arrayMap(baseFlatten(iteratees), baseIteratee);
|
iteratees = arrayMap(baseFlatten(iteratees, 1), baseIteratee);
|
||||||
return rest(function(args) {
|
return rest(function(args) {
|
||||||
var thisArg = this;
|
var thisArg = this;
|
||||||
return arrayFunc(iteratees, function(iteratee) {
|
return arrayFunc(iteratees, function(iteratee) {
|
||||||
|
|||||||
@@ -40,9 +40,12 @@ function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, par
|
|||||||
if (!(bitmask & CURRY_BOUND_FLAG)) {
|
if (!(bitmask & CURRY_BOUND_FLAG)) {
|
||||||
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
|
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
|
||||||
}
|
}
|
||||||
var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, arity],
|
var newData = [
|
||||||
result = wrapFunc.apply(undefined, newData);
|
func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight,
|
||||||
|
newHoldersRight, newArgPos, ary, arity
|
||||||
|
];
|
||||||
|
|
||||||
|
var result = wrapFunc.apply(undefined, newData);
|
||||||
if (isLaziable(func)) {
|
if (isLaziable(func)) {
|
||||||
setData(result, newData);
|
setData(result, newData);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,8 +67,12 @@ function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, a
|
|||||||
|
|
||||||
partials = holders = undefined;
|
partials = holders = undefined;
|
||||||
}
|
}
|
||||||
var data = isBindKey ? undefined : getData(func),
|
var data = isBindKey ? undefined : getData(func);
|
||||||
newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];
|
|
||||||
|
var newData = [
|
||||||
|
func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
|
||||||
|
argPos, ary, arity
|
||||||
|
];
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
mergeData(newData, data);
|
mergeData(newData, data);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var baseToPath = require('./_baseToPath'),
|
var baseCastPath = require('./_baseCastPath'),
|
||||||
isArguments = require('./isArguments'),
|
isArguments = require('./isArguments'),
|
||||||
isArray = require('./isArray'),
|
isArray = require('./isArray'),
|
||||||
isIndex = require('./_isIndex'),
|
isIndex = require('./_isIndex'),
|
||||||
@@ -23,7 +23,7 @@ function hasPath(object, path, hasFunc) {
|
|||||||
}
|
}
|
||||||
var result = hasFunc(object, path);
|
var result = hasFunc(object, path);
|
||||||
if (!result && !isKey(path)) {
|
if (!result && !isKey(path)) {
|
||||||
path = baseToPath(path);
|
path = baseCastPath(path);
|
||||||
object = parent(object, path);
|
object = parent(object, path);
|
||||||
if (object != null) {
|
if (object != null) {
|
||||||
path = last(path);
|
path = last(path);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
function isKeyable(value) {
|
function isKeyable(value) {
|
||||||
var type = typeof value;
|
var type = typeof value;
|
||||||
return type == 'number' || type == 'boolean' ||
|
return type == 'number' || type == 'boolean' ||
|
||||||
(type == 'string' && value !== '__proto__') || value == null;
|
(type == 'string' && value != '__proto__') || value == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = isKeyable;
|
module.exports = isKeyable;
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ function lazyValue() {
|
|||||||
resIndex = 0,
|
resIndex = 0,
|
||||||
takeCount = nativeMin(length, this.__takeCount__);
|
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__);
|
return baseWrapperValue(array, this.__actions__);
|
||||||
}
|
}
|
||||||
var result = [];
|
var result = [];
|
||||||
|
|||||||
@@ -9,7 +9,11 @@ var Hash = require('./_Hash'),
|
|||||||
* @memberOf MapCache
|
* @memberOf MapCache
|
||||||
*/
|
*/
|
||||||
function mapClear() {
|
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
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = mapClear;
|
module.exports = mapClear;
|
||||||
|
|||||||
12
_root.js
12
_root.js
@@ -7,10 +7,14 @@ var objectTypes = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Detect free variable `exports`. */
|
/** 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`. */
|
/** 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. */
|
/** Detect free variable `global` from Node.js. */
|
||||||
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
|
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
|
||||||
@@ -30,6 +34,8 @@ var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
|
|||||||
* The `this` value is used if it's the global object to avoid Greasemonkey's
|
* The `this` value is used if it's the global object to avoid Greasemonkey's
|
||||||
* restricted `window` object, otherwise the `window` object is used.
|
* 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')();
|
||||||
|
|
||||||
module.exports = root;
|
module.exports = root;
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
var isArrayLikeObject = require('./isArrayLikeObject');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts `value` to an array-like object if it's not one.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {*} value The value to process.
|
|
||||||
* @returns {Array} Returns the array-like object.
|
|
||||||
*/
|
|
||||||
function toArrayLikeObject(value) {
|
|
||||||
return isArrayLikeObject(value) ? value : [];
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = toArrayLikeObject;
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
var identity = require('./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;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = toFunction;
|
|
||||||
1
array.js
1
array.js
@@ -14,6 +14,7 @@ module.exports = {
|
|||||||
'findLastIndex': require('./findLastIndex'),
|
'findLastIndex': require('./findLastIndex'),
|
||||||
'flatten': require('./flatten'),
|
'flatten': require('./flatten'),
|
||||||
'flattenDeep': require('./flattenDeep'),
|
'flattenDeep': require('./flattenDeep'),
|
||||||
|
'flattenDepth': require('./flattenDepth'),
|
||||||
'fromPairs': require('./fromPairs'),
|
'fromPairs': require('./fromPairs'),
|
||||||
'head': require('./head'),
|
'head': require('./head'),
|
||||||
'indexOf': require('./indexOf'),
|
'indexOf': require('./indexOf'),
|
||||||
|
|||||||
2
at.js
2
at.js
@@ -23,7 +23,7 @@ var baseAt = require('./_baseAt'),
|
|||||||
* // => ['a', 'c']
|
* // => ['a', 'c']
|
||||||
*/
|
*/
|
||||||
var at = rest(function(object, paths) {
|
var at = rest(function(object, paths) {
|
||||||
return baseAt(object, baseFlatten(paths));
|
return baseAt(object, baseFlatten(paths, 1));
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = at;
|
module.exports = at;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
var apply = require('./_apply'),
|
var apply = require('./_apply'),
|
||||||
isObject = require('./isObject'),
|
isError = require('./isError'),
|
||||||
rest = require('./rest');
|
rest = require('./rest');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,7 +26,7 @@ var attempt = rest(function(func, args) {
|
|||||||
try {
|
try {
|
||||||
return apply(func, undefined, args);
|
return apply(func, undefined, args);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return isObject(e) ? e : new Error(e);
|
return isError(e) ? e : new Error(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ var arrayEach = require('./_arrayEach'),
|
|||||||
* // => logs 'clicked docs' when clicked
|
* // => logs 'clicked docs' when clicked
|
||||||
*/
|
*/
|
||||||
var bindAll = rest(function(object, methodNames) {
|
var bindAll = rest(function(object, methodNames) {
|
||||||
arrayEach(baseFlatten(methodNames), function(key) {
|
arrayEach(baseFlatten(methodNames, 1), function(key) {
|
||||||
object[key] = bind(object[key], object);
|
object[key] = bind(object[key], object);
|
||||||
});
|
});
|
||||||
return object;
|
return object;
|
||||||
|
|||||||
43
castArray.js
Normal file
43
castArray.js
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
var isArray = require('./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];
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = castArray;
|
||||||
@@ -28,7 +28,7 @@ var concat = rest(function(array, values) {
|
|||||||
if (!isArray(array)) {
|
if (!isArray(array)) {
|
||||||
array = array == null ? [] : [Object(array)];
|
array = array == null ? [] : [Object(array)];
|
||||||
}
|
}
|
||||||
values = baseFlatten(values);
|
values = baseFlatten(values, 1);
|
||||||
return arrayConcat(array, values);
|
return arrayConcat(array, values);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
175
core.js
175
core.js
@@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @license
|
* @license
|
||||||
* lodash 4.3.0 (Custom Build) <https://lodash.com/>
|
* lodash 4.4.0 (Custom Build) <https://lodash.com/>
|
||||||
* Build: `lodash core -o ./dist/lodash.core.js`
|
* Build: `lodash core -o ./dist/lodash.core.js`
|
||||||
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
|
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
|
||||||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
var undefined;
|
var undefined;
|
||||||
|
|
||||||
/** Used as the semantic version number. */
|
/** Used as the semantic version number. */
|
||||||
var VERSION = '4.3.0';
|
var VERSION = '4.4.0';
|
||||||
|
|
||||||
/** Used to compose bitmasks for wrapper metadata. */
|
/** Used to compose bitmasks for wrapper metadata. */
|
||||||
var BIND_FLAG = 1,
|
var BIND_FLAG = 1,
|
||||||
@@ -27,7 +27,8 @@
|
|||||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||||
|
|
||||||
/** Used as references for various `Number` constants. */
|
/** Used as references for various `Number` constants. */
|
||||||
var MAX_SAFE_INTEGER = 9007199254740991;
|
var INFINITY = 1 / 0,
|
||||||
|
MAX_SAFE_INTEGER = 9007199254740991;
|
||||||
|
|
||||||
/** `Object#toString` result references. */
|
/** `Object#toString` result references. */
|
||||||
var argsTag = '[object Arguments]',
|
var argsTag = '[object Arguments]',
|
||||||
@@ -66,10 +67,19 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Detect free variable `exports`. */
|
/** 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`. */
|
/** 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 the popular CommonJS extension `module.exports`. */
|
||||||
|
var moduleExports = (freeModule && freeModule.exports === freeExports)
|
||||||
|
? freeExports
|
||||||
|
: undefined;
|
||||||
|
|
||||||
/** Detect free variable `global` from Node.js. */
|
/** Detect free variable `global` from Node.js. */
|
||||||
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
|
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
|
||||||
@@ -80,9 +90,6 @@
|
|||||||
/** Detect free variable `window`. */
|
/** Detect free variable `window`. */
|
||||||
var freeWindow = checkGlobal(objectTypes[typeof window] && window);
|
var freeWindow = checkGlobal(objectTypes[typeof window] && window);
|
||||||
|
|
||||||
/** Detect the popular CommonJS extension `module.exports`. */
|
|
||||||
var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : null;
|
|
||||||
|
|
||||||
/** Detect `this` as the global object. */
|
/** Detect `this` as the global object. */
|
||||||
var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
|
var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
|
||||||
|
|
||||||
@@ -92,7 +99,9 @@
|
|||||||
* The `this` value is used if it's the global object to avoid Greasemonkey's
|
* The `this` value is used if it's the global object to avoid Greasemonkey's
|
||||||
* restricted `window` object, otherwise the `window` object is used.
|
* 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')();
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@@ -365,6 +374,7 @@
|
|||||||
Symbol = root.Symbol,
|
Symbol = root.Symbol,
|
||||||
Uint8Array = root.Uint8Array,
|
Uint8Array = root.Uint8Array,
|
||||||
enumerate = Reflect ? Reflect.enumerate : undefined,
|
enumerate = Reflect ? Reflect.enumerate : undefined,
|
||||||
|
objectCreate = Object.create,
|
||||||
propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
||||||
|
|
||||||
/* 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. */
|
||||||
@@ -413,28 +423,28 @@
|
|||||||
* `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
|
* `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
|
||||||
*
|
*
|
||||||
* The chainable wrapper methods are:
|
* The chainable wrapper methods are:
|
||||||
* `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`,
|
* `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
|
||||||
* `at`, `before`, `bind`, `bindAll`, `bindKey`, `chain`, `chunk`, `commit`,
|
* `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
|
||||||
* `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, `curry`,
|
* `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
|
||||||
* `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`,
|
* `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`,
|
||||||
* `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`,
|
* `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`,
|
||||||
* `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flip`, `flow`,
|
* `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flattenDepth`,
|
||||||
* `flowRight`, `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`,
|
* `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, `functionsIn`,
|
||||||
* `intersection`, `intersectionBy`, `intersectionWith`, `invert`, `invertBy`,
|
* `groupBy`, `initial`, `intersection`, `intersectionBy`, `intersectionWith`,
|
||||||
* `invokeMap`, `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`,
|
* `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, `keys`, `keysIn`,
|
||||||
* `mapValues`, `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`,
|
* `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, `memoize`,
|
||||||
* `method`, `methodOf`, `mixin`, `negate`, `nthArg`, `omit`, `omitBy`, `once`,
|
* `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, `nthArg`,
|
||||||
* `orderBy`, `over`, `overArgs`, `overEvery`, `overSome`, `partial`,
|
* `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, `overEvery`,
|
||||||
* `partialRight`, `partition`, `pick`, `pickBy`, `plant`, `property`,
|
* `overSome`, `partial`, `partialRight`, `partition`, `pick`, `pickBy`, `plant`,
|
||||||
* `propertyOf`, `pull`, `pullAll`, `pullAllBy`, `pullAt`, `push`, `range`,
|
* `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, `pullAt`, `push`,
|
||||||
* `rangeRight`, `rearg`, `reject`, `remove`, `rest`, `reverse`, `sampleSize`,
|
* `range`, `rangeRight`, `rearg`, `reject`, `remove`, `rest`, `reverse`,
|
||||||
* `set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `spread`,
|
* `sampleSize`, `set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`,
|
||||||
* `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`,
|
* `splice`, `spread`, `tail`, `take`, `takeRight`, `takeRightWhile`,
|
||||||
* `thru`, `toArray`, `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`,
|
* `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, `toPairs`, `toPairsIn`,
|
||||||
* `transform`, `unary`, `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`,
|
* `toPath`, `toPlainObject`, `transform`, `unary`, `union`, `unionBy`,
|
||||||
* `uniqWith`, `unset`, `unshift`, `unzip`, `unzipWith`, `values`, `valuesIn`,
|
* `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, `unshift`, `unzip`,
|
||||||
* `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, `zipObject`,
|
* `unzipWith`, `values`, `valuesIn`, `without`, `wrap`, `xor`, `xorBy`,
|
||||||
* `zipObjectDeep`, and `zipWith`
|
* `xorWith`, `zip`, `zipObject`, `zipObjectDeep`, and `zipWith`
|
||||||
*
|
*
|
||||||
* The wrapper methods that are **not** chainable by default are:
|
* The wrapper methods that are **not** chainable by default are:
|
||||||
* `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
|
* `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
|
||||||
@@ -549,6 +559,17 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.create` without support for assigning
|
* The base implementation of `_.create` without support for assigning
|
||||||
* properties to the created object.
|
* properties to the created object.
|
||||||
@@ -557,17 +578,9 @@
|
|||||||
* @param {Object} prototype The object to inherit from.
|
* @param {Object} prototype The object to inherit from.
|
||||||
* @returns {Object} Returns the new object.
|
* @returns {Object} Returns the new object.
|
||||||
*/
|
*/
|
||||||
var baseCreate = (function() {
|
function baseCreate(proto) {
|
||||||
function object() {}
|
return isObject(proto) ? objectCreate(proto) : {};
|
||||||
return function(prototype) {
|
}
|
||||||
if (isObject(prototype)) {
|
|
||||||
object.prototype = prototype;
|
|
||||||
var result = new object;
|
|
||||||
object.prototype = undefined;
|
|
||||||
}
|
|
||||||
return result || {};
|
|
||||||
};
|
|
||||||
}());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.delay` and `_.defer` which accepts an array
|
* The base implementation of `_.delay` and `_.defer` which accepts an array
|
||||||
@@ -636,12 +649,12 @@
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to flatten.
|
* @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 {boolean} [isStrict] Restrict flattening to arrays-like objects.
|
||||||
* @param {Array} [result=[]] The initial result value.
|
* @param {Array} [result=[]] The initial result value.
|
||||||
* @returns {Array} Returns the new flattened array.
|
* @returns {Array} Returns the new flattened array.
|
||||||
*/
|
*/
|
||||||
function baseFlatten(array, isDeep, isStrict, result) {
|
function baseFlatten(array, depth, isStrict, result) {
|
||||||
result || (result = []);
|
result || (result = []);
|
||||||
|
|
||||||
var index = -1,
|
var index = -1,
|
||||||
@@ -649,11 +662,11 @@
|
|||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var value = array[index];
|
var value = array[index];
|
||||||
if (isArrayLikeObject(value) &&
|
if (depth > 0 && isArrayLikeObject(value) &&
|
||||||
(isStrict || isArray(value) || isArguments(value))) {
|
(isStrict || isArray(value) || isArguments(value))) {
|
||||||
if (isDeep) {
|
if (depth > 1) {
|
||||||
// Recursively flatten arrays (susceptible to call stack limits).
|
// Recursively flatten arrays (susceptible to call stack limits).
|
||||||
baseFlatten(value, isDeep, isStrict, result);
|
baseFlatten(value, depth - 1, isStrict, result);
|
||||||
} else {
|
} else {
|
||||||
arrayPush(result, value);
|
arrayPush(result, value);
|
||||||
}
|
}
|
||||||
@@ -816,7 +829,6 @@
|
|||||||
* property of prototypes or treat sparse arrays as dense.
|
* property of prototypes or treat sparse arrays as dense.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @type Function
|
|
||||||
* @param {Object} object The object to query.
|
* @param {Object} object The object to query.
|
||||||
* @returns {Array} Returns the array of property names.
|
* @returns {Array} Returns the array of property names.
|
||||||
*/
|
*/
|
||||||
@@ -1032,8 +1044,11 @@
|
|||||||
length = props.length;
|
length = props.length;
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var key = props[index],
|
var key = props[index];
|
||||||
newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key];
|
|
||||||
|
var newValue = customizer
|
||||||
|
? customizer(object[key], source[key], key, object, source)
|
||||||
|
: source[key];
|
||||||
|
|
||||||
assignValue(object, key, newValue);
|
assignValue(object, key, newValue);
|
||||||
}
|
}
|
||||||
@@ -1053,7 +1068,10 @@
|
|||||||
length = sources.length,
|
length = sources.length,
|
||||||
customizer = length > 1 ? sources[length - 1] : undefined;
|
customizer = length > 1 ? sources[length - 1] : undefined;
|
||||||
|
|
||||||
customizer = typeof customizer == 'function' ? (length--, customizer) : undefined;
|
customizer = typeof customizer == 'function'
|
||||||
|
? (length--, customizer)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
object = Object(object);
|
object = Object(object);
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var source = sources[index];
|
var source = sources[index];
|
||||||
@@ -1382,17 +1400,6 @@
|
|||||||
return value === proto;
|
return value === proto;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a clone of `wrapper`.
|
* Creates a clone of `wrapper`.
|
||||||
*
|
*
|
||||||
@@ -1451,12 +1458,12 @@
|
|||||||
if (!isArray(array)) {
|
if (!isArray(array)) {
|
||||||
array = array == null ? [] : [Object(array)];
|
array = array == null ? [] : [Object(array)];
|
||||||
}
|
}
|
||||||
values = baseFlatten(values);
|
values = baseFlatten(values, 1);
|
||||||
return arrayConcat(array, values);
|
return arrayConcat(array, values);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flattens `array` a single level.
|
* Flattens `array` a single level deep.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -1465,30 +1472,30 @@
|
|||||||
* @returns {Array} Returns the new flattened array.
|
* @returns {Array} Returns the new flattened array.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.flatten([1, [2, 3, [4]]]);
|
* _.flatten([1, [2, [3, [4]], 5]]);
|
||||||
* // => [1, 2, 3, [4]]
|
* // => [1, 2, [3, [4]], 5]
|
||||||
*/
|
*/
|
||||||
function flatten(array) {
|
function flatten(array) {
|
||||||
var length = array ? array.length : 0;
|
var length = array ? array.length : 0;
|
||||||
return length ? baseFlatten(array) : [];
|
return length ? baseFlatten(array, 1) : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.flatten` except that it recursively flattens `array`.
|
* Recursively flattens `array`.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Array
|
* @category Array
|
||||||
* @param {Array} array The array to recursively flatten.
|
* @param {Array} array The array to flatten.
|
||||||
* @returns {Array} Returns the new flattened array.
|
* @returns {Array} Returns the new flattened array.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.flattenDeep([1, [2, 3, [4]]]);
|
* _.flattenDeep([1, [2, [3, [4]], 5]]);
|
||||||
* // => [1, 2, 3, 4]
|
* // => [1, 2, 3, 4, 5]
|
||||||
*/
|
*/
|
||||||
function flattenDeep(array) {
|
function flattenDeep(array) {
|
||||||
var length = array ? array.length : 0;
|
var length = array ? array.length : 0;
|
||||||
return length ? baseFlatten(array, true) : [];
|
return length ? baseFlatten(array, INFINITY) : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1872,7 +1879,7 @@
|
|||||||
* // => logs 'a' then 'b' (iteration order is not guaranteed)
|
* // => logs 'a' then 'b' (iteration order is not guaranteed)
|
||||||
*/
|
*/
|
||||||
function forEach(collection, iteratee) {
|
function forEach(collection, iteratee) {
|
||||||
return baseEach(collection, toFunction(iteratee));
|
return baseEach(collection, baseCastFunction(iteratee));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2400,7 +2407,7 @@
|
|||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @type Function
|
* @type {Function}
|
||||||
* @category Lang
|
* @category Lang
|
||||||
* @param {*} value The value to check.
|
* @param {*} value The value to check.
|
||||||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||||||
@@ -2427,7 +2434,6 @@
|
|||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @type Function
|
|
||||||
* @category Lang
|
* @category Lang
|
||||||
* @param {*} value The value to check.
|
* @param {*} value The value to check.
|
||||||
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
||||||
@@ -2456,7 +2462,6 @@
|
|||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @type Function
|
|
||||||
* @category Lang
|
* @category Lang
|
||||||
* @param {*} value The value to check.
|
* @param {*} value The value to check.
|
||||||
* @returns {boolean} Returns `true` if `value` is an array-like object, else `false`.
|
* @returns {boolean} Returns `true` if `value` is an array-like object, else `false`.
|
||||||
@@ -2548,7 +2553,8 @@
|
|||||||
*/
|
*/
|
||||||
function isEmpty(value) {
|
function isEmpty(value) {
|
||||||
if (isArrayLike(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;
|
return !value.length;
|
||||||
}
|
}
|
||||||
for (var key in value) {
|
for (var key in value) {
|
||||||
@@ -2667,7 +2673,8 @@
|
|||||||
* // => false
|
* // => false
|
||||||
*/
|
*/
|
||||||
function isLength(value) {
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3295,7 +3302,7 @@
|
|||||||
* // => { 'a': 1, 'c': 3 }
|
* // => { 'a': 1, 'c': 3 }
|
||||||
*/
|
*/
|
||||||
var pick = rest(function(object, props) {
|
var pick = rest(function(object, props) {
|
||||||
return object == null ? {} : basePick(object, baseFlatten(props));
|
return object == null ? {} : basePick(object, baseFlatten(props, 1));
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3429,7 +3436,8 @@
|
|||||||
* Creates a function that invokes `func` with the arguments of the created
|
* Creates a function that invokes `func` with the arguments of the created
|
||||||
* function. If `func` is a property name the created callback returns the
|
* 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
|
* 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
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -3457,9 +3465,10 @@
|
|||||||
var iteratee = baseIteratee;
|
var iteratee = baseIteratee;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
* 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`.
|
* **Note:** This method supports comparing the same values as `_.isEqual`.
|
||||||
*
|
*
|
||||||
@@ -3597,7 +3606,7 @@
|
|||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Util
|
* @category Util
|
||||||
* @param {string} [prefix] The value to prefix the ID with.
|
* @param {string} [prefix=''] The value to prefix the ID with.
|
||||||
* @returns {string} Returns the unique ID.
|
* @returns {string} Returns the unique ID.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -3759,7 +3768,7 @@
|
|||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @type string
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
lodash.VERSION = VERSION;
|
lodash.VERSION = VERSION;
|
||||||
|
|
||||||
|
|||||||
@@ -138,8 +138,10 @@ function debounce(func, wait, options) {
|
|||||||
if (!lastCalled && !maxTimeoutId && !leading) {
|
if (!lastCalled && !maxTimeoutId && !leading) {
|
||||||
lastCalled = stamp;
|
lastCalled = stamp;
|
||||||
}
|
}
|
||||||
var remaining = maxWait - (stamp - lastCalled),
|
var remaining = maxWait - (stamp - lastCalled);
|
||||||
isCalled = remaining <= 0 || remaining > maxWait;
|
|
||||||
|
var isCalled = (remaining <= 0 || remaining > maxWait) &&
|
||||||
|
(leading || maxTimeoutId);
|
||||||
|
|
||||||
if (isCalled) {
|
if (isCalled) {
|
||||||
if (maxTimeoutId) {
|
if (maxTimeoutId) {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ var baseDifference = require('./_baseDifference'),
|
|||||||
*/
|
*/
|
||||||
var difference = rest(function(array, values) {
|
var difference = rest(function(array, values) {
|
||||||
return isArrayLikeObject(array)
|
return isArrayLikeObject(array)
|
||||||
? baseDifference(array, baseFlatten(values, false, true))
|
? baseDifference(array, baseFlatten(values, 1, true))
|
||||||
: [];
|
: [];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ var differenceBy = rest(function(array, values) {
|
|||||||
iteratee = undefined;
|
iteratee = undefined;
|
||||||
}
|
}
|
||||||
return isArrayLikeObject(array)
|
return isArrayLikeObject(array)
|
||||||
? baseDifference(array, baseFlatten(values, false, true), baseIteratee(iteratee))
|
? baseDifference(array, baseFlatten(values, 1, true), baseIteratee(iteratee))
|
||||||
: [];
|
: [];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ var differenceWith = rest(function(array, values) {
|
|||||||
comparator = undefined;
|
comparator = undefined;
|
||||||
}
|
}
|
||||||
return isArrayLikeObject(array)
|
return isArrayLikeObject(array)
|
||||||
? baseDifference(array, baseFlatten(values, false, true), undefined, comparator)
|
? baseDifference(array, baseFlatten(values, 1, true), undefined, comparator)
|
||||||
: [];
|
: [];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ var baseFlatten = require('./_baseFlatten'),
|
|||||||
* // => [1, 1, 2, 2]
|
* // => [1, 1, 2, 2]
|
||||||
*/
|
*/
|
||||||
function flatMap(collection, iteratee) {
|
function flatMap(collection, iteratee) {
|
||||||
return baseFlatten(map(collection, iteratee));
|
return baseFlatten(map(collection, iteratee), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = flatMap;
|
module.exports = flatMap;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
var baseFlatten = require('./_baseFlatten');
|
var baseFlatten = require('./_baseFlatten');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flattens `array` a single level.
|
* Flattens `array` a single level deep.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -10,12 +10,12 @@ var baseFlatten = require('./_baseFlatten');
|
|||||||
* @returns {Array} Returns the new flattened array.
|
* @returns {Array} Returns the new flattened array.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.flatten([1, [2, 3, [4]]]);
|
* _.flatten([1, [2, [3, [4]], 5]]);
|
||||||
* // => [1, 2, 3, [4]]
|
* // => [1, 2, [3, [4]], 5]
|
||||||
*/
|
*/
|
||||||
function flatten(array) {
|
function flatten(array) {
|
||||||
var length = array ? array.length : 0;
|
var length = array ? array.length : 0;
|
||||||
return length ? baseFlatten(array) : [];
|
return length ? baseFlatten(array, 1) : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = flatten;
|
module.exports = flatten;
|
||||||
|
|||||||
@@ -1,21 +1,24 @@
|
|||||||
var baseFlatten = require('./_baseFlatten');
|
var baseFlatten = require('./_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
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Array
|
* @category Array
|
||||||
* @param {Array} array The array to recursively flatten.
|
* @param {Array} array The array to flatten.
|
||||||
* @returns {Array} Returns the new flattened array.
|
* @returns {Array} Returns the new flattened array.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.flattenDeep([1, [2, 3, [4]]]);
|
* _.flattenDeep([1, [2, [3, [4]], 5]]);
|
||||||
* // => [1, 2, 3, 4]
|
* // => [1, 2, 3, 4, 5]
|
||||||
*/
|
*/
|
||||||
function flattenDeep(array) {
|
function flattenDeep(array) {
|
||||||
var length = array ? array.length : 0;
|
var length = array ? array.length : 0;
|
||||||
return length ? baseFlatten(array, true) : [];
|
return length ? baseFlatten(array, INFINITY) : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = flattenDeep;
|
module.exports = flattenDeep;
|
||||||
|
|||||||
32
flattenDepth.js
Normal file
32
flattenDepth.js
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
var baseFlatten = require('./_baseFlatten'),
|
||||||
|
toInteger = require('./toInteger');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = flattenDepth;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
var arrayEach = require('./_arrayEach'),
|
var arrayEach = require('./_arrayEach'),
|
||||||
|
baseCastFunction = require('./_baseCastFunction'),
|
||||||
baseEach = require('./_baseEach'),
|
baseEach = require('./_baseEach'),
|
||||||
isArray = require('./isArray'),
|
isArray = require('./isArray');
|
||||||
toFunction = require('./_toFunction');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates over elements of `collection` invoking `iteratee` for each element.
|
* Iterates over elements of `collection` invoking `iteratee` for each element.
|
||||||
@@ -34,7 +34,7 @@ var arrayEach = require('./_arrayEach'),
|
|||||||
function forEach(collection, iteratee) {
|
function forEach(collection, iteratee) {
|
||||||
return (typeof iteratee == 'function' && isArray(collection))
|
return (typeof iteratee == 'function' && isArray(collection))
|
||||||
? arrayEach(collection, iteratee)
|
? arrayEach(collection, iteratee)
|
||||||
: baseEach(collection, toFunction(iteratee));
|
: baseEach(collection, baseCastFunction(iteratee));
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = forEach;
|
module.exports = forEach;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
var arrayEachRight = require('./_arrayEachRight'),
|
var arrayEachRight = require('./_arrayEachRight'),
|
||||||
|
baseCastFunction = require('./_baseCastFunction'),
|
||||||
baseEachRight = require('./_baseEachRight'),
|
baseEachRight = require('./_baseEachRight'),
|
||||||
isArray = require('./isArray'),
|
isArray = require('./isArray');
|
||||||
toFunction = require('./_toFunction');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.forEach` except that it iterates over elements of
|
* This method is like `_.forEach` except that it iterates over elements of
|
||||||
@@ -24,7 +24,7 @@ var arrayEachRight = require('./_arrayEachRight'),
|
|||||||
function forEachRight(collection, iteratee) {
|
function forEachRight(collection, iteratee) {
|
||||||
return (typeof iteratee == 'function' && isArray(collection))
|
return (typeof iteratee == 'function' && isArray(collection))
|
||||||
? arrayEachRight(collection, iteratee)
|
? arrayEachRight(collection, iteratee)
|
||||||
: baseEachRight(collection, toFunction(iteratee));
|
: baseEachRight(collection, baseCastFunction(iteratee));
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = forEachRight;
|
module.exports = forEachRight;
|
||||||
|
|||||||
10
forIn.js
10
forIn.js
@@ -1,6 +1,6 @@
|
|||||||
var baseFor = require('./_baseFor'),
|
var baseCastFunction = require('./_baseCastFunction'),
|
||||||
keysIn = require('./keysIn'),
|
baseFor = require('./_baseFor'),
|
||||||
toFunction = require('./_toFunction');
|
keysIn = require('./keysIn');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates over own and inherited enumerable properties of an object invoking
|
* Iterates over own and inherited enumerable properties of an object invoking
|
||||||
@@ -29,7 +29,9 @@ var baseFor = require('./_baseFor'),
|
|||||||
* // => logs 'a', 'b', then 'c' (iteration order is not guaranteed)
|
* // => logs 'a', 'b', then 'c' (iteration order is not guaranteed)
|
||||||
*/
|
*/
|
||||||
function forIn(object, iteratee) {
|
function forIn(object, iteratee) {
|
||||||
return object == null ? object : baseFor(object, toFunction(iteratee), keysIn);
|
return object == null
|
||||||
|
? object
|
||||||
|
: baseFor(object, baseCastFunction(iteratee), keysIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = forIn;
|
module.exports = forIn;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
var baseForRight = require('./_baseForRight'),
|
var baseCastFunction = require('./_baseCastFunction'),
|
||||||
keysIn = require('./keysIn'),
|
baseForRight = require('./_baseForRight'),
|
||||||
toFunction = require('./_toFunction');
|
keysIn = require('./keysIn');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.forIn` except that it iterates over properties of
|
* This method is like `_.forIn` except that it iterates over properties of
|
||||||
@@ -27,7 +27,9 @@ var baseForRight = require('./_baseForRight'),
|
|||||||
* // => logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'
|
* // => logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'
|
||||||
*/
|
*/
|
||||||
function forInRight(object, iteratee) {
|
function forInRight(object, iteratee) {
|
||||||
return object == null ? object : baseForRight(object, toFunction(iteratee), keysIn);
|
return object == null
|
||||||
|
? object
|
||||||
|
: baseForRight(object, baseCastFunction(iteratee), keysIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = forInRight;
|
module.exports = forInRight;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
var baseForOwn = require('./_baseForOwn'),
|
var baseCastFunction = require('./_baseCastFunction'),
|
||||||
toFunction = require('./_toFunction');
|
baseForOwn = require('./_baseForOwn');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates over own enumerable properties of an object invoking `iteratee`
|
* Iterates over own enumerable properties of an object invoking `iteratee`
|
||||||
@@ -28,7 +28,7 @@ var baseForOwn = require('./_baseForOwn'),
|
|||||||
* // => logs 'a' then 'b' (iteration order is not guaranteed)
|
* // => logs 'a' then 'b' (iteration order is not guaranteed)
|
||||||
*/
|
*/
|
||||||
function forOwn(object, iteratee) {
|
function forOwn(object, iteratee) {
|
||||||
return object && baseForOwn(object, toFunction(iteratee));
|
return object && baseForOwn(object, baseCastFunction(iteratee));
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = forOwn;
|
module.exports = forOwn;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
var baseForOwnRight = require('./_baseForOwnRight'),
|
var baseCastFunction = require('./_baseCastFunction'),
|
||||||
toFunction = require('./_toFunction');
|
baseForOwnRight = require('./_baseForOwnRight');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.forOwn` except that it iterates over properties of
|
* This method is like `_.forOwn` except that it iterates over properties of
|
||||||
@@ -26,7 +26,7 @@ var baseForOwnRight = require('./_baseForOwnRight'),
|
|||||||
* // => logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'
|
* // => logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'
|
||||||
*/
|
*/
|
||||||
function forOwnRight(object, iteratee) {
|
function forOwnRight(object, iteratee) {
|
||||||
return object && baseForOwnRight(object, toFunction(iteratee));
|
return object && baseForOwnRight(object, baseCastFunction(iteratee));
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = forOwnRight;
|
module.exports = forOwnRight;
|
||||||
|
|||||||
2
fp.js
2
fp.js
@@ -1,2 +1,2 @@
|
|||||||
var _ = require('./lodash').noConflict().runInContext();
|
var _ = require('./lodash').runInContext();
|
||||||
module.exports = require('./fp/convert')(_);
|
module.exports = require('./fp/convert')(_);
|
||||||
|
|||||||
@@ -18,15 +18,20 @@ var mapping = require('./_mapping'),
|
|||||||
* @returns {Function|Object} Returns the converted function or object.
|
* @returns {Function|Object} Returns the converted function or object.
|
||||||
*/
|
*/
|
||||||
function baseConvert(util, name, func, options) {
|
function baseConvert(util, name, func, options) {
|
||||||
options || (options = {});
|
var setPlaceholder,
|
||||||
|
isLib = typeof name == 'function',
|
||||||
|
isObj = name === Object(name);
|
||||||
|
|
||||||
if (typeof func != 'function') {
|
if (isObj) {
|
||||||
|
options = func;
|
||||||
func = name;
|
func = name;
|
||||||
name = undefined;
|
name = undefined;
|
||||||
}
|
}
|
||||||
if (func == null) {
|
if (func == null) {
|
||||||
throw new TypeError;
|
throw new TypeError;
|
||||||
}
|
}
|
||||||
|
options || (options = {});
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
'cap': 'cap' in options ? options.cap : true,
|
'cap': 'cap' in options ? options.cap : true,
|
||||||
'curry': 'curry' in options ? options.curry : true,
|
'curry': 'curry' in options ? options.curry : true,
|
||||||
@@ -37,13 +42,12 @@ function baseConvert(util, name, func, options) {
|
|||||||
|
|
||||||
var forceRearg = ('rearg' in options) && options.rearg;
|
var forceRearg = ('rearg' in options) && options.rearg;
|
||||||
|
|
||||||
var isLib = name === undefined && typeof func.VERSION == 'string';
|
var helpers = isLib ? func : {
|
||||||
|
|
||||||
var _ = isLib ? func : {
|
|
||||||
'ary': util.ary,
|
'ary': util.ary,
|
||||||
'cloneDeep': util.cloneDeep,
|
'cloneDeep': util.cloneDeep,
|
||||||
'curry': util.curry,
|
'curry': util.curry,
|
||||||
'forEach': util.forEach,
|
'forEach': util.forEach,
|
||||||
|
'isArray': util.isArray,
|
||||||
'isFunction': util.isFunction,
|
'isFunction': util.isFunction,
|
||||||
'iteratee': util.iteratee,
|
'iteratee': util.iteratee,
|
||||||
'keys': util.keys,
|
'keys': util.keys,
|
||||||
@@ -51,14 +55,17 @@ function baseConvert(util, name, func, options) {
|
|||||||
'spread': util.spread
|
'spread': util.spread
|
||||||
};
|
};
|
||||||
|
|
||||||
var ary = _.ary,
|
var ary = helpers.ary,
|
||||||
cloneDeep = _.cloneDeep,
|
cloneDeep = helpers.cloneDeep,
|
||||||
curry = _.curry,
|
curry = helpers.curry,
|
||||||
each = _.forEach,
|
each = helpers.forEach,
|
||||||
isFunction = _.isFunction,
|
isArray = helpers.isArray,
|
||||||
keys = _.keys,
|
isFunction = helpers.isFunction,
|
||||||
rearg = _.rearg,
|
keys = helpers.keys,
|
||||||
spread = _.spread;
|
rearg = helpers.rearg,
|
||||||
|
spread = helpers.spread;
|
||||||
|
|
||||||
|
var aryMethodKeys = keys(mapping.aryMethod);
|
||||||
|
|
||||||
var baseArity = function(func, n) {
|
var baseArity = function(func, n) {
|
||||||
return n == 2
|
return n == 2
|
||||||
@@ -89,7 +96,19 @@ function baseConvert(util, name, func, options) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var immutWrap = function(func, cloner) {
|
var immutWrap = function(func, cloner) {
|
||||||
return overArg(func, cloner, true);
|
return function() {
|
||||||
|
var length = arguments.length;
|
||||||
|
if (!length) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
var args = Array(length);
|
||||||
|
while (length--) {
|
||||||
|
args[length] = arguments[length];
|
||||||
|
}
|
||||||
|
var result = args[0] = cloner(args[0]);
|
||||||
|
func.apply(undefined, args);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
var iterateeAry = function(func, n) {
|
var iterateeAry = function(func, n) {
|
||||||
@@ -98,28 +117,31 @@ function baseConvert(util, name, func, options) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var iterateeRearg = function(func, indexes) {
|
|
||||||
return overArg(func, function(func) {
|
|
||||||
var n = indexes.length;
|
|
||||||
return baseArity(rearg(baseAry(func, n), indexes), n);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
var overArg = function(func, iteratee, retArg) {
|
var overArg = function(func, iteratee, retArg) {
|
||||||
return function() {
|
return function() {
|
||||||
var length = arguments.length,
|
var length = arguments.length;
|
||||||
args = Array(length);
|
if (!length) {
|
||||||
|
return func();
|
||||||
|
}
|
||||||
|
var args = Array(length);
|
||||||
while (length--) {
|
while (length--) {
|
||||||
args[length] = arguments[length];
|
args[length] = arguments[length];
|
||||||
}
|
}
|
||||||
args[0] = iteratee(args[0]);
|
var index = config.rearg ? 0 : (length - 1);
|
||||||
var result = func.apply(undefined, args);
|
args[index] = iteratee(args[index]);
|
||||||
return retArg ? args[0] : result;
|
return func.apply(undefined, args);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
var wrappers = {
|
var wrappers = {
|
||||||
|
'castArray': function(castArray) {
|
||||||
|
return function() {
|
||||||
|
var value = arguments[0];
|
||||||
|
return isArray(value)
|
||||||
|
? castArray(cloneArray(value))
|
||||||
|
: castArray.apply(undefined, arguments);
|
||||||
|
};
|
||||||
|
},
|
||||||
'iteratee': function(iteratee) {
|
'iteratee': function(iteratee) {
|
||||||
return function() {
|
return function() {
|
||||||
var func = arguments[0],
|
var func = arguments[0],
|
||||||
@@ -166,7 +188,7 @@ function baseConvert(util, name, func, options) {
|
|||||||
},
|
},
|
||||||
'runInContext': function(runInContext) {
|
'runInContext': function(runInContext) {
|
||||||
return function(context) {
|
return function(context) {
|
||||||
return baseConvert(util, runInContext(context), undefined, options);
|
return baseConvert(util, runInContext(context), options);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -190,30 +212,26 @@ function baseConvert(util, name, func, options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var result;
|
var result;
|
||||||
each(mapping.caps, function(cap) {
|
each(aryMethodKeys, function(aryKey) {
|
||||||
each(mapping.aryMethod[cap], function(otherName) {
|
each(mapping.aryMethod[aryKey], function(otherName) {
|
||||||
if (name == otherName) {
|
if (name == otherName) {
|
||||||
var aryN = !isLib && mapping.iterateeAry[name],
|
var aryN = !isLib && mapping.iterateeAry[name],
|
||||||
reargIndexes = mapping.iterateeRearg[name],
|
|
||||||
spreadStart = mapping.methodSpread[name];
|
spreadStart = mapping.methodSpread[name];
|
||||||
|
|
||||||
|
result = wrapped;
|
||||||
if (config.fixed) {
|
if (config.fixed) {
|
||||||
result = spreadStart === undefined
|
result = spreadStart === undefined
|
||||||
? ary(wrapped, cap)
|
? ary(result, aryKey)
|
||||||
: spread(wrapped, spreadStart);
|
: spread(result, spreadStart);
|
||||||
}
|
}
|
||||||
if (config.rearg && cap > 1 && (forceRearg || !mapping.skipRearg[name])) {
|
if (config.rearg && aryKey > 1 && (forceRearg || !mapping.skipRearg[name])) {
|
||||||
result = rearg(result, mapping.methodRearg[name] || mapping.aryRearg[cap]);
|
result = rearg(result, mapping.methodRearg[name] || mapping.aryRearg[aryKey]);
|
||||||
}
|
}
|
||||||
if (config.cap) {
|
if (config.cap && aryN) {
|
||||||
if (reargIndexes) {
|
result = iterateeAry(result, aryN);
|
||||||
result = iterateeRearg(result, reargIndexes);
|
|
||||||
} else if (aryN) {
|
|
||||||
result = iterateeAry(result, aryN);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (config.curry && cap > 1) {
|
if (config.curry && aryKey > 1) {
|
||||||
result = curry(result, cap);
|
result = curry(result, aryKey);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -221,24 +239,24 @@ function baseConvert(util, name, func, options) {
|
|||||||
return !result;
|
return !result;
|
||||||
});
|
});
|
||||||
|
|
||||||
result || (result = func);
|
result || (result = wrapped);
|
||||||
if (mapping.placeholder[name]) {
|
if (mapping.placeholder[name]) {
|
||||||
|
setPlaceholder = true;
|
||||||
func.placeholder = result.placeholder = placeholder;
|
func.placeholder = result.placeholder = placeholder;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!isLib) {
|
if (!isObj) {
|
||||||
return wrap(name, func);
|
return wrap(name, func);
|
||||||
}
|
}
|
||||||
// Add placeholder.
|
var _ = func;
|
||||||
_.placeholder = placeholder;
|
|
||||||
|
|
||||||
// Iterate over methods for the current ary cap.
|
// Iterate over methods for the current ary cap.
|
||||||
var pairs = [];
|
var pairs = [];
|
||||||
each(mapping.caps, function(cap) {
|
each(aryMethodKeys, function(aryKey) {
|
||||||
each(mapping.aryMethod[cap], function(key) {
|
each(mapping.aryMethod[aryKey], function(key) {
|
||||||
var func = _[mapping.rename[key] || key];
|
var func = _[mapping.remap[key] || key];
|
||||||
if (func) {
|
if (func) {
|
||||||
pairs.push([key, wrap(key, func)]);
|
pairs.push([key, wrap(key, func)]);
|
||||||
}
|
}
|
||||||
@@ -250,6 +268,9 @@ function baseConvert(util, name, func, options) {
|
|||||||
_[pair[0]] = pair[1];
|
_[pair[0]] = pair[1];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (setPlaceholder) {
|
||||||
|
_.placeholder = placeholder;
|
||||||
|
}
|
||||||
// Wrap the lodash method and its aliases.
|
// Wrap the lodash method and its aliases.
|
||||||
each(keys(_), function(key) {
|
each(keys(_), function(key) {
|
||||||
each(mapping.realToAlias[key] || [], function(alias) {
|
each(mapping.realToAlias[key] || [], function(alias) {
|
||||||
|
|||||||
@@ -8,7 +8,10 @@ var baseConvert = require('./_baseConvert');
|
|||||||
* @returns {Function} Returns the converted `lodash`.
|
* @returns {Function} Returns the converted `lodash`.
|
||||||
*/
|
*/
|
||||||
function browserConvert(lodash, options) {
|
function browserConvert(lodash, options) {
|
||||||
return baseConvert(lodash, lodash, undefined, options);
|
return baseConvert(lodash, lodash, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof _ == 'function') {
|
||||||
|
_ = browserConvert(_.runInContext());
|
||||||
|
}
|
||||||
module.exports = browserConvert;
|
module.exports = browserConvert;
|
||||||
|
|||||||
104
fp/_mapping.js
104
fp/_mapping.js
@@ -38,55 +38,52 @@ exports.aliasToReal = {
|
|||||||
|
|
||||||
/** Used to map ary to method names. */
|
/** Used to map ary to method names. */
|
||||||
exports.aryMethod = {
|
exports.aryMethod = {
|
||||||
1: [
|
'1': [
|
||||||
'attempt', 'ceil', 'create', 'curry', 'curryRight', 'floor', 'fromPairs',
|
'attempt', 'castArray', 'ceil', 'create', 'curry', 'curryRight', 'floor',
|
||||||
'invert', 'iteratee', 'memoize', 'method', 'methodOf', 'mixin', 'over',
|
'fromPairs', 'invert', 'iteratee', 'memoize', 'method', 'methodOf', 'mixin',
|
||||||
'overEvery', 'overSome', 'rest', 'reverse', 'round', 'runInContext',
|
'over', 'overEvery', 'overSome', 'rest', 'reverse', 'round', 'runInContext',
|
||||||
'spread', 'template', 'trim', 'trimEnd', 'trimStart', 'uniqueId', 'words'
|
'spread', 'template', 'trim', 'trimEnd', 'trimStart', 'uniqueId', 'words'
|
||||||
],
|
],
|
||||||
2: [
|
'2': [
|
||||||
'add', 'after', 'ary', 'assign', 'assignIn', 'at', 'before', 'bind', 'bindKey',
|
'add', 'after', 'ary', 'assign', 'assignIn', 'at', 'before', 'bind', 'bindKey',
|
||||||
'chunk', 'cloneDeepWith', 'cloneWith', 'concat', 'countBy', 'curryN',
|
'chunk', 'cloneDeepWith', 'cloneWith', 'concat', 'countBy', 'curryN',
|
||||||
'curryRightN', 'debounce', 'defaults', 'defaultsDeep', 'delay', 'difference',
|
'curryRightN', 'debounce', 'defaults', 'defaultsDeep', 'delay', 'difference',
|
||||||
'drop', 'dropRight', 'dropRightWhile', 'dropWhile', 'endsWith', 'eq', 'every',
|
'drop', 'dropRight', 'dropRightWhile', 'dropWhile', 'endsWith', 'eq', 'every',
|
||||||
'filter', 'find', 'find', 'findIndex', 'findKey', 'findLast', 'findLastIndex',
|
'filter', 'find', 'find', 'findIndex', 'findKey', 'findLast', 'findLastIndex',
|
||||||
'findLastKey', 'flatMap', 'forEach', 'forEachRight', 'forIn', 'forInRight',
|
'findLastKey', 'flatMap', 'flattenDepth', 'forEach', 'forEachRight', 'forIn',
|
||||||
'forOwn', 'forOwnRight', 'get', 'groupBy', 'gt', 'gte', 'has', 'hasIn',
|
'forInRight', 'forOwn', 'forOwnRight', 'get', 'groupBy', 'gt', 'gte', 'has',
|
||||||
'includes', 'indexOf', 'intersection', 'invertBy', 'invoke', 'invokeMap',
|
'hasIn', 'includes', 'indexOf', 'intersection', 'invertBy', 'invoke', 'invokeMap',
|
||||||
'isEqual', 'isMatch', 'join', 'keyBy', 'lastIndexOf', 'lt', 'lte', 'map',
|
'isEqual', 'isMatch', 'join', 'keyBy', 'lastIndexOf', 'lt', 'lte', 'map',
|
||||||
'mapKeys', 'mapValues', 'matchesProperty', 'maxBy', 'merge', 'minBy', 'omit',
|
'mapKeys', 'mapValues', 'matchesProperty', 'maxBy', 'merge', 'minBy', 'omit',
|
||||||
'omitBy', 'orderBy', 'overArgs', 'pad', 'padEnd', 'padStart', 'parseInt',
|
'omitBy', 'orderBy', 'overArgs', 'pad', 'padEnd', 'padStart', 'parseInt',
|
||||||
'partial', 'partialRight', 'partition', 'pick', 'pickBy', 'pull', 'pullAll',
|
'partial', 'partialRight', 'partition', 'pick', 'pickBy', 'pull', 'pullAll',
|
||||||
'pullAt', 'random', 'range', 'rangeRight', 'rearg', 'reject', 'remove',
|
'pullAt', 'random', 'range', 'rangeRight', 'rearg', 'reject', 'remove',
|
||||||
'repeat', 'result', 'sampleSize', 'some', 'sortBy', 'sortedIndex',
|
'repeat', 'result', 'sampleSize', 'some', 'sortBy', 'sortedIndex',
|
||||||
'sortedIndexOf', 'sortedLastIndex', 'sortedLastIndexOf', 'sortedUniqBy',
|
'sortedIndexOf', 'sortedLastIndex', 'sortedLastIndexOf', 'sortedUniqBy',
|
||||||
'split', 'startsWith', 'subtract', 'sumBy', 'take', 'takeRight', 'takeRightWhile',
|
'split', 'startsWith', 'subtract', 'sumBy', 'take', 'takeRight', 'takeRightWhile',
|
||||||
'takeWhile', 'tap', 'throttle', 'thru', 'times', 'trimChars', 'trimCharsEnd',
|
'takeWhile', 'tap', 'throttle', 'thru', 'times', 'trimChars', 'trimCharsEnd',
|
||||||
'trimCharsStart', 'truncate', 'union', 'uniqBy', 'uniqWith', 'unset',
|
'trimCharsStart', 'truncate', 'union', 'uniqBy', 'uniqWith', 'unset',
|
||||||
'unzipWith', 'without', 'wrap', 'xor', 'zip', 'zipObject', 'zipObjectDeep'
|
'unzipWith', 'without', 'wrap', 'xor', 'zip', 'zipObject', 'zipObjectDeep'
|
||||||
],
|
],
|
||||||
3: [
|
'3': [
|
||||||
'assignInWith', 'assignWith', 'clamp', 'differenceBy', 'differenceWith',
|
'assignInWith', 'assignWith', 'clamp', 'differenceBy', 'differenceWith',
|
||||||
'getOr', 'inRange', 'intersectionBy', 'intersectionWith', 'isEqualWith',
|
'getOr', 'inRange', 'intersectionBy', 'intersectionWith', 'isEqualWith',
|
||||||
'isMatchWith', 'mergeWith', 'pullAllBy', 'reduce', 'reduceRight', 'replace',
|
'isMatchWith', 'mergeWith', 'pullAllBy', 'reduce', 'reduceRight', 'replace',
|
||||||
'set', 'slice', 'sortedIndexBy', 'sortedLastIndexBy', 'transform', 'unionBy',
|
'set', 'slice', 'sortedIndexBy', 'sortedLastIndexBy', 'transform', 'unionBy',
|
||||||
'unionWith', 'xorBy', 'xorWith', 'zipWith'
|
'unionWith', 'xorBy', 'xorWith', 'zipWith'
|
||||||
],
|
],
|
||||||
4: [
|
'4': [
|
||||||
'fill', 'setWith'
|
'fill', 'setWith'
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Used to map ary to rearg configs. */
|
/** Used to map ary to rearg configs. */
|
||||||
exports.aryRearg = {
|
exports.aryRearg = {
|
||||||
2: [1, 0],
|
'2': [1, 0],
|
||||||
3: [2, 1, 0],
|
'3': [2, 0, 1],
|
||||||
4: [3, 2, 0, 1]
|
'4': [3, 2, 0, 1]
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Used to iterate `mapping.aryMethod` keys. */
|
|
||||||
exports.caps = [1, 2, 3, 4];
|
|
||||||
|
|
||||||
/** Used to map method names to their iteratee ary. */
|
/** Used to map method names to their iteratee ary. */
|
||||||
exports.iterateeAry = {
|
exports.iterateeAry = {
|
||||||
'assignWith': 2,
|
'assignWith': 2,
|
||||||
@@ -127,25 +124,18 @@ exports.iterateeAry = {
|
|||||||
'transform': 2
|
'transform': 2
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Used to map method names to iteratee rearg configs. */
|
|
||||||
exports.iterateeRearg = {
|
|
||||||
'findKey': [1],
|
|
||||||
'findLastKey': [1],
|
|
||||||
'mapKeys': [1]
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Used to map method names to rearg configs. */
|
/** Used to map method names to rearg configs. */
|
||||||
exports.methodRearg = {
|
exports.methodRearg = {
|
||||||
'assignInWith': [1, 2, 0],
|
'assignInWith': [1, 2, 0],
|
||||||
'assignWith': [1, 2, 0],
|
'assignWith': [1, 2, 0],
|
||||||
'clamp': [2, 0, 1],
|
'getOr': [2, 1, 0],
|
||||||
|
'isMatchWith': [2, 1, 0],
|
||||||
'mergeWith': [1, 2, 0],
|
'mergeWith': [1, 2, 0],
|
||||||
'reduce': [2, 0, 1],
|
'pullAllBy': [2, 1, 0],
|
||||||
'reduceRight': [2, 0, 1],
|
|
||||||
'set': [2, 0, 1],
|
|
||||||
'setWith': [3, 1, 2, 0],
|
'setWith': [3, 1, 2, 0],
|
||||||
'slice': [2, 0, 1],
|
'sortedIndexBy': [2, 1, 0],
|
||||||
'transform': [2, 0, 1]
|
'sortedLastIndexBy': [2, 1, 0],
|
||||||
|
'zipWith': [1, 2, 0]
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Used to map method names to spread configs. */
|
/** Used to map method names to spread configs. */
|
||||||
@@ -210,7 +200,7 @@ exports.realToAlias = (function() {
|
|||||||
}());
|
}());
|
||||||
|
|
||||||
/** Used to map method names to other names. */
|
/** Used to map method names to other names. */
|
||||||
exports.rename = {
|
exports.remap = {
|
||||||
'curryN': 'curry',
|
'curryN': 'curry',
|
||||||
'curryRightN': 'curryRight',
|
'curryRightN': 'curryRight',
|
||||||
'getOr': 'get',
|
'getOr': 'get',
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ module.exports = {
|
|||||||
'cloneDeep': require('../cloneDeep'),
|
'cloneDeep': require('../cloneDeep'),
|
||||||
'curry': require('../curry'),
|
'curry': require('../curry'),
|
||||||
'forEach': require('../_arrayEach'),
|
'forEach': require('../_arrayEach'),
|
||||||
|
'isArray': require('../isArray'),
|
||||||
'isFunction': require('../isFunction'),
|
'isFunction': require('../isFunction'),
|
||||||
'iteratee': require('../iteratee'),
|
'iteratee': require('../iteratee'),
|
||||||
'keys': require('../_baseKeys'),
|
'keys': require('../_baseKeys'),
|
||||||
|
|||||||
2
fp/castArray.js
Normal file
2
fp/castArray.js
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
var convert = require('./convert');
|
||||||
|
module.exports = convert('castArray', require('../castArray'));
|
||||||
2
fp/flattenDepth.js
Normal file
2
fp/flattenDepth.js
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
var convert = require('./convert');
|
||||||
|
module.exports = convert('flattenDepth', require('../flattenDepth'));
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
var arrayMap = require('./_arrayMap'),
|
var arrayMap = require('./_arrayMap'),
|
||||||
|
baseCastArrayLikeObject = require('./_baseCastArrayLikeObject'),
|
||||||
baseIntersection = require('./_baseIntersection'),
|
baseIntersection = require('./_baseIntersection'),
|
||||||
rest = require('./rest'),
|
rest = require('./rest');
|
||||||
toArrayLikeObject = require('./_toArrayLikeObject');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an array of unique values that are included in all given arrays
|
* Creates an array of unique values that are included in all given arrays
|
||||||
@@ -19,7 +19,7 @@ var arrayMap = require('./_arrayMap'),
|
|||||||
* // => [2]
|
* // => [2]
|
||||||
*/
|
*/
|
||||||
var intersection = rest(function(arrays) {
|
var intersection = rest(function(arrays) {
|
||||||
var mapped = arrayMap(arrays, toArrayLikeObject);
|
var mapped = arrayMap(arrays, baseCastArrayLikeObject);
|
||||||
return (mapped.length && mapped[0] === arrays[0])
|
return (mapped.length && mapped[0] === arrays[0])
|
||||||
? baseIntersection(mapped)
|
? baseIntersection(mapped)
|
||||||
: [];
|
: [];
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
var arrayMap = require('./_arrayMap'),
|
var arrayMap = require('./_arrayMap'),
|
||||||
|
baseCastArrayLikeObject = require('./_baseCastArrayLikeObject'),
|
||||||
baseIntersection = require('./_baseIntersection'),
|
baseIntersection = require('./_baseIntersection'),
|
||||||
baseIteratee = require('./_baseIteratee'),
|
baseIteratee = require('./_baseIteratee'),
|
||||||
last = require('./last'),
|
last = require('./last'),
|
||||||
rest = require('./rest'),
|
rest = require('./rest');
|
||||||
toArrayLikeObject = require('./_toArrayLikeObject');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.intersection` except that it accepts `iteratee`
|
* This method is like `_.intersection` except that it accepts `iteratee`
|
||||||
@@ -27,7 +27,7 @@ var arrayMap = require('./_arrayMap'),
|
|||||||
*/
|
*/
|
||||||
var intersectionBy = rest(function(arrays) {
|
var intersectionBy = rest(function(arrays) {
|
||||||
var iteratee = last(arrays),
|
var iteratee = last(arrays),
|
||||||
mapped = arrayMap(arrays, toArrayLikeObject);
|
mapped = arrayMap(arrays, baseCastArrayLikeObject);
|
||||||
|
|
||||||
if (iteratee === last(mapped)) {
|
if (iteratee === last(mapped)) {
|
||||||
iteratee = undefined;
|
iteratee = undefined;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
var arrayMap = require('./_arrayMap'),
|
var arrayMap = require('./_arrayMap'),
|
||||||
|
baseCastArrayLikeObject = require('./_baseCastArrayLikeObject'),
|
||||||
baseIntersection = require('./_baseIntersection'),
|
baseIntersection = require('./_baseIntersection'),
|
||||||
last = require('./last'),
|
last = require('./last'),
|
||||||
rest = require('./rest'),
|
rest = require('./rest');
|
||||||
toArrayLikeObject = require('./_toArrayLikeObject');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.intersection` except that it accepts `comparator`
|
* This method is like `_.intersection` except that it accepts `comparator`
|
||||||
@@ -25,7 +25,7 @@ var arrayMap = require('./_arrayMap'),
|
|||||||
*/
|
*/
|
||||||
var intersectionWith = rest(function(arrays) {
|
var intersectionWith = rest(function(arrays) {
|
||||||
var comparator = last(arrays),
|
var comparator = last(arrays),
|
||||||
mapped = arrayMap(arrays, toArrayLikeObject);
|
mapped = arrayMap(arrays, baseCastArrayLikeObject);
|
||||||
|
|
||||||
if (comparator === last(mapped)) {
|
if (comparator === last(mapped)) {
|
||||||
comparator = undefined;
|
comparator = undefined;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @type Function
|
* @type {Function}
|
||||||
* @category Lang
|
* @category Lang
|
||||||
* @param {*} value The value to check.
|
* @param {*} value The value to check.
|
||||||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ var objectToString = objectProto.toString;
|
|||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @type Function
|
|
||||||
* @category Lang
|
* @category Lang
|
||||||
* @param {*} value The value to check.
|
* @param {*} value The value to check.
|
||||||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ var getLength = require('./_getLength'),
|
|||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @type Function
|
|
||||||
* @category Lang
|
* @category Lang
|
||||||
* @param {*} value The value to check.
|
* @param {*} value The value to check.
|
||||||
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ var isArrayLike = require('./isArrayLike'),
|
|||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @type Function
|
|
||||||
* @category Lang
|
* @category Lang
|
||||||
* @param {*} value The value to check.
|
* @param {*} value The value to check.
|
||||||
* @returns {boolean} Returns `true` if `value` is an array-like object, else `false`.
|
* @returns {boolean} Returns `true` if `value` is an array-like object, else `false`.
|
||||||
|
|||||||
12
isBuffer.js
12
isBuffer.js
@@ -8,13 +8,19 @@ var objectTypes = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Detect free variable `exports`. */
|
/** 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`. */
|
/** 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 the popular CommonJS extension `module.exports`. */
|
/** Detect the popular CommonJS extension `module.exports`. */
|
||||||
var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : null;
|
var moduleExports = (freeModule && freeModule.exports === freeExports)
|
||||||
|
? freeExports
|
||||||
|
: undefined;
|
||||||
|
|
||||||
/** Built-in value references. */
|
/** Built-in value references. */
|
||||||
var Buffer = moduleExports ? root.Buffer : undefined;
|
var Buffer = moduleExports ? root.Buffer : undefined;
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
|||||||
*/
|
*/
|
||||||
function isEmpty(value) {
|
function isEmpty(value) {
|
||||||
if (isArrayLike(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;
|
return !value.length;
|
||||||
}
|
}
|
||||||
for (var key in value) {
|
for (var key in value) {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
var baseIsEqual = require('./_baseIsEqual');
|
var baseIsEqual = require('./_baseIsEqual');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.isEqual` except that it accepts `customizer` which is
|
* This method is like `_.isEqual` except that it accepts `customizer` which
|
||||||
* invoked to compare values. If `customizer` returns `undefined` comparisons are
|
* is invoked to compare values. If `customizer` returns `undefined` comparisons
|
||||||
* handled by the method instead. The `customizer` is invoked with up to six arguments:
|
* are handled by the method instead. The `customizer` is invoked with up to
|
||||||
* (objValue, othValue [, index|key, object, other, stack]).
|
* six arguments: (objValue, othValue [, index|key, object, other, stack]).
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
@@ -30,8 +30,12 @@ var objectToString = objectProto.toString;
|
|||||||
* // => false
|
* // => false
|
||||||
*/
|
*/
|
||||||
function isError(value) {
|
function isError(value) {
|
||||||
return isObjectLike(value) &&
|
if (!isObjectLike(value)) {
|
||||||
typeof value.message == 'string' && objectToString.call(value) == errorTag;
|
return false;
|
||||||
|
}
|
||||||
|
var Ctor = value.constructor;
|
||||||
|
return (objectToString.call(value) == errorTag) ||
|
||||||
|
(typeof Ctor == 'function' && objectToString.call(Ctor.prototype) == errorTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = isError;
|
module.exports = isError;
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ var MAX_SAFE_INTEGER = 9007199254740991;
|
|||||||
* // => false
|
* // => false
|
||||||
*/
|
*/
|
||||||
function isLength(value) {
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = isLength;
|
module.exports = isLength;
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ var baseIsMatch = require('./_baseIsMatch'),
|
|||||||
getMatchData = require('./_getMatchData');
|
getMatchData = require('./_getMatchData');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a deep comparison between `object` and `source` to determine if
|
* Performs a partial deep comparison between `object` and `source` to
|
||||||
* `object` contains equivalent property values.
|
* 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`.
|
* **Note:** This method supports comparing the same values as `_.isEqual`.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ var getPrototypeOf = Object.getPrototypeOf;
|
|||||||
* // => true
|
* // => true
|
||||||
*/
|
*/
|
||||||
function isPlainObject(value) {
|
function isPlainObject(value) {
|
||||||
if (!isObjectLike(value) || objectToString.call(value) != objectTag || isHostObject(value)) {
|
if (!isObjectLike(value) ||
|
||||||
|
objectToString.call(value) != objectTag || isHostObject(value)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var proto = objectProto;
|
var proto = objectProto;
|
||||||
|
|||||||
@@ -68,7 +68,8 @@ var objectToString = objectProto.toString;
|
|||||||
* // => false
|
* // => false
|
||||||
*/
|
*/
|
||||||
function isTypedArray(value) {
|
function isTypedArray(value) {
|
||||||
return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
|
return isObjectLike(value) &&
|
||||||
|
isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = isTypedArray;
|
module.exports = isTypedArray;
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ var baseClone = require('./_baseClone'),
|
|||||||
* Creates a function that invokes `func` with the arguments of the created
|
* Creates a function that invokes `func` with the arguments of the created
|
||||||
* function. If `func` is a property name the created callback returns the
|
* 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
|
* 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
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
|
|||||||
1
lang.js
1
lang.js
@@ -1,4 +1,5 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
|
'castArray': require('./castArray'),
|
||||||
'clone': require('./clone'),
|
'clone': require('./clone'),
|
||||||
'cloneDeep': require('./cloneDeep'),
|
'cloneDeep': require('./cloneDeep'),
|
||||||
'cloneDeepWith': require('./cloneDeepWith'),
|
'cloneDeepWith': require('./cloneDeepWith'),
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ var baseClone = require('./_baseClone'),
|
|||||||
baseMatches = require('./_baseMatches');
|
baseMatches = require('./_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
|
* 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`.
|
* **Note:** This method supports comparing the same values as `_.isEqual`.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ var baseClone = require('./_baseClone'),
|
|||||||
baseMatchesProperty = require('./_baseMatchesProperty');
|
baseMatchesProperty = require('./_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
|
* value at `path` of a given object to `srcValue`, returning `true` if the
|
||||||
* object value is equivalent, else `false`.
|
* object value is equivalent, else `false`.
|
||||||
*
|
*
|
||||||
|
|||||||
12
merge.js
12
merge.js
@@ -2,12 +2,12 @@ var baseMerge = require('./_baseMerge'),
|
|||||||
createAssigner = require('./_createAssigner');
|
createAssigner = require('./_createAssigner');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursively merges own and inherited enumerable properties of source
|
* Recursively merges own and inherited enumerable properties of source objects
|
||||||
* objects into the destination object, skipping source properties that resolve
|
* into the destination object. Source properties that resolve to `undefined`
|
||||||
* to `undefined`. Array and plain object properties are merged recursively.
|
* are skipped if a destination value exists. Array and plain object properties
|
||||||
* Other objects and value types are overridden by assignment. Source objects
|
* are merged recursively. Other objects and value types are overridden by
|
||||||
* are applied from left to right. Subsequent sources overwrite property
|
* assignment. Source objects are applied from left to right. Subsequent
|
||||||
* assignments of previous sources.
|
* sources overwrite property assignments of previous sources.
|
||||||
*
|
*
|
||||||
* **Note:** This method mutates `object`.
|
* **Note:** This method mutates `object`.
|
||||||
*
|
*
|
||||||
|
|||||||
2
now.js
2
now.js
@@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @type Function
|
* @type {Function}
|
||||||
* @category Date
|
* @category Date
|
||||||
* @returns {number} Returns the timestamp.
|
* @returns {number} Returns the timestamp.
|
||||||
* @example
|
* @example
|
||||||
|
|||||||
4
omit.js
4
omit.js
@@ -14,7 +14,7 @@ var arrayMap = require('./_arrayMap'),
|
|||||||
* @category Object
|
* @category Object
|
||||||
* @param {Object} object The source object.
|
* @param {Object} object The source object.
|
||||||
* @param {...(string|string[])} [props] The property names to omit, specified
|
* @param {...(string|string[])} [props] The property names to omit, specified
|
||||||
* individually or in arrays..
|
* individually or in arrays.
|
||||||
* @returns {Object} Returns the new object.
|
* @returns {Object} Returns the new object.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -27,7 +27,7 @@ var omit = rest(function(object, props) {
|
|||||||
if (object == null) {
|
if (object == null) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
props = arrayMap(baseFlatten(props), String);
|
props = arrayMap(baseFlatten(props, 1), String);
|
||||||
return basePick(object, baseDifference(keysIn(object), props));
|
return basePick(object, baseDifference(keysIn(object), props));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ var nativeMin = Math.min;
|
|||||||
* // => [100, 10]
|
* // => [100, 10]
|
||||||
*/
|
*/
|
||||||
var overArgs = rest(function(func, transforms) {
|
var overArgs = rest(function(func, transforms) {
|
||||||
transforms = arrayMap(baseFlatten(transforms), baseIteratee);
|
transforms = arrayMap(baseFlatten(transforms, 1), baseIteratee);
|
||||||
|
|
||||||
var funcsLength = transforms.length;
|
var funcsLength = transforms.length;
|
||||||
return rest(function(args) {
|
return rest(function(args) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "lodash",
|
"name": "lodash",
|
||||||
"version": "4.3.0",
|
"version": "4.4.0",
|
||||||
"description": "Lodash modular utilities.",
|
"description": "Lodash modular utilities.",
|
||||||
"homepage": "https://lodash.com/",
|
"homepage": "https://lodash.com/",
|
||||||
"icon": "https://lodash.com/icon.svg",
|
"icon": "https://lodash.com/icon.svg",
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ var nativeParseInt = root.parseInt;
|
|||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category String
|
* @category String
|
||||||
* @param {string} string The string to convert.
|
* @param {string} string The string to convert.
|
||||||
* @param {number} [radix] The radix to interpret `value` by.
|
* @param {number} [radix=10] The radix to interpret `value` by.
|
||||||
* @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`.
|
* @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`.
|
||||||
* @returns {number} Returns the converted integer.
|
* @returns {number} Returns the converted integer.
|
||||||
* @example
|
* @example
|
||||||
|
|||||||
2
pick.js
2
pick.js
@@ -20,7 +20,7 @@ var baseFlatten = require('./_baseFlatten'),
|
|||||||
* // => { 'a': 1, 'c': 3 }
|
* // => { 'a': 1, 'c': 3 }
|
||||||
*/
|
*/
|
||||||
var pick = rest(function(object, props) {
|
var pick = rest(function(object, props) {
|
||||||
return object == null ? {} : basePick(object, baseFlatten(props));
|
return object == null ? {} : basePick(object, baseFlatten(props, 1));
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = pick;
|
module.exports = pick;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ var arrayMap = require('./_arrayMap'),
|
|||||||
* // => [10, 20]
|
* // => [10, 20]
|
||||||
*/
|
*/
|
||||||
var pullAt = rest(function(array, indexes) {
|
var pullAt = rest(function(array, indexes) {
|
||||||
indexes = arrayMap(baseFlatten(indexes), String);
|
indexes = arrayMap(baseFlatten(indexes, 1), String);
|
||||||
|
|
||||||
var result = baseAt(array, indexes);
|
var result = baseAt(array, indexes);
|
||||||
basePullAt(array, indexes.sort(compareAscending));
|
basePullAt(array, indexes.sort(compareAscending));
|
||||||
|
|||||||
2
rearg.js
2
rearg.js
@@ -28,7 +28,7 @@ var REARG_FLAG = 256;
|
|||||||
* // => ['a', 'b', 'c']
|
* // => ['a', 'b', 'c']
|
||||||
*/
|
*/
|
||||||
var rearg = rest(function(func, indexes) {
|
var rearg = rest(function(func, indexes) {
|
||||||
return createWrapper(func, REARG_FLAG, undefined, undefined, undefined, baseFlatten(indexes));
|
return createWrapper(func, REARG_FLAG, undefined, undefined, undefined, baseFlatten(indexes, 1));
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = rearg;
|
module.exports = rearg;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var baseToPath = require('./_baseToPath'),
|
var baseCastPath = require('./_baseCastPath'),
|
||||||
get = require('./get'),
|
get = require('./get'),
|
||||||
isFunction = require('./isFunction'),
|
isFunction = require('./isFunction'),
|
||||||
isKey = require('./_isKey'),
|
isKey = require('./_isKey'),
|
||||||
@@ -34,7 +34,7 @@ var baseToPath = require('./_baseToPath'),
|
|||||||
*/
|
*/
|
||||||
function result(object, path, defaultValue) {
|
function result(object, path, defaultValue) {
|
||||||
if (!isKey(path, object)) {
|
if (!isKey(path, object)) {
|
||||||
path = baseToPath(path);
|
path = baseCastPath(path);
|
||||||
var result = get(object, path);
|
var result = get(object, path);
|
||||||
object = parent(object, path);
|
object = parent(object, path);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ var sortBy = rest(function(collection, iteratees) {
|
|||||||
} else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
|
} else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
|
||||||
iteratees.length = 1;
|
iteratees.length = 1;
|
||||||
}
|
}
|
||||||
return baseOrderBy(collection, baseFlatten(iteratees), []);
|
return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = sortBy;
|
module.exports = sortBy;
|
||||||
|
|||||||
@@ -210,7 +210,8 @@ function template(string, options, guard) {
|
|||||||
'return __p\n}';
|
'return __p\n}';
|
||||||
|
|
||||||
var result = attempt(function() {
|
var result = attempt(function() {
|
||||||
return Function(importsKeys, sourceURL + 'return ' + source).apply(undefined, importsValues);
|
return Function(importsKeys, sourceURL + 'return ' + source)
|
||||||
|
.apply(undefined, importsValues);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Provide the compiled function's source by its `toString` method or
|
// Provide the compiled function's source by its `toString` method or
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ var escape = require('./escape'),
|
|||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @type Object
|
* @type {Object}
|
||||||
*/
|
*/
|
||||||
var templateSettings = {
|
var templateSettings = {
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ var templateSettings = {
|
|||||||
* Used to detect `data` property values to be HTML-escaped.
|
* Used to detect `data` property values to be HTML-escaped.
|
||||||
*
|
*
|
||||||
* @memberOf _.templateSettings
|
* @memberOf _.templateSettings
|
||||||
* @type RegExp
|
* @type {RegExp}
|
||||||
*/
|
*/
|
||||||
'escape': reEscape,
|
'escape': reEscape,
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ var templateSettings = {
|
|||||||
* Used to detect code to be evaluated.
|
* Used to detect code to be evaluated.
|
||||||
*
|
*
|
||||||
* @memberOf _.templateSettings
|
* @memberOf _.templateSettings
|
||||||
* @type RegExp
|
* @type {RegExp}
|
||||||
*/
|
*/
|
||||||
'evaluate': reEvaluate,
|
'evaluate': reEvaluate,
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ var templateSettings = {
|
|||||||
* Used to detect `data` property values to inject.
|
* Used to detect `data` property values to inject.
|
||||||
*
|
*
|
||||||
* @memberOf _.templateSettings
|
* @memberOf _.templateSettings
|
||||||
* @type RegExp
|
* @type {RegExp}
|
||||||
*/
|
*/
|
||||||
'interpolate': reInterpolate,
|
'interpolate': reInterpolate,
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ var templateSettings = {
|
|||||||
* Used to reference the data object in the template text.
|
* Used to reference the data object in the template text.
|
||||||
*
|
*
|
||||||
* @memberOf _.templateSettings
|
* @memberOf _.templateSettings
|
||||||
* @type string
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
'variable': '',
|
'variable': '',
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ var templateSettings = {
|
|||||||
* Used to import variables into the compiled template.
|
* Used to import variables into the compiled template.
|
||||||
*
|
*
|
||||||
* @memberOf _.templateSettings
|
* @memberOf _.templateSettings
|
||||||
* @type Object
|
* @type {Object}
|
||||||
*/
|
*/
|
||||||
'imports': {
|
'imports': {
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ var templateSettings = {
|
|||||||
* A reference to the `lodash` function.
|
* A reference to the `lodash` function.
|
||||||
*
|
*
|
||||||
* @memberOf _.templateSettings.imports
|
* @memberOf _.templateSettings.imports
|
||||||
* @type Function
|
* @type {Function}
|
||||||
*/
|
*/
|
||||||
'_': { 'escape': escape }
|
'_': { 'escape': escape }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,11 @@ function throttle(func, wait, options) {
|
|||||||
leading = 'leading' in options ? !!options.leading : leading;
|
leading = 'leading' in options ? !!options.leading : leading;
|
||||||
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
||||||
}
|
}
|
||||||
return debounce(func, wait, { 'leading': leading, 'maxWait': wait, 'trailing': trailing });
|
return debounce(func, wait, {
|
||||||
|
'leading': leading,
|
||||||
|
'maxWait': wait,
|
||||||
|
'trailing': trailing
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = throttle;
|
module.exports = throttle;
|
||||||
|
|||||||
6
times.js
6
times.js
@@ -1,5 +1,5 @@
|
|||||||
var baseTimes = require('./_baseTimes'),
|
var baseCastFunction = require('./_baseCastFunction'),
|
||||||
toFunction = require('./_toFunction'),
|
baseTimes = require('./_baseTimes'),
|
||||||
toInteger = require('./toInteger');
|
toInteger = require('./toInteger');
|
||||||
|
|
||||||
/** Used as references for various `Number` constants. */
|
/** Used as references for various `Number` constants. */
|
||||||
@@ -37,7 +37,7 @@ function times(n, iteratee) {
|
|||||||
var index = MAX_ARRAY_LENGTH,
|
var index = MAX_ARRAY_LENGTH,
|
||||||
length = nativeMin(n, MAX_ARRAY_LENGTH);
|
length = nativeMin(n, MAX_ARRAY_LENGTH);
|
||||||
|
|
||||||
iteratee = toFunction(iteratee);
|
iteratee = baseCastFunction(iteratee);
|
||||||
n -= MAX_ARRAY_LENGTH;
|
n -= MAX_ARRAY_LENGTH;
|
||||||
|
|
||||||
var result = baseTimes(length, iteratee);
|
var result = baseTimes(length, iteratee);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user