Compare commits

...

4 Commits

Author SHA1 Message Date
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
John-David Dalton
d8bc95999f Bump to v4.2.1. 2016-02-03 01:09:45 -08:00
John-David Dalton
24a4285b70 Bump to v4.2.0. 2016-02-02 00:06:39 -08:00
164 changed files with 1183 additions and 598 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.1.0 # lodash v4.3.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.
@@ -28,29 +28,13 @@ 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.1.0-npm) for more details. See the [package source](https://github.com/lodash/lodash/tree/4.3.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 also available in a variety of other builds & module formats.
* [lodash](https://www.npmjs.com/package/lodash) & [per method](https://www.npmjs.com/browse/keyword/lodash-modularized) packages
* [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 46-47, Firefox 42-43, 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

@@ -1,7 +1,7 @@
var nativeCreate = require('./_nativeCreate'); var nativeCreate = require('./_nativeCreate');
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = global.Object.prototype; var objectProto = Object.prototype;
/** /**
* Creates an hash object. * Creates an hash object.

View File

@@ -1,6 +1,7 @@
var getNative = require('./_getNative'); var getNative = require('./_getNative'),
root = require('./_root');
/* Built-in method references that are verified to be native. */ /* Built-in method references that are verified to be native. */
var Map = getNative(global, 'Map'); var Map = getNative(root, 'Map');
module.exports = Map; module.exports = Map;

View File

@@ -1,4 +1,6 @@
var root = require('./_root');
/** Built-in value references. */ /** Built-in value references. */
var Reflect = global.Reflect; var Reflect = root.Reflect;
module.exports = Reflect; module.exports = Reflect;

View File

@@ -1,6 +1,7 @@
var getNative = require('./_getNative'); var getNative = require('./_getNative'),
root = require('./_root');
/* Built-in method references that are verified to be native. */ /* Built-in method references that are verified to be native. */
var Set = getNative(global, 'Set'); var Set = getNative(root, 'Set');
module.exports = Set; module.exports = Set;

View File

@@ -1,4 +1,6 @@
var root = require('./_root');
/** Built-in value references. */ /** Built-in value references. */
var Symbol = global.Symbol; var Symbol = root.Symbol;
module.exports = Symbol; module.exports = Symbol;

View File

@@ -1,4 +1,6 @@
var root = require('./_root');
/** Built-in value references. */ /** Built-in value references. */
var Uint8Array = global.Uint8Array; var Uint8Array = root.Uint8Array;
module.exports = Uint8Array; module.exports = Uint8Array;

View File

@@ -1,6 +1,7 @@
var getNative = require('./_getNative'); var getNative = require('./_getNative'),
root = require('./_root');
/* Built-in method references that are verified to be native. */ /* Built-in method references that are verified to be native. */
var WeakMap = getNative(global, 'WeakMap'); var WeakMap = getNative(root, 'WeakMap');
module.exports = WeakMap; module.exports = WeakMap;

View File

@@ -5,11 +5,11 @@
* @private * @private
* @param {Function} func The function to invoke. * @param {Function} func The function to invoke.
* @param {*} thisArg The `this` binding of `func`. * @param {*} thisArg The `this` binding of `func`.
* @param {...*} [args] The arguments to invoke `func` with. * @param {...*} args The arguments to invoke `func` with.
* @returns {*} Returns the result of `func`. * @returns {*} Returns the result of `func`.
*/ */
function apply(func, thisArg, args) { function apply(func, thisArg, args) {
var length = args ? args.length : 0; var length = args.length;
switch (length) { switch (length) {
case 0: return func.call(thisArg); case 0: return func.call(thisArg);
case 1: return func.call(thisArg, args[0]); case 1: return func.call(thisArg, args[0]);

View File

@@ -1,7 +1,7 @@
var eq = require('./eq'); var eq = require('./eq');
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = global.Object.prototype; var objectProto = Object.prototype;
/** Used to check objects for own properties. */ /** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty; var hasOwnProperty = objectProto.hasOwnProperty;

View File

@@ -1,7 +1,7 @@
var eq = require('./eq'); var eq = require('./eq');
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = global.Object.prototype; var objectProto = Object.prototype;
/** Used to check objects for own properties. */ /** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty; var hasOwnProperty = objectProto.hasOwnProperty;

View File

@@ -1,7 +1,7 @@
var assocIndexOf = require('./_assocIndexOf'); var assocIndexOf = require('./_assocIndexOf');
/** Used for built-in method references. */ /** Used for built-in method references. */
var arrayProto = global.Array.prototype; var arrayProto = Array.prototype;
/** Built-in value references. */ /** Built-in value references. */
var splice = arrayProto.splice; var splice = arrayProto.splice;

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

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

@@ -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,5 +1,5 @@
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = global.Object.prototype; var objectProto = Object.prototype;
/** Used to check objects for own properties. */ /** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty; var hasOwnProperty = objectProto.hasOwnProperty;

View File

@@ -16,7 +16,7 @@ var argsTag = '[object Arguments]',
objectTag = '[object Object]'; objectTag = '[object Object]';
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = global.Object.prototype; var objectProto = Object.prototype;
/** Used to check objects for own properties. */ /** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty; var hasOwnProperty = objectProto.hasOwnProperty;

View File

@@ -2,7 +2,7 @@ var Reflect = require('./_Reflect'),
iteratorToArray = require('./_iteratorToArray'); iteratorToArray = require('./_iteratorToArray');
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = global.Object.prototype; var objectProto = Object.prototype;
/** Built-in value references. */ /** Built-in value references. */
var enumerate = Reflect ? Reflect.enumerate : undefined, var enumerate = Reflect ? Reflect.enumerate : undefined,

View File

@@ -2,7 +2,7 @@ var arrayMap = require('./_arrayMap'),
baseIndexOf = require('./_baseIndexOf'); baseIndexOf = require('./_baseIndexOf');
/** Used for built-in method references. */ /** Used for built-in method references. */
var arrayProto = global.Array.prototype; var arrayProto = Array.prototype;
/** Built-in value references. */ /** Built-in value references. */
var splice = arrayProto.splice; var splice = arrayProto.splice;

View File

@@ -5,7 +5,7 @@ var baseToPath = require('./_baseToPath'),
parent = require('./_parent'); parent = require('./_parent');
/** Used for built-in method references. */ /** Used for built-in method references. */
var arrayProto = global.Array.prototype; var arrayProto = Array.prototype;
/** Built-in value references. */ /** Built-in value references. */
var splice = arrayProto.splice; var splice = arrayProto.splice;

View File

@@ -17,7 +17,7 @@ function baseSum(array, iteratee) {
result = result === undefined ? current : (result + current); result = result === undefined ? current : (result + current);
} }
} }
return length ? result : 0; return result;
} }
module.exports = baseSum; module.exports = baseSum;

12
_checkGlobal.js Normal file
View File

@@ -0,0 +1,12 @@
/**
* Checks if `value` is a global object.
*
* @private
* @param {*} value The value to check.
* @returns {null|Object} Returns `value` if it's a global object, else `null`.
*/
function checkGlobal(value) {
return (value && value.Object === Object) ? value : null;
}
module.exports = checkGlobal;

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`.
@@ -12,7 +12,7 @@ function cloneTypedArray(typedArray, isDeep) {
var buffer = typedArray.buffer, var buffer = typedArray.buffer,
Ctor = typedArray.constructor; Ctor = typedArray.constructor;
return new Ctor(isDeep ? cloneBuffer(buffer) : buffer, typedArray.byteOffset, typedArray.length); return new Ctor(isDeep ? cloneArrayBuffer(buffer) : buffer, typedArray.byteOffset, typedArray.length);
} }
module.exports = cloneTypedArray; module.exports = cloneTypedArray;

View File

@@ -1,4 +1,5 @@
var createCtorWrapper = require('./_createCtorWrapper'); var createCtorWrapper = require('./_createCtorWrapper'),
root = require('./_root');
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1; var BIND_FLAG = 1;
@@ -18,7 +19,7 @@ function createBaseWrapper(func, bitmask, thisArg) {
Ctor = createCtorWrapper(func); Ctor = createCtorWrapper(func);
function wrapper() { function wrapper() {
var fn = (this && this !== global && this instanceof wrapper) ? Ctor : func; var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
return fn.apply(isBind ? thisArg : this, arguments); return fn.apply(isBind ? thisArg : this, arguments);
} }
return wrapper; return wrapper;

View File

@@ -2,7 +2,8 @@ var apply = require('./_apply'),
createCtorWrapper = require('./_createCtorWrapper'), createCtorWrapper = require('./_createCtorWrapper'),
createHybridWrapper = require('./_createHybridWrapper'), createHybridWrapper = require('./_createHybridWrapper'),
createRecurryWrapper = require('./_createRecurryWrapper'), createRecurryWrapper = require('./_createRecurryWrapper'),
replaceHolders = require('./_replaceHolders'); replaceHolders = require('./_replaceHolders'),
root = require('./_root');
/** /**
* Creates a function that wraps `func` to enable currying. * Creates a function that wraps `func` to enable currying.
@@ -20,7 +21,7 @@ function createCurryWrapper(func, bitmask, arity) {
var length = arguments.length, var length = arguments.length,
index = length, index = length,
args = Array(length), args = Array(length),
fn = (this && this !== global && this instanceof wrapper) ? Ctor : func, fn = (this && this !== root && this instanceof wrapper) ? Ctor : func,
placeholder = wrapper.placeholder; placeholder = wrapper.placeholder;
while (index--) { while (index--) {

View File

@@ -3,7 +3,8 @@ var composeArgs = require('./_composeArgs'),
createCtorWrapper = require('./_createCtorWrapper'), createCtorWrapper = require('./_createCtorWrapper'),
createRecurryWrapper = require('./_createRecurryWrapper'), createRecurryWrapper = require('./_createRecurryWrapper'),
reorder = require('./_reorder'), reorder = require('./_reorder'),
replaceHolders = require('./_replaceHolders'); replaceHolders = require('./_replaceHolders'),
root = require('./_root');
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1, var BIND_FLAG = 1,
@@ -73,7 +74,7 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials
if (isAry && ary < args.length) { if (isAry && ary < args.length) {
args.length = ary; args.length = ary;
} }
if (this && this !== global && this instanceof wrapper) { if (this && this !== root && this instanceof wrapper) {
fn = Ctor || createCtorWrapper(fn); fn = Ctor || createCtorWrapper(fn);
} }
return fn.apply(thisBinding, args); return fn.apply(thisBinding, args);

View File

@@ -1,5 +1,6 @@
var apply = require('./_apply'), var apply = require('./_apply'),
createCtorWrapper = require('./_createCtorWrapper'); createCtorWrapper = require('./_createCtorWrapper'),
root = require('./_root');
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1; var BIND_FLAG = 1;
@@ -26,7 +27,7 @@ function createPartialWrapper(func, bitmask, thisArg, partials) {
leftIndex = -1, leftIndex = -1,
leftLength = partials.length, leftLength = partials.length,
args = Array(leftLength + argsLength), args = Array(leftLength + argsLength),
fn = (this && this !== global && this instanceof wrapper) ? Ctor : func; fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
while (++leftIndex < leftLength) { while (++leftIndex < leftLength) {
args[leftIndex] = partials[leftIndex]; args[leftIndex] = partials[leftIndex];

View File

@@ -1,7 +1,7 @@
var realNames = require('./_realNames'); var realNames = require('./_realNames');
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = global.Object.prototype; var objectProto = Object.prototype;
/** Used to check objects for own properties. */ /** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty; var hasOwnProperty = objectProto.hasOwnProperty;

View File

@@ -1,16 +1,18 @@
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 = global.Object.prototype; var objectProto = Object.prototype;
/** Used to resolve the decompiled source of functions. */ /** Used to resolve the decompiled source of functions. */
var funcToString = global.Function.prototype.toString; var funcToString = Function.prototype.toString;
/** /**
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
@@ -18,9 +20,10 @@ var funcToString = global.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

@@ -4,7 +4,7 @@ var nativeCreate = require('./_nativeCreate');
var HASH_UNDEFINED = '__lodash_hash_undefined__'; var HASH_UNDEFINED = '__lodash_hash_undefined__';
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = global.Object.prototype; var objectProto = Object.prototype;
/** Used to check objects for own properties. */ /** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty; var hasOwnProperty = objectProto.hasOwnProperty;

View File

@@ -1,7 +1,7 @@
var nativeCreate = require('./_nativeCreate'); var nativeCreate = require('./_nativeCreate');
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = global.Object.prototype; var objectProto = Object.prototype;
/** Used to check objects for own properties. */ /** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty; var hasOwnProperty = objectProto.hasOwnProperty;

View File

@@ -1,5 +1,5 @@
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = global.Object.prototype; var objectProto = Object.prototype;
/** Used to check objects for own properties. */ /** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty; var hasOwnProperty = objectProto.hasOwnProperty;

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

@@ -1,5 +1,5 @@
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = global.Object.prototype; var objectProto = Object.prototype;
/** /**
* Checks if `value` is likely a prototype object. * Checks if `value` is likely a prototype object.

35
_root.js Normal file
View File

@@ -0,0 +1,35 @@
var checkGlobal = require('./_checkGlobal');
/** 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 : null;
/** Detect free variable `module`. */
var freeModule = (objectTypes[typeof module] && module && !module.nodeType) ? module : null;
/** Detect free variable `global` from Node.js. */
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
/** Detect free variable `self`. */
var freeSelf = checkGlobal(objectTypes[typeof self] && self);
/** Detect free variable `window`. */
var freeWindow = checkGlobal(objectTypes[typeof window] && window);
/** Detect `this` as the global object. */
var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
/**
* Used as a reference to the global object.
*
* The `this` value is used if it's the global object to avoid Greasemonkey's
* restricted `window` object, otherwise the `window` object is used.
*/
var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')();
module.exports = root;

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

@@ -12,7 +12,6 @@ module.exports = {
'fill': require('./fill'), 'fill': require('./fill'),
'findIndex': require('./findIndex'), 'findIndex': require('./findIndex'),
'findLastIndex': require('./findLastIndex'), 'findLastIndex': require('./findLastIndex'),
'flatMap': require('./flatMap'),
'flatten': require('./flatten'), 'flatten': require('./flatten'),
'flattenDeep': require('./flattenDeep'), 'flattenDeep': require('./flattenDeep'),
'fromPairs': require('./fromPairs'), 'fromPairs': require('./fromPairs'),

View File

@@ -1,5 +1,5 @@
var apply = require('./_apply'), var apply = require('./_apply'),
isError = require('./isError'), isObject = require('./isObject'),
rest = require('./rest'); rest = require('./rest');
/** /**
@@ -13,7 +13,7 @@ var apply = require('./_apply'),
* @returns {*} Returns the `func` result or error object. * @returns {*} Returns the `func` result or error object.
* @example * @example
* *
* // avoid throwing errors for invalid selectors * // Avoid throwing errors for invalid selectors.
* var elements = _.attempt(function(selector) { * var elements = _.attempt(function(selector) {
* return document.querySelectorAll(selector); * return document.querySelectorAll(selector);
* }, '>_>'); * }, '>_>');
@@ -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 isError(e) ? e : new Error(e); return isObject(e) ? e : new Error(e);
} }
}); });

View File

@@ -36,7 +36,7 @@ var BIND_FLAG = 1,
* bound('!'); * bound('!');
* // => 'hi fred!' * // => 'hi fred!'
* *
* // using placeholders * // Bound with placeholders.
* var bound = _.bind(greet, object, _, '!'); * var bound = _.bind(greet, object, _, '!');
* bound('hi'); * bound('hi');
* // => 'hi fred!' * // => 'hi fred!'
@@ -44,10 +44,15 @@ var BIND_FLAG = 1,
var bind = rest(function(func, thisArg, partials) { var bind = rest(function(func, thisArg, partials) {
var bitmask = BIND_FLAG; var bitmask = BIND_FLAG;
if (partials.length) { if (partials.length) {
var holders = replaceHolders(partials, bind.placeholder); var placeholder = bind.placeholder,
holders = replaceHolders(partials, placeholder);
bitmask |= PARTIAL_FLAG; bitmask |= PARTIAL_FLAG;
} }
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

@@ -46,7 +46,7 @@ var BIND_FLAG = 1,
* bound('!'); * bound('!');
* // => 'hiya fred!' * // => 'hiya fred!'
* *
* // using placeholders * // Bound with placeholders.
* var bound = _.bindKey(object, 'greet', _, '!'); * var bound = _.bindKey(object, 'greet', _, '!');
* bound('hi'); * bound('hi');
* // => 'hiya fred!' * // => 'hiya fred!'
@@ -54,10 +54,15 @@ var BIND_FLAG = 1,
var bindKey = rest(function(object, key, partials) { var bindKey = rest(function(object, key, partials) {
var bitmask = BIND_FLAG | BIND_KEY_FLAG; var bitmask = BIND_FLAG | BIND_KEY_FLAG;
if (partials.length) { if (partials.length) {
var holders = replaceHolders(partials, bindKey.placeholder); var placeholder = bindKey.placeholder,
holders = replaceHolders(partials, placeholder);
bitmask |= PARTIAL_FLAG; bitmask |= PARTIAL_FLAG;
} }
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;

View File

@@ -7,6 +7,7 @@ module.exports = {
'filter': require('./filter'), 'filter': require('./filter'),
'find': require('./find'), 'find': require('./find'),
'findLast': require('./findLast'), 'findLast': require('./findLast'),
'flatMap': require('./flatMap'),
'forEach': require('./forEach'), 'forEach': require('./forEach'),
'forEachRight': require('./forEachRight'), 'forEachRight': require('./forEachRight'),
'groupBy': require('./groupBy'), 'groupBy': require('./groupBy'),

71
core.js
View File

@@ -1,6 +1,6 @@
/** /**
* @license * @license
* lodash 4.1.0 (Custom Build) <https://lodash.com/> * lodash 4.3.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.1.0'; var VERSION = '4.3.0';
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1, var BIND_FLAG = 1,
@@ -472,11 +472,11 @@
* *
* var wrapped = _([1, 2, 3]); * var wrapped = _([1, 2, 3]);
* *
* // returns an unwrapped value * // Returns an unwrapped value.
* wrapped.reduce(_.add); * wrapped.reduce(_.add);
* // => 6 * // => 6
* *
* // returns a wrapped value * // Returns a wrapped value.
* var squares = wrapped.map(square); * var squares = wrapped.map(square);
* *
* _.isArray(squares); * _.isArray(squares);
@@ -576,7 +576,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) {
@@ -692,7 +692,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.
@@ -1516,8 +1516,7 @@
* Gets the index at which the first occurrence of `value` is found in `array` * Gets the index at which the first occurrence of `value` is found in `array`
* 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. If `fromIndex` is negative, it's used as the offset * for equality comparisons. If `fromIndex` is negative, it's used as the offset
* from the end of `array`. If `array` is sorted providing `true` for `fromIndex` * from the end of `array`.
* performs a faster binary search.
* *
* @static * @static
* @memberOf _ * @memberOf _
@@ -1531,7 +1530,7 @@
* _.indexOf([1, 2, 1, 2], 2); * _.indexOf([1, 2, 1, 2], 2);
* // => 1 * // => 1
* *
* // using `fromIndex` * // Search from the `fromIndex`.
* _.indexOf([1, 2, 1, 2], 2, 2); * _.indexOf([1, 2, 1, 2], 2, 2);
* // => 3 * // => 3
*/ */
@@ -1629,10 +1628,9 @@
} }
/** /**
* This method invokes `interceptor` and returns `value`. The interceptor is * This method invokes `interceptor` and returns `value`. The interceptor
* invoked with one argument; (value). The purpose of this method is to "tap into" * is invoked with one argument; (value). The purpose of this method is to
* a method chain in order to perform operations on intermediate results within * "tap into" a method chain in order to modify intermediate results.
* the chain.
* *
* @static * @static
* @memberOf _ * @memberOf _
@@ -1644,6 +1642,7 @@
* *
* _([1, 2, 3]) * _([1, 2, 3])
* .tap(function(array) { * .tap(function(array) {
* // Mutate input array.
* array.pop(); * array.pop();
* }) * })
* .reverse() * .reverse()
@@ -1657,6 +1656,8 @@
/** /**
* This method is like `_.tap` except that it returns the result of `interceptor`. * This method is like `_.tap` except that it returns the result of `interceptor`.
* The purpose of this method is to "pass thru" values replacing intermediate
* results in a method chain.
* *
* @static * @static
* @memberOf _ * @memberOf _
@@ -1693,11 +1694,11 @@
* { 'user': 'fred', 'age': 40 } * { 'user': 'fred', 'age': 40 }
* ]; * ];
* *
* // without explicit chaining * // A sequence without explicit chaining.
* _(users).head(); * _(users).head();
* // => { 'user': 'barney', 'age': 36 } * // => { 'user': 'barney', 'age': 36 }
* *
* // with explicit chaining * // A sequence with explicit chaining.
* _(users) * _(users)
* .chain() * .chain()
* .head() * .head()
@@ -1750,15 +1751,15 @@
* { 'user': 'fred', 'active': false } * { 'user': 'fred', 'active': false }
* ]; * ];
* *
* // using the `_.matches` iteratee shorthand * // The `_.matches` iteratee shorthand.
* _.every(users, { 'user': 'barney', 'active': false }); * _.every(users, { 'user': 'barney', 'active': false });
* // => false * // => false
* *
* // using the `_.matchesProperty` iteratee shorthand * // The `_.matchesProperty` iteratee shorthand.
* _.every(users, ['active', false]); * _.every(users, ['active', false]);
* // => true * // => true
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.every(users, 'active'); * _.every(users, 'active');
* // => false * // => false
*/ */
@@ -1788,15 +1789,15 @@
* _.filter(users, function(o) { return !o.active; }); * _.filter(users, function(o) { return !o.active; });
* // => objects for ['fred'] * // => objects for ['fred']
* *
* // using the `_.matches` iteratee shorthand * // The `_.matches` iteratee shorthand.
* _.filter(users, { 'age': 36, 'active': true }); * _.filter(users, { 'age': 36, 'active': true });
* // => objects for ['barney'] * // => objects for ['barney']
* *
* // using the `_.matchesProperty` iteratee shorthand * // The `_.matchesProperty` iteratee shorthand.
* _.filter(users, ['active', false]); * _.filter(users, ['active', false]);
* // => objects for ['fred'] * // => objects for ['fred']
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.filter(users, 'active'); * _.filter(users, 'active');
* // => objects for ['barney'] * // => objects for ['barney']
*/ */
@@ -1826,15 +1827,15 @@
* _.find(users, function(o) { return o.age < 40; }); * _.find(users, function(o) { return o.age < 40; });
* // => object for 'barney' * // => object for 'barney'
* *
* // using the `_.matches` iteratee shorthand * // The `_.matches` iteratee shorthand.
* _.find(users, { 'age': 1, 'active': true }); * _.find(users, { 'age': 1, 'active': true });
* // => object for 'pebbles' * // => object for 'pebbles'
* *
* // using the `_.matchesProperty` iteratee shorthand * // The `_.matchesProperty` iteratee shorthand.
* _.find(users, ['active', false]); * _.find(users, ['active', false]);
* // => object for 'fred' * // => object for 'fred'
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.find(users, 'active'); * _.find(users, 'active');
* // => object for 'barney' * // => object for 'barney'
*/ */
@@ -1911,7 +1912,7 @@
* { 'user': 'fred' } * { 'user': 'fred' }
* ]; * ];
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.map(users, 'user'); * _.map(users, 'user');
* // => ['barney', 'fred'] * // => ['barney', 'fred']
*/ */
@@ -1923,7 +1924,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).
* *
@@ -2008,15 +2009,15 @@
* { 'user': 'fred', 'active': false } * { 'user': 'fred', 'active': false }
* ]; * ];
* *
* // using the `_.matches` iteratee shorthand * // The `_.matches` iteratee shorthand.
* _.some(users, { 'user': 'barney', 'active': false }); * _.some(users, { 'user': 'barney', 'active': false });
* // => false * // => false
* *
* // using the `_.matchesProperty` iteratee shorthand * // The `_.matchesProperty` iteratee shorthand.
* _.some(users, ['active', false]); * _.some(users, ['active', false]);
* // => true * // => true
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.some(users, 'active'); * _.some(users, 'active');
* // => true * // => true
*/ */
@@ -2134,7 +2135,7 @@
* bound('!'); * bound('!');
* // => 'hi fred!' * // => 'hi fred!'
* *
* // using placeholders * // Bound with placeholders.
* var bound = _.bind(greet, object, _, '!'); * var bound = _.bind(greet, object, _, '!');
* bound('hi'); * bound('hi');
* // => 'hi fred!' * // => 'hi fred!'
@@ -2158,7 +2159,7 @@
* _.defer(function(text) { * _.defer(function(text) {
* console.log(text); * console.log(text);
* }, 'deferred'); * }, 'deferred');
* // logs 'deferred' after one or more milliseconds * // => logs 'deferred' after one or more milliseconds
*/ */
var defer = rest(function(func, args) { var defer = rest(function(func, args) {
return baseDelay(func, 1, args); return baseDelay(func, 1, args);
@@ -3098,7 +3099,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 _
@@ -3406,7 +3407,7 @@
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
/** /**
* This method returns the first argument provided to it. * This method returns the first argument given to it.
* *
* @static * @static
* @memberOf _ * @memberOf _
@@ -3442,7 +3443,7 @@
* { 'user': 'fred', 'age': 40 } * { 'user': 'fred', 'age': 40 }
* ]; * ];
* *
* // create custom iteratee shorthands * // Create custom iteratee shorthands.
* _.iteratee = _.wrap(_.iteratee, function(callback, func) { * _.iteratee = _.wrap(_.iteratee, function(callback, func) {
* var p = /^(\S+)\s*([<>])\s*(\S+)$/.exec(func); * var p = /^(\S+)\s*([<>])\s*(\S+)$/.exec(func);
* return !p ? callback(func) : function(object) { * return !p ? callback(func) : function(object) {
@@ -3591,7 +3592,7 @@
} }
/** /**
* 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 _

View File

@@ -1,7 +1,7 @@
var createAggregator = require('./_createAggregator'); var createAggregator = require('./_createAggregator');
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = global.Object.prototype; var objectProto = Object.prototype;
/** Used to check objects for own properties. */ /** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty; var hasOwnProperty = objectProto.hasOwnProperty;

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

@@ -39,7 +39,7 @@ var CURRY_FLAG = 8;
* curried(1, 2, 3); * curried(1, 2, 3);
* // => [1, 2, 3] * // => [1, 2, 3]
* *
* // using placeholders * // Curried with placeholders.
* curried(1)(_, 3)(2); * curried(1)(_, 3)(2);
* // => [1, 2, 3] * // => [1, 2, 3]
*/ */
@@ -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

@@ -36,7 +36,7 @@ var CURRY_RIGHT_FLAG = 16;
* curried(1, 2, 3); * curried(1, 2, 3);
* // => [1, 2, 3] * // => [1, 2, 3]
* *
* // using placeholders * // Curried with placeholders.
* curried(3)(1, _)(2); * curried(3)(1, _)(2);
* // => [1, 2, 3] * // => [1, 2, 3]
*/ */
@@ -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

@@ -19,7 +19,7 @@ var nativeMax = Math.max;
* to the debounced function return the result of the last `func` invocation. * to the debounced function return the result of the last `func` invocation.
* *
* **Note:** If `leading` and `trailing` options are `true`, `func` is invoked * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
* on the trailing edge of the timeout only if the the debounced function is * on the trailing edge of the timeout only if the debounced function is
* invoked more than once during the `wait` timeout. * invoked more than once during the `wait` timeout.
* *
* See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation) * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)
@@ -40,21 +40,21 @@ var nativeMax = Math.max;
* @returns {Function} Returns the new debounced function. * @returns {Function} Returns the new debounced function.
* @example * @example
* *
* // avoid costly calculations while the window size is in flux * // Avoid costly calculations while the window size is in flux.
* jQuery(window).on('resize', _.debounce(calculateLayout, 150)); * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
* *
* // invoke `sendMail` when clicked, debouncing subsequent calls * // Invoke `sendMail` when clicked, debouncing subsequent calls.
* jQuery(element).on('click', _.debounce(sendMail, 300, { * jQuery(element).on('click', _.debounce(sendMail, 300, {
* 'leading': true, * 'leading': true,
* 'trailing': false * 'trailing': false
* })); * }));
* *
* // ensure `batchLog` is invoked once after 1 second of debounced calls * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
* var source = new EventSource('/stream'); * var source = new EventSource('/stream');
* jQuery(source).on('message', debounced); * jQuery(source).on('message', debounced);
* *
* // cancel a trailing debounced invocation * // Cancel the trailing debounced invocation.
* jQuery(window).on('popstate', debounced.cancel); * jQuery(window).on('popstate', debounced.cancel);
*/ */
function debounce(func, wait, options) { function debounce(func, wait, options) {
@@ -135,7 +135,7 @@ 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),

View File

@@ -16,7 +16,7 @@ var baseDelay = require('./_baseDelay'),
* _.defer(function(text) { * _.defer(function(text) {
* console.log(text); * console.log(text);
* }, 'deferred'); * }, 'deferred');
* // logs 'deferred' after one or more milliseconds * // => logs 'deferred' after one or more milliseconds
*/ */
var defer = rest(function(func, args) { var defer = rest(function(func, args) {
return baseDelay(func, 1, args); return baseDelay(func, 1, args);

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

View File

@@ -22,7 +22,7 @@ var baseDifference = require('./_baseDifference'),
* _.differenceBy([3.1, 2.2, 1.3], [4.4, 2.5], Math.floor); * _.differenceBy([3.1, 2.2, 1.3], [4.4, 2.5], Math.floor);
* // => [3.1, 1.3] * // => [3.1, 1.3]
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
* // => [{ 'x': 2 }] * // => [{ 'x': 2 }]
*/ */

View File

@@ -23,15 +23,15 @@ var baseIteratee = require('./_baseIteratee'),
* _.dropRightWhile(users, function(o) { return !o.active; }); * _.dropRightWhile(users, function(o) { return !o.active; });
* // => objects for ['barney'] * // => objects for ['barney']
* *
* // using the `_.matches` iteratee shorthand * // The `_.matches` iteratee shorthand.
* _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
* // => objects for ['barney', 'fred'] * // => objects for ['barney', 'fred']
* *
* // using the `_.matchesProperty` iteratee shorthand * // The `_.matchesProperty` iteratee shorthand.
* _.dropRightWhile(users, ['active', false]); * _.dropRightWhile(users, ['active', false]);
* // => objects for ['barney'] * // => objects for ['barney']
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.dropRightWhile(users, 'active'); * _.dropRightWhile(users, 'active');
* // => objects for ['barney', 'fred', 'pebbles'] * // => objects for ['barney', 'fred', 'pebbles']
*/ */

View File

@@ -23,15 +23,15 @@ var baseIteratee = require('./_baseIteratee'),
* _.dropWhile(users, function(o) { return !o.active; }); * _.dropWhile(users, function(o) { return !o.active; });
* // => objects for ['pebbles'] * // => objects for ['pebbles']
* *
* // using the `_.matches` iteratee shorthand * // The `_.matches` iteratee shorthand.
* _.dropWhile(users, { 'user': 'barney', 'active': false }); * _.dropWhile(users, { 'user': 'barney', 'active': false });
* // => objects for ['fred', 'pebbles'] * // => objects for ['fred', 'pebbles']
* *
* // using the `_.matchesProperty` iteratee shorthand * // The `_.matchesProperty` iteratee shorthand.
* _.dropWhile(users, ['active', false]); * _.dropWhile(users, ['active', false]);
* // => objects for ['pebbles'] * // => objects for ['pebbles']
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.dropWhile(users, 'active'); * _.dropWhile(users, 'active');
* // => objects for ['barney', 'fred', 'pebbles'] * // => objects for ['barney', 'fred', 'pebbles']
*/ */

View File

@@ -26,15 +26,15 @@ var arrayEvery = require('./_arrayEvery'),
* { 'user': 'fred', 'active': false } * { 'user': 'fred', 'active': false }
* ]; * ];
* *
* // using the `_.matches` iteratee shorthand * // The `_.matches` iteratee shorthand.
* _.every(users, { 'user': 'barney', 'active': false }); * _.every(users, { 'user': 'barney', 'active': false });
* // => false * // => false
* *
* // using the `_.matchesProperty` iteratee shorthand * // The `_.matchesProperty` iteratee shorthand.
* _.every(users, ['active', false]); * _.every(users, ['active', false]);
* // => true * // => true
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.every(users, 'active'); * _.every(users, 'active');
* // => false * // => false
*/ */

View File

@@ -24,15 +24,15 @@ var arrayFilter = require('./_arrayFilter'),
* _.filter(users, function(o) { return !o.active; }); * _.filter(users, function(o) { return !o.active; });
* // => objects for ['fred'] * // => objects for ['fred']
* *
* // using the `_.matches` iteratee shorthand * // The `_.matches` iteratee shorthand.
* _.filter(users, { 'age': 36, 'active': true }); * _.filter(users, { 'age': 36, 'active': true });
* // => objects for ['barney'] * // => objects for ['barney']
* *
* // using the `_.matchesProperty` iteratee shorthand * // The `_.matchesProperty` iteratee shorthand.
* _.filter(users, ['active', false]); * _.filter(users, ['active', false]);
* // => objects for ['fred'] * // => objects for ['fred']
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.filter(users, 'active'); * _.filter(users, 'active');
* // => objects for ['barney'] * // => objects for ['barney']
*/ */

View File

@@ -26,15 +26,15 @@ var baseEach = require('./_baseEach'),
* _.find(users, function(o) { return o.age < 40; }); * _.find(users, function(o) { return o.age < 40; });
* // => object for 'barney' * // => object for 'barney'
* *
* // using the `_.matches` iteratee shorthand * // The `_.matches` iteratee shorthand.
* _.find(users, { 'age': 1, 'active': true }); * _.find(users, { 'age': 1, 'active': true });
* // => object for 'pebbles' * // => object for 'pebbles'
* *
* // using the `_.matchesProperty` iteratee shorthand * // The `_.matchesProperty` iteratee shorthand.
* _.find(users, ['active', false]); * _.find(users, ['active', false]);
* // => object for 'fred' * // => object for 'fred'
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.find(users, 'active'); * _.find(users, 'active');
* // => object for 'barney' * // => object for 'barney'
*/ */

View File

@@ -22,15 +22,15 @@ var baseFindIndex = require('./_baseFindIndex'),
* _.findIndex(users, function(o) { return o.user == 'barney'; }); * _.findIndex(users, function(o) { return o.user == 'barney'; });
* // => 0 * // => 0
* *
* // using the `_.matches` iteratee shorthand * // The `_.matches` iteratee shorthand.
* _.findIndex(users, { 'user': 'fred', 'active': false }); * _.findIndex(users, { 'user': 'fred', 'active': false });
* // => 1 * // => 1
* *
* // using the `_.matchesProperty` iteratee shorthand * // The `_.matchesProperty` iteratee shorthand.
* _.findIndex(users, ['active', false]); * _.findIndex(users, ['active', false]);
* // => 0 * // => 0
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.findIndex(users, 'active'); * _.findIndex(users, 'active');
* // => 2 * // => 2
*/ */

View File

@@ -23,15 +23,15 @@ var baseFind = require('./_baseFind'),
* _.findKey(users, function(o) { return o.age < 40; }); * _.findKey(users, function(o) { return o.age < 40; });
* // => 'barney' (iteration order is not guaranteed) * // => 'barney' (iteration order is not guaranteed)
* *
* // using the `_.matches` iteratee shorthand * // The `_.matches` iteratee shorthand.
* _.findKey(users, { 'age': 1, 'active': true }); * _.findKey(users, { 'age': 1, 'active': true });
* // => 'pebbles' * // => 'pebbles'
* *
* // using the `_.matchesProperty` iteratee shorthand * // The `_.matchesProperty` iteratee shorthand.
* _.findKey(users, ['active', false]); * _.findKey(users, ['active', false]);
* // => 'fred' * // => 'fred'
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.findKey(users, 'active'); * _.findKey(users, 'active');
* // => 'barney' * // => 'barney'
*/ */

View File

@@ -22,15 +22,15 @@ var baseFindIndex = require('./_baseFindIndex'),
* _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
* // => 2 * // => 2
* *
* // using the `_.matches` iteratee shorthand * // The `_.matches` iteratee shorthand.
* _.findLastIndex(users, { 'user': 'barney', 'active': true }); * _.findLastIndex(users, { 'user': 'barney', 'active': true });
* // => 0 * // => 0
* *
* // using the `_.matchesProperty` iteratee shorthand * // The `_.matchesProperty` iteratee shorthand.
* _.findLastIndex(users, ['active', false]); * _.findLastIndex(users, ['active', false]);
* // => 2 * // => 2
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.findLastIndex(users, 'active'); * _.findLastIndex(users, 'active');
* // => 0 * // => 0
*/ */

View File

@@ -23,15 +23,15 @@ var baseFind = require('./_baseFind'),
* _.findLastKey(users, function(o) { return o.age < 40; }); * _.findLastKey(users, function(o) { return o.age < 40; });
* // => returns 'pebbles' assuming `_.findKey` returns 'barney' * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
* *
* // using the `_.matches` iteratee shorthand * // The `_.matches` iteratee shorthand.
* _.findLastKey(users, { 'age': 36, 'active': true }); * _.findLastKey(users, { 'age': 36, 'active': true });
* // => 'barney' * // => 'barney'
* *
* // using the `_.matchesProperty` iteratee shorthand * // The `_.matchesProperty` iteratee shorthand.
* _.findLastKey(users, ['active', false]); * _.findLastKey(users, ['active', false]);
* // => 'fred' * // => 'fred'
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.findLastKey(users, 'active'); * _.findLastKey(users, 'active');
* // => 'pebbles' * // => 'pebbles'
*/ */

View File

@@ -1,18 +1,17 @@
var arrayMap = require('./_arrayMap'), var baseFlatten = require('./_baseFlatten'),
baseFlatten = require('./_baseFlatten'), map = require('./map');
baseIteratee = require('./_baseIteratee');
/** /**
* Creates an array of flattened values by running each element in `array` * Creates an array of flattened values by running each element in `collection`
* through `iteratee` and concating its result to the other mapped values. * through `iteratee` and concating its result to the other mapped values.
* The iteratee is invoked with three arguments: (value, index|key, array). * The iteratee is invoked with three arguments: (value, index|key, collection).
* *
* @static * @static
* @memberOf _ * @memberOf _
* @category Array * @category Collection
* @param {Array} array The array to iterate over. * @param {Array|Object} collection The collection to iterate over.
* @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration.
* @returns {Array} Returns the new array. * @returns {Array} Returns the new flattened array.
* @example * @example
* *
* function duplicate(n) { * function duplicate(n) {
@@ -22,9 +21,8 @@ var arrayMap = require('./_arrayMap'),
* _.flatMap([1, 2], duplicate); * _.flatMap([1, 2], duplicate);
* // => [1, 1, 2, 2] * // => [1, 1, 2, 2]
*/ */
function flatMap(array, iteratee) { function flatMap(collection, iteratee) {
var length = array ? array.length : 0; return baseFlatten(map(collection, iteratee));
return length ? baseFlatten(arrayMap(array, baseIteratee(iteratee, 3))) : [];
} }
module.exports = flatMap; module.exports = flatMap;

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

@@ -9,9 +9,17 @@ 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) {
options || (options = {});
if (typeof func != 'function') { if (typeof func != 'function') {
func = name; func = name;
name = undefined; name = undefined;
@@ -19,6 +27,16 @@ function baseConvert(util, name, func) {
if (func == null) { if (func == null) {
throw new TypeError; throw new TypeError;
} }
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 isLib = name === undefined && typeof func.VERSION == 'string'; var isLib = name === undefined && typeof func.VERSION == 'string';
var _ = isLib ? func : { var _ = isLib ? func : {
@@ -29,7 +47,8 @@ function baseConvert(util, name, func) {
'isFunction': util.isFunction, 'isFunction': util.isFunction,
'iteratee': util.iteratee, 'iteratee': util.iteratee,
'keys': util.keys, 'keys': util.keys,
'rearg': util.rearg 'rearg': util.rearg,
'spread': util.spread
}; };
var ary = _.ary, var ary = _.ary,
@@ -38,7 +57,8 @@ function baseConvert(util, name, func) {
each = _.forEach, each = _.forEach,
isFunction = _.isFunction, isFunction = _.isFunction,
keys = _.keys, keys = _.keys,
rearg = _.rearg; rearg = _.rearg,
spread = _.spread;
var baseArity = function(func, n) { var baseArity = function(func, n) {
return n == 2 return n == 2
@@ -105,6 +125,9 @@ function baseConvert(util, name, func) {
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;
@@ -143,7 +166,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), undefined, options);
}; };
} }
}; };
@@ -154,32 +177,42 @@ function baseConvert(util, name, func) {
if (wrapper) { if (wrapper) {
return wrapper(func); return wrapper(func);
} }
if (mutateMap.array[name]) { var wrapped = func;
func = immutWrap(func, cloneArray); if (config.immutable) {
} if (mutateMap.array[name]) {
else if (mutateMap.object[name]) { wrapped = immutWrap(func, cloneArray);
func = immutWrap(func, createCloner(func)); }
} else if (mutateMap.object[name]) {
else if (mutateMap.set[name]) { wrapped = immutWrap(func, createCloner(func));
func = immutWrap(func, cloneDeep); }
else if (mutateMap.set[name]) {
wrapped = immutWrap(func, cloneDeep);
}
} }
var result; var result;
each(mapping.caps, function(cap) { each(mapping.caps, function(cap) {
each(mapping.aryMethod[cap], function(otherName) { each(mapping.aryMethod[cap], function(otherName) {
if (name == otherName) { if (name == otherName) {
var indexes = mapping.iterateeRearg[name], var aryN = !isLib && mapping.iterateeAry[name],
n = !isLib && mapping.aryIteratee[name]; reargIndexes = mapping.iterateeRearg[name],
spreadStart = mapping.methodSpread[name];
result = ary(func, cap); if (config.fixed) {
if (cap > 1 && !mapping.skipRearg[name]) { result = spreadStart === undefined
? ary(wrapped, cap)
: spread(wrapped, spreadStart);
}
if (config.rearg && cap > 1 && (forceRearg || !mapping.skipRearg[name])) {
result = rearg(result, mapping.methodRearg[name] || mapping.aryRearg[cap]); result = rearg(result, mapping.methodRearg[name] || mapping.aryRearg[cap]);
} }
if (indexes) { if (config.cap) {
result = iterateeRearg(result, indexes); if (reargIndexes) {
} else if (n) { result = iterateeRearg(result, reargIndexes);
result = iterateeAry(result, n); } else if (aryN) {
result = iterateeAry(result, aryN);
}
} }
if (cap > 1) { if (config.curry && cap > 1) {
result = curry(result, cap); result = curry(result, cap);
} }
return false; return false;
@@ -190,7 +223,7 @@ function baseConvert(util, name, func) {
result || (result = func); result || (result = func);
if (mapping.placeholder[name]) { if (mapping.placeholder[name]) {
result.placeholder = placeholder; func.placeholder = result.placeholder = placeholder;
} }
return result; return result;
}; };
@@ -198,11 +231,14 @@ function baseConvert(util, name, func) {
if (!isLib) { if (!isLib) {
return wrap(name, func); return wrap(name, func);
} }
// Add placeholder.
_.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(mapping.caps, function(cap) {
each(mapping.aryMethod[cap], function(key) { each(mapping.aryMethod[cap], function(key) {
var func = _[mapping.key[key] || key]; var func = _[mapping.rename[key] || key];
if (func) { if (func) {
pairs.push([key, wrap(key, func)]); pairs.push([key, wrap(key, func)]);
} }

View File

@@ -4,10 +4,11 @@ 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, undefined, options);
} }
module.exports = browserConvert; module.exports = browserConvert;

View File

@@ -1,11 +1,15 @@
/** Used to map aliases to their real names. */ /** Used to map aliases to their real names. */
exports.aliasToReal = { exports.aliasToReal = {
'__': 'placeholder',
'all': 'some', 'all': 'some',
'allPass': 'overEvery', 'allPass': 'overEvery',
'apply': 'spread', 'apply': 'spread',
'assoc': 'set',
'assocPath': 'set',
'compose': 'flowRight', 'compose': 'flowRight',
'contains': 'includes', 'contains': 'includes',
'dissoc': 'omit', 'dissoc': 'unset',
'dissocPath': 'unset',
'each': 'forEach', 'each': 'forEach',
'eachRight': 'forEachRight', 'eachRight': 'forEachRight',
'equals': 'isEqual', 'equals': 'isEqual',
@@ -32,8 +36,59 @@ exports.aliasToReal = {
'zipObj': 'zipObject' 'zipObj': 'zipObject'
}; };
/** Used to map ary to method names. */
exports.aryMethod = {
1: [
'attempt', 'ceil', 'create', 'curry', 'curryRight', 'floor', 'fromPairs',
'invert', 'iteratee', 'memoize', 'method', 'methodOf', 'mixin', 'over',
'overEvery', 'overSome', 'rest', 'reverse', 'round', 'runInContext',
'spread', 'template', 'trim', 'trimEnd', 'trimStart', 'uniqueId', 'words'
],
2: [
'add', 'after', 'ary', 'assign', 'assignIn', 'at', 'before', 'bind', 'bindKey',
'chunk', 'cloneDeepWith', 'cloneWith', 'concat', 'countBy', 'curryN',
'curryRightN', 'debounce', 'defaults', 'defaultsDeep', 'delay', 'difference',
'drop', 'dropRight', 'dropRightWhile', 'dropWhile', 'endsWith', 'eq', 'every',
'filter', 'find', 'find', 'findIndex', 'findKey', 'findLast', 'findLastIndex',
'findLastKey', 'flatMap', 'forEach', 'forEachRight', 'forIn', 'forInRight',
'forOwn', 'forOwnRight', 'get', 'groupBy', 'gt', 'gte', 'has', 'hasIn',
'includes', 'indexOf', 'intersection', 'invertBy', 'invoke', 'invokeMap',
'isEqual', 'isMatch', 'join', 'keyBy', 'lastIndexOf', 'lt', 'lte', 'map',
'mapKeys', 'mapValues', 'matchesProperty', 'maxBy', 'merge', 'minBy', 'omit',
'omitBy', 'orderBy', 'overArgs', 'pad', 'padEnd', 'padStart', 'parseInt',
'partial', 'partialRight', 'partition', 'pick', 'pickBy', 'pull', 'pullAll',
'pullAt', 'random', 'range', 'rangeRight', 'rearg', 'reject', 'remove',
'repeat', 'result', 'sampleSize', 'some', 'sortBy', 'sortedIndex',
'sortedIndexOf', 'sortedLastIndex', 'sortedLastIndexOf', 'sortedUniqBy',
'split', 'startsWith', 'subtract', 'sumBy', 'take', 'takeRight', 'takeRightWhile',
'takeWhile', 'tap', 'throttle', 'thru', 'times', 'trimChars', 'trimCharsEnd',
'trimCharsStart', 'truncate', 'union', 'uniqBy', 'uniqWith', 'unset',
'unzipWith', 'without', 'wrap', 'xor', 'zip', 'zipObject', 'zipObjectDeep'
],
3: [
'assignInWith', 'assignWith', 'clamp', 'differenceBy', 'differenceWith',
'getOr', 'inRange', 'intersectionBy', 'intersectionWith', 'isEqualWith',
'isMatchWith', 'mergeWith', 'pullAllBy', 'reduce', 'reduceRight', 'replace',
'set', 'slice', 'sortedIndexBy', 'sortedLastIndexBy', 'transform', 'unionBy',
'unionWith', 'xorBy', 'xorWith', 'zipWith'
],
4: [
'fill', 'setWith'
]
};
/** Used to map ary to rearg configs. */
exports.aryRearg = {
2: [1, 0],
3: [2, 1, 0],
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.aryIteratee = { exports.iterateeAry = {
'assignWith': 2, 'assignWith': 2,
'assignInWith': 2, 'assignInWith': 2,
'cloneDeepWith': 1, 'cloneDeepWith': 1,
@@ -72,53 +127,6 @@ exports.aryIteratee = {
'transform': 2 'transform': 2
}; };
/** Used to map ary to method names. */
exports.aryMethod = {
1: [
'attempt', 'ceil', 'create', 'curry', 'curryRight', 'floor', 'fromPairs',
'invert', 'iteratee', 'memoize', 'method', 'methodOf', 'mixin', 'over',
'overEvery', 'overSome', 'rest', 'reverse', 'round', 'runInContext',
'template', 'trim', 'trimEnd', 'trimStart', 'uniqueId', 'words'
],
2: [
'add', 'after', 'ary', 'assign', 'assignIn', 'at', 'before', 'bind', 'bindKey',
'chunk', 'cloneDeepWith', 'cloneWith', 'concat', 'countBy', 'curryN',
'curryRightN', 'debounce', 'defaults', 'defaultsDeep', 'delay', 'difference',
'drop', 'dropRight', 'dropRightWhile', 'dropWhile', 'endsWith', 'eq', 'every',
'filter', 'find', 'find', 'findIndex', 'findKey', 'findLast', 'findLastIndex',
'findLastKey', 'flatMap', 'forEach', 'forEachRight', 'forIn', 'forInRight',
'forOwn', 'forOwnRight', 'get', 'groupBy', 'gt', 'gte', 'has', 'hasIn',
'includes', 'indexOf', 'intersection', 'invertBy', 'invoke', 'invokeMap',
'isEqual', 'isMatch', 'join', 'keyBy', 'lastIndexOf', 'lt', 'lte', 'map',
'mapKeys', 'mapValues', 'matchesProperty', 'maxBy', 'merge', 'minBy', 'omit',
'omitBy', 'orderBy', 'overArgs', 'pad', 'padEnd', 'padStart', 'parseInt',
'partition', 'pick', 'pickBy', 'pull', 'pullAll', 'pullAt', 'random', 'range',
'rangeRight', 'rearg', 'reject', 'remove', 'repeat', 'result', 'sampleSize',
'some', 'sortBy', 'sortedIndex', 'sortedIndexOf', 'sortedLastIndex',
'sortedLastIndexOf', 'sortedUniqBy', 'split', 'startsWith', 'subtract',
'sumBy', 'take', 'takeRight', 'takeRightWhile', 'takeWhile', 'tap', 'throttle',
'thru', 'times', 'truncate', 'union', 'uniqBy', 'uniqWith', 'unset', 'unzipWith',
'without', 'wrap', 'xor', 'zip', 'zipObject', 'zipObjectDeep'
],
3: [
'assignInWith', 'assignWith', 'clamp', 'differenceBy', 'differenceWith',
'getOr', 'inRange', 'intersectionBy', 'intersectionWith', 'isEqualWith',
'isMatchWith', 'mergeWith', 'pullAllBy', 'reduce', 'reduceRight', 'replace',
'set', 'slice', 'sortedIndexBy', 'sortedLastIndexBy', 'transform', 'unionBy',
'unionWith', 'xorBy', 'xorWith', 'zipWith'
],
4: [
'fill', 'setWith'
]
};
/** Used to map ary to rearg configs. */
exports.aryRearg = {
2: [1, 0],
3: [2, 1, 0],
4: [3, 2, 0, 1]
};
/** Used to map method names to iteratee rearg configs. */ /** Used to map method names to iteratee rearg configs. */
exports.iterateeRearg = { exports.iterateeRearg = {
'findKey': [1], 'findKey': [1],
@@ -140,14 +148,10 @@ exports.methodRearg = {
'transform': [2, 0, 1] 'transform': [2, 0, 1]
}; };
/** Used to iterate `mapping.aryMethod` keys. */ /** Used to map method names to spread configs. */
exports.caps = [1, 2, 3, 4]; exports.methodSpread = {
'partial': 1,
/** Used to map keys to other keys. */ 'partialRight': 1
exports.key = {
'curryN': 'curry',
'curryRightN': 'curryRight',
'getOr': 'get'
}; };
/** Used to identify methods which mutate arrays or objects. */ /** Used to identify methods which mutate arrays or objects. */
@@ -173,7 +177,8 @@ exports.mutate = {
}, },
'set': { 'set': {
'set': true, 'set': true,
'setWith': true 'setWith': true,
'unset': true
} }
}; };
@@ -204,17 +209,35 @@ exports.realToAlias = (function() {
return result; return result;
}()); }());
/** Used to map method names to other names. */
exports.rename = {
'curryN': 'curry',
'curryRightN': 'curryRight',
'getOr': 'get',
'trimChars': 'trim',
'trimCharsEnd': 'trimEnd',
'trimCharsStart': 'trimStart'
};
/** Used to track methods that skip `_.rearg`. */ /** Used to track methods that skip `_.rearg`. */
exports.skipRearg = { exports.skipRearg = {
'add': true,
'assign': true, 'assign': true,
'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,
'partialRight': true,
'random': true, 'random': true,
'range': true, 'range': true,
'rangeRight': true, 'rangeRight': true,
'subtract': true,
'zip': true, 'zip': true,
'zipObject': true 'zipObject': true
}; };

View File

@@ -6,5 +6,6 @@ module.exports = {
'isFunction': require('../isFunction'), 'isFunction': require('../isFunction'),
'iteratee': require('../iteratee'), 'iteratee': require('../iteratee'),
'keys': require('../_baseKeys'), 'keys': require('../_baseKeys'),
'rearg': require('../rearg') 'rearg': require('../rearg'),
'spread': require('../spread')
}; };

1
fp/assoc.js Normal file
View File

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

1
fp/assocPath.js Normal file
View File

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

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;

View File

@@ -1 +1 @@
module.exports = require('./omit'); module.exports = require('./unset');

1
fp/dissocPath.js Normal file
View File

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

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 +1,2 @@
module.exports = require('../partial'); var convert = require('./convert');
module.exports = convert('partial', require('../partial'));

View File

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

View File

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

2
fp/trimChars.js Normal file
View File

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

2
fp/trimCharsEnd.js Normal file
View File

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

2
fp/trimCharsStart.js Normal file
View File

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

View File

@@ -1,7 +1,7 @@
var createAggregator = require('./_createAggregator'); var createAggregator = require('./_createAggregator');
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = global.Object.prototype; var objectProto = Object.prototype;
/** Used to check objects for own properties. */ /** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty; var hasOwnProperty = objectProto.hasOwnProperty;
@@ -23,7 +23,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* _.groupBy([6.1, 4.2, 6.3], Math.floor); * _.groupBy([6.1, 4.2, 6.3], Math.floor);
* // => { '4': [4.2], '6': [6.1, 6.3] } * // => { '4': [4.2], '6': [6.1, 6.3] }
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.groupBy(['one', 'two', 'three'], 'length'); * _.groupBy(['one', 'two', 'three'], 'length');
* // => { '3': ['one', 'two'], '5': ['three'] } * // => { '3': ['one', 'two'], '5': ['three'] }
*/ */

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

@@ -8,8 +8,7 @@ var nativeMax = Math.max;
* Gets the index at which the first occurrence of `value` is found in `array` * Gets the index at which the first occurrence of `value` is found in `array`
* 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. If `fromIndex` is negative, it's used as the offset * for equality comparisons. If `fromIndex` is negative, it's used as the offset
* from the end of `array`. If `array` is sorted providing `true` for `fromIndex` * from the end of `array`.
* performs a faster binary search.
* *
* @static * @static
* @memberOf _ * @memberOf _
@@ -23,7 +22,7 @@ var nativeMax = Math.max;
* _.indexOf([1, 2, 1, 2], 2); * _.indexOf([1, 2, 1, 2], 2);
* // => 1 * // => 1
* *
* // using `fromIndex` * // Search from the `fromIndex`.
* _.indexOf([1, 2, 1, 2], 2, 2); * _.indexOf([1, 2, 1, 2], 2, 2);
* // => 3 * // => 3
*/ */

View File

@@ -4,8 +4,8 @@ var arrayMap = require('./_arrayMap'),
toArrayLikeObject = require('./_toArrayLikeObject'); 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

View File

@@ -21,7 +21,7 @@ var arrayMap = require('./_arrayMap'),
* _.intersectionBy([2.1, 1.2], [4.3, 2.4], Math.floor); * _.intersectionBy([2.1, 1.2], [4.3, 2.4], Math.floor);
* // => [2.1] * // => [2.1]
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 1 }] * // => [{ 'x': 1 }]
*/ */

View File

@@ -2,7 +2,7 @@ var baseIteratee = require('./_baseIteratee'),
createInverter = require('./_createInverter'); createInverter = require('./_createInverter');
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = global.Object.prototype; var objectProto = Object.prototype;
/** Used to check objects for own properties. */ /** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty; var hasOwnProperty = objectProto.hasOwnProperty;

View File

@@ -4,7 +4,7 @@ var isArrayLikeObject = require('./isArrayLikeObject');
var argsTag = '[object Arguments]'; var argsTag = '[object Arguments]';
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = global.Object.prototype; var objectProto = Object.prototype;
/** Used to check objects for own properties. */ /** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty; var hasOwnProperty = objectProto.hasOwnProperty;

35
isArrayBuffer.js Normal file
View File

@@ -0,0 +1,35 @@
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 _
* @type Function
* @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

@@ -4,7 +4,7 @@ var isObjectLike = require('./isObjectLike');
var boolTag = '[object Boolean]'; var boolTag = '[object Boolean]';
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = global.Object.prototype; var objectProto = Object.prototype;
/** /**
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)

42
isBuffer.js Normal file
View File

@@ -0,0 +1,42 @@
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 : null;
/** Detect free variable `module`. */
var freeModule = (objectTypes[typeof module] && module && !module.nodeType) ? module : null;
/** Detect the popular CommonJS extension `module.exports`. */
var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : null;
/** 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

@@ -4,7 +4,7 @@ var isObjectLike = require('./isObjectLike');
var dateTag = '[object Date]'; var dateTag = '[object Date]';
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = global.Object.prototype; var objectProto = Object.prototype;
/** /**
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)

View File

@@ -5,7 +5,7 @@ var isArguments = require('./isArguments'),
isString = require('./isString'); isString = require('./isString');
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = global.Object.prototype; var objectProto = Object.prototype;
/** Used to check objects for own properties. */ /** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty; var hasOwnProperty = objectProto.hasOwnProperty;

View File

@@ -4,7 +4,7 @@ var isObjectLike = require('./isObjectLike');
var errorTag = '[object Error]'; var errorTag = '[object Error]';
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = global.Object.prototype; var objectProto = Object.prototype;
/** /**
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)

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