Compare commits

...

3 Commits

Author SHA1 Message Date
John-David Dalton
91d3468c81 Bump to v4.4.0. 2016-02-15 23:05:17 -08:00
John-David Dalton
e2aef0def9 Bump to v4.3.0. 2016-02-08 00:43:24 -08:00
John-David Dalton
bd7f722175 Bulk update. 2016-02-03 23:26:07 -08:00
151 changed files with 1582 additions and 783 deletions

33
LICENSE
View File

@@ -1,22 +1,23 @@
The MIT License (MIT)
Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/> Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
Based on Underscore.js, copyright 2009-2016 Jeremy Ashkenas, Based on Underscore.js, copyright 2009-2016 Jeremy Ashkenas,
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining a copy
a copy of this software and associated documentation files (the of this software and associated documentation files (the "Software"), to deal
"Software"), to deal in the Software without restriction, including in the Software without restriction, including without limitation the rights
without limitation the rights to use, copy, modify, merge, publish, to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
distribute, sublicense, and/or sell copies of the Software, and to copies of the Software, and to permit persons to whom the Software is
permit persons to whom the Software is furnished to do so, subject to furnished to do so, subject to the following conditions:
the following conditions:
The above copyright notice and this permission notice shall be The above copyright notice and this permission notice shall be included in all
included in all copies or substantial portions of the Software. copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. SOFTWARE.

View File

@@ -1,4 +1,4 @@
# lodash v4.2.1 # 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,45 +12,29 @@ $ 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.2.1-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>
Dont assign values to the [special variable](http://nodejs.org/api/repl.html#repl_repl_features) `_` when in the REPL.<br> Dont assign values to the [special variable](http://nodejs.org/api/repl.html#repl_repl_features) `_` when in the REPL.<br>
Install [n_](https://www.npmjs.com/package/n_) for a REPL that includes lodash by default. Install [n_](https://www.npmjs.com/package/n_) for a REPL that includes lodash by default.
## Module formats
Lodash is available in a variety of other builds & module formats.
* [lodash](https://www.npmjs.com/package/lodash) & [per method packages](https://www.npmjs.com/browse/keyword/lodash-modularized)
* [lodash-amd](https://www.npmjs.com/package/lodash-amd)
* [lodash-es](https://www.npmjs.com/package/lodash-es) & [babel-plugin-lodash](https://www.npmjs.com/package/babel-plugin-lodash)
## Further Reading
* [API Documentation](https://lodash.com/docs)
* [Build Differences](https://github.com/lodash/lodash/wiki/Build-Differences)
* [Changelog](https://github.com/lodash/lodash/wiki/Changelog)
* [Roadmap](https://github.com/lodash/lodash/wiki/Roadmap)
* [More Resources](https://github.com/lodash/lodash/wiki/Resources)
## Support ## Support
Tested in Chrome 47-48, Firefox 43-44, IE 9-11, Edge 13, Safari 8-9, Node.js 0.10, 0.12, 4, & 5, & PhantomJS 1.9.8. Tested in Chrome 47-48, Firefox 43-44, IE 9-11, Edge 13, Safari 8-9, Node.js 0.10, 0.12, 4, & 5, & PhantomJS 1.9.8.<br>
Automated [browser](https://saucelabs.com/u/lodash) & [CI](https://travis-ci.org/lodash/lodash/) test runs are available. Special thanks to [Sauce Labs](https://saucelabs.com/) for providing automated browser testing. Automated [browser](https://saucelabs.com/u/lodash) & [CI](https://travis-ci.org/lodash/lodash/) test runs are available.

View File

@@ -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() {}

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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) {

View 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
View 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
View 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;

View File

@@ -3,6 +3,7 @@ var Stack = require('./_Stack'),
assignValue = require('./_assignValue'), assignValue = require('./_assignValue'),
baseAssign = require('./_baseAssign'), baseAssign = require('./_baseAssign'),
baseForOwn = require('./_baseForOwn'), baseForOwn = require('./_baseForOwn'),
cloneBuffer = require('./_cloneBuffer'),
copyArray = require('./_copyArray'), copyArray = require('./_copyArray'),
copySymbols = require('./_copySymbols'), copySymbols = require('./_copySymbols'),
getTag = require('./_getTag'), getTag = require('./_getTag'),
@@ -10,6 +11,7 @@ var Stack = require('./_Stack'),
initCloneByTag = require('./_initCloneByTag'), initCloneByTag = require('./_initCloneByTag'),
initCloneObject = require('./_initCloneObject'), initCloneObject = require('./_initCloneObject'),
isArray = require('./isArray'), isArray = require('./isArray'),
isBuffer = require('./isBuffer'),
isHostObject = require('./_isHostObject'), isHostObject = require('./_isHostObject'),
isObject = require('./isObject'); isObject = require('./isObject');
@@ -91,6 +93,9 @@ function baseClone(value, isDeep, customizer, key, object, stack) {
var tag = getTag(value), var tag = getTag(value),
isFunc = tag == funcTag || tag == genTag; isFunc = tag == funcTag || tag == genTag;
if (isBuffer(value)) {
return cloneBuffer(value, isDeep);
}
if (tag == objectTag || tag == argsTag || (isFunc && !object)) { if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
if (isHostObject(value)) { if (isHostObject(value)) {
return object ? value : {}; return object ? value : {};

View File

@@ -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;

View File

@@ -8,7 +8,7 @@ var FUNC_ERROR_TEXT = 'Expected a function';
* @private * @private
* @param {Function} func The function to delay. * @param {Function} func The function to delay.
* @param {number} wait The number of milliseconds to delay invocation. * @param {number} wait The number of milliseconds to delay invocation.
* @param {Object} args The arguments provide to `func`. * @param {Object} args The arguments to provide to `func`.
* @returns {number} Returns the timer id. * @returns {number} Returns the timer id.
*/ */
function baseDelay(func, wait, args) { function baseDelay(func, wait, args) {

View File

@@ -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);
} }

View File

@@ -3,7 +3,7 @@ var arrayFilter = require('./_arrayFilter'),
/** /**
* The base implementation of `_.functions` which creates an array of * The base implementation of `_.functions` which creates an array of
* `object` function property names filtered from those provided. * `object` function property names filtered from `props`.
* *
* @private * @private
* @param {Object} object The object to inspect. * @param {Object} object The object to inspect.

View File

@@ -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;

View File

@@ -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;
} }
} }

View File

@@ -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);
} }

View File

@@ -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.
*/ */

View File

@@ -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;
} }

View File

@@ -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 {

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

19
_cloneArrayBuffer.js Normal file
View File

@@ -0,0 +1,19 @@
var Uint8Array = require('./_Uint8Array');
/**
* Creates a clone of `arrayBuffer`.
*
* @private
* @param {ArrayBuffer} arrayBuffer The array buffer to clone.
* @returns {ArrayBuffer} Returns the cloned array buffer.
*/
function cloneArrayBuffer(arrayBuffer) {
var Ctor = arrayBuffer.constructor,
result = new Ctor(arrayBuffer.byteLength),
view = new Uint8Array(result);
view.set(new Uint8Array(arrayBuffer));
return result;
}
module.exports = cloneArrayBuffer;

View File

@@ -1,18 +1,19 @@
var Uint8Array = require('./_Uint8Array');
/** /**
* Creates a clone of `buffer`. * Creates a clone of `buffer`.
* *
* @private * @private
* @param {ArrayBuffer} buffer The array buffer to clone. * @param {Buffer} buffer The buffer to clone.
* @returns {ArrayBuffer} Returns the cloned array buffer. * @param {boolean} [isDeep] Specify a deep clone.
* @returns {Buffer} Returns the cloned buffer.
*/ */
function cloneBuffer(buffer) { function cloneBuffer(buffer, isDeep) {
if (isDeep) {
return buffer.slice();
}
var Ctor = buffer.constructor, var Ctor = buffer.constructor,
result = new Ctor(buffer.byteLength), result = new Ctor(buffer.length);
view = new Uint8Array(result);
view.set(new Uint8Array(buffer)); buffer.copy(result);
return result; return result;
} }

View File

@@ -1,4 +1,4 @@
var cloneBuffer = require('./_cloneBuffer'); var cloneArrayBuffer = require('./_cloneArrayBuffer');
/** /**
* Creates a clone of `typedArray`. * Creates a clone of `typedArray`.
@@ -9,10 +9,11 @@ var cloneBuffer = require('./_cloneBuffer');
* @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 ? cloneBuffer(buffer) : buffer, typedArray.byteOffset, typedArray.length); return new Ctor(buffer, typedArray.byteOffset, typedArray.length);
} }
module.exports = cloneTypedArray; module.exports = cloneTypedArray;

View File

@@ -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);
} }

View File

@@ -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;

View File

@@ -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;

View File

@@ -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,

View File

@@ -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,

View File

@@ -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) {

View File

@@ -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);
} }

View File

@@ -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);

View File

@@ -1,10 +1,12 @@
var Map = require('./_Map'), var Map = require('./_Map'),
Set = require('./_Set'); Set = require('./_Set'),
WeakMap = require('./_WeakMap');
/** `Object#toString` result references. */ /** `Object#toString` result references. */
var mapTag = '[object Map]', var mapTag = '[object Map]',
objectTag = '[object Object]', objectTag = '[object Object]',
setTag = '[object Set]'; setTag = '[object Set]',
weakMapTag = '[object WeakMap]';
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = Object.prototype; var objectProto = Object.prototype;
@@ -18,9 +20,10 @@ var funcToString = Function.prototype.toString;
*/ */
var objectToString = objectProto.toString; var objectToString = objectProto.toString;
/** Used to detect maps and sets. */ /** Used to detect maps, sets, and weakmaps. */
var mapCtorString = Map ? funcToString.call(Map) : '', var mapCtorString = Map ? funcToString.call(Map) : '',
setCtorString = Set ? funcToString.call(Set) : ''; setCtorString = Set ? funcToString.call(Set) : '',
weakMapCtorString = WeakMap ? funcToString.call(WeakMap) : '';
/** /**
* Gets the `toStringTag` of `value`. * Gets the `toStringTag` of `value`.
@@ -33,19 +36,20 @@ function getTag(value) {
return objectToString.call(value); return objectToString.call(value);
} }
// Fallback for IE 11 providing `toStringTag` values for maps and sets. // Fallback for IE 11 providing `toStringTag` values for maps, sets, and weakmaps.
if ((Map && getTag(new Map) != mapTag) || (Set && getTag(new Set) != setTag)) { if ((Map && getTag(new Map) != mapTag) ||
(Set && getTag(new Set) != setTag) ||
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
getTag = function(value) { getTag = function(value) {
var result = objectToString.call(value), var result = objectToString.call(value),
Ctor = result == objectTag ? value.constructor : null, Ctor = result == objectTag ? value.constructor : null,
ctorString = typeof Ctor == 'function' ? funcToString.call(Ctor) : ''; ctorString = typeof Ctor == 'function' ? funcToString.call(Ctor) : '';
if (ctorString) { if (ctorString) {
if (ctorString == mapCtorString) { switch (ctorString) {
return mapTag; case mapCtorString: return mapTag;
} case setCtorString: return setTag;
if (ctorString == setCtorString) { case weakMapCtorString: return weakMapTag;
return setTag;
} }
} }
return result; return result;

View File

@@ -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);

View File

@@ -1,4 +1,4 @@
var cloneBuffer = require('./_cloneBuffer'), var cloneArrayBuffer = require('./_cloneArrayBuffer'),
cloneMap = require('./_cloneMap'), cloneMap = require('./_cloneMap'),
cloneRegExp = require('./_cloneRegExp'), cloneRegExp = require('./_cloneRegExp'),
cloneSet = require('./_cloneSet'), cloneSet = require('./_cloneSet'),
@@ -42,7 +42,7 @@ function initCloneByTag(object, tag, isDeep) {
var Ctor = object.constructor; var Ctor = object.constructor;
switch (tag) { switch (tag) {
case arrayBufferTag: case arrayBufferTag:
return cloneBuffer(object); return cloneArrayBuffer(object);
case boolTag: case boolTag:
case dateTag: case dateTag:

View File

@@ -4,7 +4,7 @@ var eq = require('./eq'),
isObject = require('./isObject'); isObject = require('./isObject');
/** /**
* Checks if the provided arguments are from an iteratee call. * Checks if the given arguments are from an iteratee call.
* *
* @private * @private
* @param {*} value The potential iteratee value argument. * @param {*} value The potential iteratee value argument.

View File

@@ -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;

View File

@@ -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 = [];

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

3
add.js
View File

@@ -14,6 +14,9 @@
*/ */
function add(augend, addend) { function add(augend, addend) {
var result; var result;
if (augend === undefined && addend === undefined) {
return 0;
}
if (augend !== undefined) { if (augend !== undefined) {
result = augend; result = augend;
} }

View File

@@ -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
View File

@@ -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;

View File

@@ -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);
} }
}); });

View File

@@ -52,4 +52,7 @@ var bind = rest(function(func, thisArg, partials) {
return createWrapper(func, bitmask, thisArg, partials, holders); return createWrapper(func, bitmask, thisArg, partials, holders);
}); });
// Assign default placeholders.
bind.placeholder = {};
module.exports = bind; module.exports = bind;

View File

@@ -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;

View File

@@ -62,4 +62,7 @@ var bindKey = rest(function(object, key, partials) {
return createWrapper(key, bitmask, object, partials, holders); return createWrapper(key, bitmask, object, partials, holders);
}); });
// Assign default placeholders.
bindKey.placeholder = {};
module.exports = bindKey; module.exports = bindKey;

43
castArray.js Normal file
View 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;

View File

@@ -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);
}); });

187
core.js
View File

@@ -1,6 +1,6 @@
/** /**
* @license * @license
* lodash 4.2.1 (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.2.1'; 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
@@ -576,7 +589,7 @@
* @private * @private
* @param {Function} func The function to delay. * @param {Function} func The function to delay.
* @param {number} wait The number of milliseconds to delay invocation. * @param {number} wait The number of milliseconds to delay invocation.
* @param {Object} args The arguments provide to `func`. * @param {Object} args The arguments to provide to `func`.
* @returns {number} Returns the timer id. * @returns {number} Returns the timer id.
*/ */
function baseDelay(func, wait, args) { function baseDelay(func, wait, args) {
@@ -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);
} }
@@ -692,7 +705,7 @@
/** /**
* The base implementation of `_.functions` which creates an array of * The base implementation of `_.functions` which creates an array of
* `object` function property names filtered from those provided. * `object` function property names filtered from `props`.
* *
* @private * @private
* @param {Object} object The object to inspect. * @param {Object} object The object to inspect.
@@ -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));
} }
/** /**
@@ -1924,7 +1931,7 @@
* Reduces `collection` to a value which is the accumulated result of running * Reduces `collection` to a value which is the accumulated result of running
* each element in `collection` through `iteratee`, where each successive * each element in `collection` through `iteratee`, where each successive
* invocation is supplied the return value of the previous. If `accumulator` * invocation is supplied the return value of the previous. If `accumulator`
* is not provided the first element of `collection` is used as the initial * is not given the first element of `collection` is used as the initial
* value. The iteratee is invoked with four arguments: * value. The iteratee is invoked with four arguments:
* (accumulator, value, index|key, collection). * (accumulator, value, index|key, collection).
* *
@@ -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;
} }
/** /**
@@ -3099,7 +3106,7 @@
/** /**
* Creates an object that inherits from the `prototype` object. If a `properties` * Creates an object that inherits from the `prototype` object. If a `properties`
* object is provided its own enumerable properties are assigned to the created object. * object is given its own enumerable properties are assigned to the created object.
* *
* @static * @static
* @memberOf _ * @memberOf _
@@ -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));
}); });
/** /**
@@ -3407,7 +3414,7 @@
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
/** /**
* This method returns the first argument provided to it. * This method returns the first argument given to it.
* *
* @static * @static
* @memberOf _ * @memberOf _
@@ -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`.
* *
@@ -3592,12 +3601,12 @@
} }
/** /**
* Generates a unique ID. If `prefix` is provided the ID is appended to it. * Generates a unique ID. If `prefix` is given the ID is appended to it.
* *
* @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;

View File

@@ -3,7 +3,7 @@ var baseAssign = require('./_baseAssign'),
/** /**
* Creates an object that inherits from the `prototype` object. If a `properties` * Creates an object that inherits from the `prototype` object. If a `properties`
* object is provided its own enumerable properties are assigned to the created object. * object is given its own enumerable properties are assigned to the created object.
* *
* @static * @static
* @memberOf _ * @memberOf _

View File

@@ -50,4 +50,7 @@ function curry(func, arity, guard) {
return result; return result;
} }
// Assign default placeholders.
curry.placeholder = {};
module.exports = curry; module.exports = curry;

View File

@@ -47,4 +47,7 @@ function curryRight(func, arity, guard) {
return result; return result;
} }
// Assign default placeholders.
curryRight.placeholder = {};
module.exports = curryRight; module.exports = curryRight;

View File

@@ -135,11 +135,13 @@ function debounce(func, wait, options) {
if (maxWait === false) { if (maxWait === false) {
var leadingCall = leading && !timeoutId; var leadingCall = leading && !timeoutId;
} else { } else {
if (!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) {

View File

@@ -5,7 +5,7 @@ var baseDifference = require('./_baseDifference'),
/** /**
* Creates an array of unique `array` values not included in the other * Creates an array of unique `array` values not included in the other
* provided arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) * given arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* for equality comparisons. * for equality comparisons.
* *
* @static * @static
@@ -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))
: []; : [];
}); });

View File

@@ -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))
: []; : [];
}); });

View File

@@ -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)
: []; : [];
}); });

View File

@@ -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;

View File

@@ -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;

View File

@@ -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
View 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;

View File

@@ -1,9 +1,9 @@
var createFlow = require('./_createFlow'); var createFlow = require('./_createFlow');
/** /**
* Creates a function that returns the result of invoking the provided * Creates a function that returns the result of invoking the given functions
* functions with the `this` binding of the created function, where each * with the `this` binding of the created function, where each successive
* successive invocation is supplied the return value of the previous. * invocation is supplied the return value of the previous.
* *
* @static * @static
* @memberOf _ * @memberOf _

View File

@@ -2,7 +2,7 @@ var createFlow = require('./_createFlow');
/** /**
* This method is like `_.flow` except that it creates a function that * This method is like `_.flow` except that it creates a function that
* invokes the provided functions from right to left. * invokes the given functions from right to left.
* *
* @static * @static
* @memberOf _ * @memberOf _

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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
View File

@@ -1,2 +1,2 @@
var _ = require('./lodash').noConflict().runInContext(); var _ = require('./lodash').runInContext();
module.exports = require('./fp/convert')(_); module.exports = require('./fp/convert')(_);

View File

@@ -9,23 +9,45 @@ var mapping = require('./_mapping'),
* @param {Object} util The util object. * @param {Object} util The util object.
* @param {string} name The name of the function to wrap. * @param {string} name The name of the function to wrap.
* @param {Function} func The function to wrap. * @param {Function} func The function to wrap.
* @param {Object} [options] The options object.
* @param {boolean} [options.cap=true] Specify capping iteratee arguments.
* @param {boolean} [options.curry=true] Specify currying.
* @param {boolean} [options.fixed=true] Specify fixed arity.
* @param {boolean} [options.immutable=true] Specify immutable operations.
* @param {boolean} [options.rearg=true] Specify rearranging arguments.
* @returns {Function|Object} Returns the converted function or object. * @returns {Function|Object} Returns the converted function or object.
*/ */
function baseConvert(util, name, func) { function baseConvert(util, name, func, options) {
if (typeof func != 'function') { var setPlaceholder,
isLib = typeof name == 'function',
isObj = name === Object(name);
if (isObj) {
options = func;
func = name; func = name;
name = undefined; name = undefined;
} }
if (func == null) { if (func == null) {
throw new TypeError; throw new TypeError;
} }
var isLib = name === undefined && typeof func.VERSION == 'string'; options || (options = {});
var _ = isLib ? func : { var config = {
'cap': 'cap' in options ? options.cap : true,
'curry': 'curry' in options ? options.curry : true,
'fixed': 'fixed' in options ? options.fixed : true,
'immutable': 'immutable' in options ? options.immutable : true,
'rearg': 'rearg' in options ? options.rearg : true
};
var forceRearg = ('rearg' in options) && options.rearg;
var helpers = 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,
@@ -33,14 +55,17 @@ function baseConvert(util, name, func) {
'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
@@ -71,7 +96,19 @@ function baseConvert(util, name, func) {
}; };
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) {
@@ -80,33 +117,39 @@ function baseConvert(util, name, func) {
}); });
}; };
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],
arity = arguments[1]; arity = arguments[1];
if (!config.cap) {
return iteratee(func, arity);
}
arity = arity > 2 ? (arity - 2) : 1; arity = arity > 2 ? (arity - 2) : 1;
func = iteratee(func); func = iteratee(func);
var length = func.length; var length = func.length;
@@ -145,7 +188,7 @@ function baseConvert(util, name, func) {
}, },
'runInContext': function(runInContext) { 'runInContext': function(runInContext) {
return function(context) { return function(context) {
return baseConvert(util, runInContext(context)); return baseConvert(util, runInContext(context), options);
}; };
} }
}; };
@@ -157,37 +200,38 @@ function baseConvert(util, name, func) {
return wrapper(func); return wrapper(func);
} }
var wrapped = func; var wrapped = func;
if (mutateMap.array[name]) { if (config.immutable) {
wrapped = immutWrap(func, cloneArray); if (mutateMap.array[name]) {
} wrapped = immutWrap(func, cloneArray);
else if (mutateMap.object[name]) { }
wrapped = immutWrap(func, createCloner(func)); else if (mutateMap.object[name]) {
} wrapped = immutWrap(func, createCloner(func));
else if (mutateMap.set[name]) { }
wrapped = immutWrap(func, cloneDeep); else if (mutateMap.set[name]) {
wrapped = immutWrap(func, cloneDeep);
}
} }
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 = spreadStart === undefined result = wrapped;
? ary(wrapped, cap) if (config.fixed) {
: spread(wrapped, spreadStart); result = spreadStart === undefined
? ary(result, aryKey)
if (cap > 1 && !mapping.skipRearg[name]) { : spread(result, spreadStart);
result = rearg(result, mapping.methodRearg[name] || mapping.aryRearg[cap]);
} }
if (reargIndexes) { if (config.rearg && aryKey > 1 && (forceRearg || !mapping.skipRearg[name])) {
result = iterateeRearg(result, reargIndexes); result = rearg(result, mapping.methodRearg[name] || mapping.aryRearg[aryKey]);
} else if (aryN) { }
if (config.cap && aryN) {
result = iterateeAry(result, aryN); result = iterateeAry(result, aryN);
} }
if (cap > 1) { if (config.curry && aryKey > 1) {
result = curry(result, cap); result = curry(result, aryKey);
} }
return false; return false;
} }
@@ -195,24 +239,24 @@ function baseConvert(util, name, func) {
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)]);
} }
@@ -224,6 +268,9 @@ function baseConvert(util, name, func) {
_[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) {

View File

@@ -4,10 +4,14 @@ var baseConvert = require('./_baseConvert');
* Converts `lodash` to an immutable auto-curried iteratee-first data-last version. * Converts `lodash` to an immutable auto-curried iteratee-first data-last version.
* *
* @param {Function} lodash The lodash function. * @param {Function} lodash The lodash function.
* @param {Object} [options] The options object. See `baseConvert` for more details.
* @returns {Function} Returns the converted `lodash`. * @returns {Function} Returns the converted `lodash`.
*/ */
function browserConvert(lodash) { function browserConvert(lodash, options) {
return baseConvert(lodash, lodash); return baseConvert(lodash, lodash, options);
} }
if (typeof _ == 'function') {
_ = browserConvert(_.runInContext());
}
module.exports = browserConvert; module.exports = browserConvert;

View File

@@ -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',
@@ -226,6 +216,10 @@ exports.skipRearg = {
'assignIn': true, 'assignIn': true,
'concat': true, 'concat': true,
'difference': true, 'difference': true,
'gt': true,
'gte': true,
'lt': true,
'lte': true,
'matchesProperty': true, 'matchesProperty': true,
'merge': true, 'merge': true,
'partial': true, 'partial': true,

View File

@@ -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
View File

@@ -0,0 +1,2 @@
var convert = require('./convert');
module.exports = convert('castArray', require('../castArray'));

View File

@@ -7,10 +7,11 @@ var baseConvert = require('./_baseConvert'),
* *
* @param {string} name The name of the function to wrap. * @param {string} name The name of the function to wrap.
* @param {Function} [func] The function to wrap. * @param {Function} [func] The function to wrap.
* @param {Object} [options] The options object. See `baseConvert` for more details.
* @returns {Function|Object} Returns the converted function or object. * @returns {Function|Object} Returns the converted function or object.
*/ */
function convert(name, func) { function convert(name, func, options) {
return baseConvert(util, name, func); return baseConvert(util, name, func, options);
} }
module.exports = convert; module.exports = convert;

2
fp/flattenDepth.js Normal file
View File

@@ -0,0 +1,2 @@
var convert = require('./convert');
module.exports = convert('flattenDepth', require('../flattenDepth'));

1
fp/isArrayBuffer.js Normal file
View File

@@ -0,0 +1 @@
module.exports = require('../isArrayBuffer');

1
fp/isBuffer.js Normal file
View File

@@ -0,0 +1 @@
module.exports = require('../isBuffer');

1
fp/isMap.js Normal file
View File

@@ -0,0 +1 @@
module.exports = require('../isMap');

1
fp/isSet.js Normal file
View File

@@ -0,0 +1 @@
module.exports = require('../isSet');

1
fp/isWeakMap.js Normal file
View File

@@ -0,0 +1 @@
module.exports = require('../isWeakMap');

1
fp/isWeakSet.js Normal file
View File

@@ -0,0 +1 @@
module.exports = require('../isWeakSet');

View File

@@ -1,5 +1,5 @@
/** /**
* This method returns the first argument provided to it. * This method returns the first argument given to it.
* *
* @static * @static
* @memberOf _ * @memberOf _

View File

@@ -1,11 +1,11 @@
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 of the provided * Creates an array of unique values that are included in all given arrays
* arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* for equality comparisons. * for equality comparisons.
* *
* @static * @static
@@ -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)
: []; : [];

View File

@@ -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;

View File

@@ -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;

View File

@@ -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`.

34
isArrayBuffer.js Normal file
View File

@@ -0,0 +1,34 @@
var isObjectLike = require('./isObjectLike');
var arrayBufferTag = '[object ArrayBuffer]';
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/**
* Checks if `value` is classified as an `ArrayBuffer` object.
*
* @static
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
* @example
*
* _.isArrayBuffer(new ArrayBuffer(2));
* // => true
*
* _.isArrayBuffer(new Array(2));
* // => false
*/
function isArrayBuffer(value) {
return isObjectLike(value) && objectToString.call(value) == arrayBufferTag;
}
module.exports = isArrayBuffer;

View File

@@ -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`.

View File

@@ -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`.

48
isBuffer.js Normal file
View File

@@ -0,0 +1,48 @@
var constant = require('./constant'),
root = require('./_root');
/** Used to determine if values are of the language type `Object`. */
var objectTypes = {
'function': true,
'object': true
};
/** Detect free variable `exports`. */
var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
? exports
: undefined;
/** Detect free variable `module`. */
var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
? module
: undefined;
/** Detect the popular CommonJS extension `module.exports`. */
var moduleExports = (freeModule && freeModule.exports === freeExports)
? freeExports
: undefined;
/** Built-in value references. */
var Buffer = moduleExports ? root.Buffer : undefined;
/**
* Checks if `value` is a buffer.
*
* @static
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
* @example
*
* _.isBuffer(new Buffer(2));
* // => true
*
* _.isBuffer(new Uint8Array(2));
* // => false
*/
var isBuffer = !Buffer ? constant(false) : function(value) {
return value instanceof Buffer;
};
module.exports = isBuffer;

View File

@@ -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) {

View File

@@ -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 _

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