Compare commits

..

1 Commits

Author SHA1 Message Date
John-David Dalton
24a4285b70 Bump to v4.2.0. 2016-02-02 00:06:39 -08:00
122 changed files with 561 additions and 439 deletions

View File

@@ -1,4 +1,4 @@
# lodash v4.1.0
# lodash v4.2.0
The [lodash](https://lodash.com/) library exported as [Node.js](https://nodejs.org/) modules.
@@ -28,7 +28,7 @@ var chunk = require('lodash/chunk');
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.2.0-npm) for more details.
**Note:**<br>
Dont assign values to the [special variable](http://nodejs.org/api/repl.html#repl_repl_features) `_` when in the REPL.<br>
@@ -36,9 +36,9 @@ Install [n_](https://www.npmjs.com/package/n_) for a REPL that includes lodash b
## Module formats
Lodash is also available in a variety of other builds & module formats.
Lodash is 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](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)
@@ -52,5 +52,5 @@ Lodash is also available in a variety of other builds & module formats.
## 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.
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.

View File

@@ -1,7 +1,7 @@
var nativeCreate = require('./_nativeCreate');
/** Used for built-in method references. */
var objectProto = global.Object.prototype;
var objectProto = Object.prototype;
/**
* 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. */
var Map = getNative(global, 'Map');
var Map = getNative(root, 'Map');
module.exports = Map;

View File

@@ -1,4 +1,6 @@
var root = require('./_root');
/** Built-in value references. */
var Reflect = global.Reflect;
var Reflect = root.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. */
var Set = getNative(global, 'Set');
var Set = getNative(root, 'Set');
module.exports = Set;

View File

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

View File

@@ -1,4 +1,6 @@
var root = require('./_root');
/** Built-in value references. */
var Uint8Array = global.Uint8Array;
var Uint8Array = root.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. */
var WeakMap = getNative(global, 'WeakMap');
var WeakMap = getNative(root, 'WeakMap');
module.exports = WeakMap;

View File

@@ -5,11 +5,11 @@
* @private
* @param {Function} func The function to invoke.
* @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`.
*/
function apply(func, thisArg, args) {
var length = args ? args.length : 0;
var length = args.length;
switch (length) {
case 0: return func.call(thisArg);
case 1: return func.call(thisArg, args[0]);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -17,7 +17,7 @@ function baseSum(array, iteratee) {
result = result === undefined ? current : (result + current);
}
}
return length ? result : 0;
return result;
}
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;

View File

@@ -1,4 +1,5 @@
var createCtorWrapper = require('./_createCtorWrapper');
var createCtorWrapper = require('./_createCtorWrapper'),
root = require('./_root');
/** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1;
@@ -18,7 +19,7 @@ function createBaseWrapper(func, bitmask, thisArg) {
Ctor = createCtorWrapper(func);
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 wrapper;

View File

@@ -2,7 +2,8 @@ var apply = require('./_apply'),
createCtorWrapper = require('./_createCtorWrapper'),
createHybridWrapper = require('./_createHybridWrapper'),
createRecurryWrapper = require('./_createRecurryWrapper'),
replaceHolders = require('./_replaceHolders');
replaceHolders = require('./_replaceHolders'),
root = require('./_root');
/**
* Creates a function that wraps `func` to enable currying.
@@ -20,7 +21,7 @@ function createCurryWrapper(func, bitmask, arity) {
var length = arguments.length,
index = 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;
while (index--) {

View File

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

View File

@@ -1,5 +1,6 @@
var apply = require('./_apply'),
createCtorWrapper = require('./_createCtorWrapper');
createCtorWrapper = require('./_createCtorWrapper'),
root = require('./_root');
/** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1;
@@ -26,7 +27,7 @@ function createPartialWrapper(func, bitmask, thisArg, partials) {
leftIndex = -1,
leftLength = partials.length,
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) {
args[leftIndex] = partials[leftIndex];

View File

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

View File

@@ -7,10 +7,10 @@ var mapTag = '[object Map]',
setTag = '[object Set]';
/** Used for built-in method references. */
var objectProto = global.Object.prototype;
var objectProto = Object.prototype;
/** 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)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
var apply = require('./_apply'),
isError = require('./isError'),
isObject = require('./isObject'),
rest = require('./rest');
/**
@@ -13,7 +13,7 @@ var apply = require('./_apply'),
* @returns {*} Returns the `func` result or error object.
* @example
*
* // avoid throwing errors for invalid selectors
* // Avoid throwing errors for invalid selectors.
* var elements = _.attempt(function(selector) {
* return document.querySelectorAll(selector);
* }, '>_>');
@@ -26,7 +26,7 @@ var attempt = rest(function(func, args) {
try {
return apply(func, undefined, args);
} 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('!');
* // => 'hi fred!'
*
* // using placeholders
* // Bound with placeholders.
* var bound = _.bind(greet, object, _, '!');
* bound('hi');
* // => 'hi fred!'

View File

@@ -46,7 +46,7 @@ var BIND_FLAG = 1,
* bound('!');
* // => 'hiya fred!'
*
* // using placeholders
* // Bound with placeholders.
* var bound = _.bindKey(object, 'greet', _, '!');
* bound('hi');
* // => 'hiya fred!'

View File

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

59
core.js
View File

@@ -1,6 +1,6 @@
/**
* @license
* lodash 4.1.0 (Custom Build) <https://lodash.com/>
* lodash 4.2.0 (Custom Build) <https://lodash.com/>
* Build: `lodash core -o ./dist/lodash.core.js`
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
@@ -13,7 +13,7 @@
var undefined;
/** Used as the semantic version number. */
var VERSION = '4.1.0';
var VERSION = '4.2.0';
/** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1,
@@ -472,11 +472,11 @@
*
* var wrapped = _([1, 2, 3]);
*
* // returns an unwrapped value
* // Returns an unwrapped value.
* wrapped.reduce(_.add);
* // => 6
*
* // returns a wrapped value
* // Returns a wrapped value.
* var squares = wrapped.map(square);
*
* _.isArray(squares);
@@ -1516,8 +1516,7 @@
* 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)
* 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`
* performs a faster binary search.
* from the end of `array`.
*
* @static
* @memberOf _
@@ -1531,7 +1530,7 @@
* _.indexOf([1, 2, 1, 2], 2);
* // => 1
*
* // using `fromIndex`
* // Search from the `fromIndex`.
* _.indexOf([1, 2, 1, 2], 2, 2);
* // => 3
*/
@@ -1629,10 +1628,9 @@
}
/**
* This method invokes `interceptor` and returns `value`. The interceptor is
* invoked with one argument; (value). The purpose of this method is to "tap into"
* a method chain in order to perform operations on intermediate results within
* the chain.
* This method invokes `interceptor` and returns `value`. The interceptor
* is invoked with one argument; (value). The purpose of this method is to
* "tap into" a method chain in order to modify intermediate results.
*
* @static
* @memberOf _
@@ -1644,6 +1642,7 @@
*
* _([1, 2, 3])
* .tap(function(array) {
* // Mutate input array.
* array.pop();
* })
* .reverse()
@@ -1657,6 +1656,8 @@
/**
* 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
* @memberOf _
@@ -1693,11 +1694,11 @@
* { 'user': 'fred', 'age': 40 }
* ];
*
* // without explicit chaining
* // A sequence without explicit chaining.
* _(users).head();
* // => { 'user': 'barney', 'age': 36 }
*
* // with explicit chaining
* // A sequence with explicit chaining.
* _(users)
* .chain()
* .head()
@@ -1750,15 +1751,15 @@
* { 'user': 'fred', 'active': false }
* ];
*
* // using the `_.matches` iteratee shorthand
* // The `_.matches` iteratee shorthand.
* _.every(users, { 'user': 'barney', 'active': false });
* // => false
*
* // using the `_.matchesProperty` iteratee shorthand
* // The `_.matchesProperty` iteratee shorthand.
* _.every(users, ['active', false]);
* // => true
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.every(users, 'active');
* // => false
*/
@@ -1788,15 +1789,15 @@
* _.filter(users, function(o) { return !o.active; });
* // => objects for ['fred']
*
* // using the `_.matches` iteratee shorthand
* // The `_.matches` iteratee shorthand.
* _.filter(users, { 'age': 36, 'active': true });
* // => objects for ['barney']
*
* // using the `_.matchesProperty` iteratee shorthand
* // The `_.matchesProperty` iteratee shorthand.
* _.filter(users, ['active', false]);
* // => objects for ['fred']
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.filter(users, 'active');
* // => objects for ['barney']
*/
@@ -1826,15 +1827,15 @@
* _.find(users, function(o) { return o.age < 40; });
* // => object for 'barney'
*
* // using the `_.matches` iteratee shorthand
* // The `_.matches` iteratee shorthand.
* _.find(users, { 'age': 1, 'active': true });
* // => object for 'pebbles'
*
* // using the `_.matchesProperty` iteratee shorthand
* // The `_.matchesProperty` iteratee shorthand.
* _.find(users, ['active', false]);
* // => object for 'fred'
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.find(users, 'active');
* // => object for 'barney'
*/
@@ -1911,7 +1912,7 @@
* { 'user': 'fred' }
* ];
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.map(users, 'user');
* // => ['barney', 'fred']
*/
@@ -2008,15 +2009,15 @@
* { 'user': 'fred', 'active': false }
* ];
*
* // using the `_.matches` iteratee shorthand
* // The `_.matches` iteratee shorthand.
* _.some(users, { 'user': 'barney', 'active': false });
* // => false
*
* // using the `_.matchesProperty` iteratee shorthand
* // The `_.matchesProperty` iteratee shorthand.
* _.some(users, ['active', false]);
* // => true
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.some(users, 'active');
* // => true
*/
@@ -2134,7 +2135,7 @@
* bound('!');
* // => 'hi fred!'
*
* // using placeholders
* // Bound with placeholders.
* var bound = _.bind(greet, object, _, '!');
* bound('hi');
* // => 'hi fred!'
@@ -2158,7 +2159,7 @@
* _.defer(function(text) {
* console.log(text);
* }, 'deferred');
* // logs 'deferred' after one or more milliseconds
* // => logs 'deferred' after one or more milliseconds
*/
var defer = rest(function(func, args) {
return baseDelay(func, 1, args);
@@ -3442,7 +3443,7 @@
* { 'user': 'fred', 'age': 40 }
* ];
*
* // create custom iteratee shorthands
* // Create custom iteratee shorthands.
* _.iteratee = _.wrap(_.iteratee, function(callback, func) {
* var p = /^(\S+)\s*([<>])\s*(\S+)$/.exec(func);
* return !p ? callback(func) : function(object) {

View File

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

View File

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

View File

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

View File

@@ -40,21 +40,21 @@ var nativeMax = Math.max;
* @returns {Function} Returns the new debounced function.
* @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));
*
* // invoke `sendMail` when clicked, debouncing subsequent calls
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
* jQuery(element).on('click', _.debounce(sendMail, 300, {
* 'leading': true,
* '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 source = new EventSource('/stream');
* jQuery(source).on('message', debounced);
*
* // cancel a trailing debounced invocation
* // Cancel the trailing debounced invocation.
* jQuery(window).on('popstate', debounced.cancel);
*/
function debounce(func, wait, options) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,18 +1,17 @@
var arrayMap = require('./_arrayMap'),
baseFlatten = require('./_baseFlatten'),
baseIteratee = require('./_baseIteratee');
var baseFlatten = require('./_baseFlatten'),
map = require('./map');
/**
* 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.
* The iteratee is invoked with three arguments: (value, index|key, array).
* The iteratee is invoked with three arguments: (value, index|key, collection).
*
* @static
* @memberOf _
* @category Array
* @param {Array} array The array to iterate over.
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @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
*
* function duplicate(n) {
@@ -22,9 +21,8 @@ var arrayMap = require('./_arrayMap'),
* _.flatMap([1, 2], duplicate);
* // => [1, 1, 2, 2]
*/
function flatMap(array, iteratee) {
var length = array ? array.length : 0;
return length ? baseFlatten(arrayMap(array, baseIteratee(iteratee, 3))) : [];
function flatMap(collection, iteratee) {
return baseFlatten(map(collection, iteratee));
}
module.exports = flatMap;

View File

@@ -29,7 +29,8 @@ function baseConvert(util, name, func) {
'isFunction': util.isFunction,
'iteratee': util.iteratee,
'keys': util.keys,
'rearg': util.rearg
'rearg': util.rearg,
'rest': util.rest
};
var ary = _.ary,
@@ -38,7 +39,8 @@ function baseConvert(util, name, func) {
each = _.forEach,
isFunction = _.isFunction,
keys = _.keys,
rearg = _.rearg;
rearg = _.rearg,
spread = _.spread;
var baseArity = function(func, n) {
return n == 2
@@ -167,17 +169,21 @@ function baseConvert(util, name, func) {
each(mapping.caps, function(cap) {
each(mapping.aryMethod[cap], function(otherName) {
if (name == otherName) {
var indexes = mapping.iterateeRearg[name],
n = !isLib && mapping.aryIteratee[name];
var aryN = !isLib && mapping.iterateeAry[name],
reargIndexes = mapping.iterateeRearg[name],
spreadStart = mapping.methodSpread[name];
result = spreadStart === undefined
? ary(func, cap)
: spread(func, spreadStart);
result = ary(func, cap);
if (cap > 1 && !mapping.skipRearg[name]) {
result = rearg(result, mapping.methodRearg[name] || mapping.aryRearg[cap]);
}
if (indexes) {
result = iterateeRearg(result, indexes);
} else if (n) {
result = iterateeAry(result, n);
if (reargIndexes) {
result = iterateeRearg(result, reargIndexes);
} else if (aryN) {
result = iterateeAry(result, aryN);
}
if (cap > 1) {
result = curry(result, cap);
@@ -198,11 +204,14 @@ function baseConvert(util, name, func) {
if (!isLib) {
return wrap(name, func);
}
// Add placeholder alias.
_.__ = placeholder;
// Iterate over methods for the current ary cap.
var pairs = [];
each(mapping.caps, function(cap) {
each(mapping.aryMethod[cap], function(key) {
var func = _[mapping.key[key] || key];
var func = _[mapping.rename[key] || key];
if (func) {
pairs.push([key, wrap(key, func)]);
}

View File

@@ -3,9 +3,12 @@ exports.aliasToReal = {
'all': 'some',
'allPass': 'overEvery',
'apply': 'spread',
'assoc': 'set',
'assocPath': 'set',
'compose': 'flowRight',
'contains': 'includes',
'dissoc': 'omit',
'dissoc': 'unset',
'dissocPath': 'unset',
'each': 'forEach',
'eachRight': 'forEachRight',
'equals': 'isEqual',
@@ -32,8 +35,59 @@ exports.aliasToReal = {
'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', '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. */
exports.aryIteratee = {
exports.iterateeAry = {
'assignWith': 2,
'assignInWith': 2,
'cloneDeepWith': 1,
@@ -72,53 +126,6 @@ exports.aryIteratee = {
'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. */
exports.iterateeRearg = {
'findKey': [1],
@@ -140,14 +147,10 @@ exports.methodRearg = {
'transform': [2, 0, 1]
};
/** Used to iterate `mapping.aryMethod` keys. */
exports.caps = [1, 2, 3, 4];
/** Used to map keys to other keys. */
exports.key = {
'curryN': 'curry',
'curryRightN': 'curryRight',
'getOr': 'get'
/** Used to map method names to spread configs. */
exports.methodSpread = {
'partial': 1,
'partialRight': 1
};
/** Used to identify methods which mutate arrays or objects. */
@@ -173,7 +176,8 @@ exports.mutate = {
},
'set': {
'set': true,
'setWith': true
'setWith': true,
'unset': true
}
};
@@ -204,6 +208,13 @@ exports.realToAlias = (function() {
return result;
}());
/** Used to map method names to other names. */
exports.rename = {
'curryN': 'curry',
'curryRightN': 'curryRight',
'getOr': 'get'
};
/** Used to track methods that skip `_.rearg`. */
exports.skipRearg = {
'assign': true,
@@ -212,6 +223,8 @@ exports.skipRearg = {
'difference': true,
'matchesProperty': true,
'merge': true,
'partial': true,
'partialRight': true,
'random': true,
'range': true,
'rangeRight': true,

View File

@@ -6,5 +6,6 @@ module.exports = {
'isFunction': require('../isFunction'),
'iteratee': require('../iteratee'),
'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

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

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

View File

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

View File

@@ -8,8 +8,7 @@ var nativeMax = Math.max;
* 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)
* 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`
* performs a faster binary search.
* from the end of `array`.
*
* @static
* @memberOf _
@@ -23,7 +22,7 @@ var nativeMax = Math.max;
* _.indexOf([1, 2, 1, 2], 2);
* // => 1
*
* // using `fromIndex`
* // Search from the `fromIndex`.
* _.indexOf([1, 2, 1, 2], 2, 2);
* // => 3
*/

View File

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

View File

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

View File

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

View File

@@ -4,7 +4,7 @@ var isObjectLike = require('./isObjectLike');
var boolTag = '[object Boolean]';
/** 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)

View File

@@ -4,7 +4,7 @@ var isObjectLike = require('./isObjectLike');
var dateTag = '[object Date]';
/** 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)

View File

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

View File

@@ -4,7 +4,7 @@ var isObjectLike = require('./isObjectLike');
var errorTag = '[object Error]';
/** 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)

View File

@@ -1,5 +1,7 @@
var root = require('./_root');
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeIsFinite = global.isFinite;
var nativeIsFinite = root.isFinite;
/**
* Checks if `value` is a finite primitive number.

View File

@@ -5,7 +5,7 @@ var funcTag = '[object Function]',
genTag = '[object GeneratorFunction]';
/** 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)

View File

@@ -9,10 +9,10 @@ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
var reIsHostCtor = /^\[object .+?Constructor\]$/;
/** Used for built-in method references. */
var objectProto = global.Object.prototype;
var objectProto = Object.prototype;
/** Used to resolve the decompiled source of functions. */
var funcToString = global.Function.prototype.toString;
var funcToString = Function.prototype.toString;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;

View File

@@ -4,7 +4,7 @@ var isObjectLike = require('./isObjectLike');
var numberTag = '[object Number]';
/** 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)

View File

@@ -5,10 +5,10 @@ var isHostObject = require('./_isHostObject'),
var objectTag = '[object Object]';
/** Used for built-in method references. */
var objectProto = global.Object.prototype;
var objectProto = Object.prototype;
/** Used to resolve the decompiled source of functions. */
var funcToString = global.Function.prototype.toString;
var funcToString = Function.prototype.toString;
/** Used to infer the `Object` constructor. */
var objectCtorString = funcToString.call(Object);

View File

@@ -4,7 +4,7 @@ var isObject = require('./isObject');
var regexpTag = '[object RegExp]';
/** 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)

View File

@@ -5,7 +5,7 @@ var isArray = require('./isArray'),
var stringTag = '[object String]';
/** 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)

View File

@@ -4,7 +4,7 @@ var isObjectLike = require('./isObjectLike');
var symbolTag = '[object Symbol]';
/** 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)

View File

@@ -43,7 +43,7 @@ typedArrayTags[regexpTag] = typedArrayTags[setTag] =
typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
/** 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)

View File

@@ -1,7 +1,5 @@
var baseIteratee = require('./_baseIteratee'),
isArray = require('./isArray'),
isObjectLike = require('./isObjectLike'),
matches = require('./matches');
var baseClone = require('./_baseClone'),
baseIteratee = require('./_baseIteratee');
/**
* Creates a function that invokes `func` with the arguments of the created
@@ -21,7 +19,7 @@ var baseIteratee = require('./_baseIteratee'),
* { 'user': 'fred', 'age': 40 }
* ];
*
* // create custom iteratee shorthands
* // Create custom iteratee shorthands.
* _.iteratee = _.wrap(_.iteratee, function(callback, func) {
* var p = /^(\S+)\s*([<>])\s*(\S+)$/.exec(func);
* return !p ? callback(func) : function(object) {
@@ -33,9 +31,7 @@ var baseIteratee = require('./_baseIteratee'),
* // => [{ 'user': 'fred', 'age': 40 }]
*/
function iteratee(func) {
return (isObjectLike(func) && !isArray(func))
? matches(func)
: baseIteratee(func);
return baseIteratee(typeof func == 'function' ? func : baseClone(func, true));
}
module.exports = iteratee;

View File

@@ -1,5 +1,5 @@
/** Used for built-in method references. */
var arrayProto = global.Array.prototype;
var arrayProto = Array.prototype;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeJoin = arrayProto.join;

View File

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

View File

@@ -21,7 +21,7 @@ var nativeMax = Math.max,
* _.lastIndexOf([1, 2, 1, 2], 2);
* // => 3
*
* // using `fromIndex`
* // Search from the `fromIndex`.
* _.lastIndexOf([1, 2, 1, 2], 2, 2);
* // => 1
*/

295
lodash.js
View File

@@ -1,6 +1,6 @@
/**
* @license
* lodash 4.1.0 (Custom Build) <https://lodash.com/>
* lodash 4.2.0 (Custom Build) <https://lodash.com/>
* Build: `lodash -d -o ./foo/lodash.js`
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
@@ -13,7 +13,7 @@
var undefined;
/** Used as the semantic version number. */
var VERSION = '4.1.0';
var VERSION = '4.2.0';
/** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1,
@@ -397,11 +397,11 @@
* @private
* @param {Function} func The function to invoke.
* @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`.
*/
function apply(func, thisArg, args) {
var length = args ? args.length : 0;
var length = args.length;
switch (length) {
case 0: return func.call(thisArg);
case 1: return func.call(thisArg, args[0]);
@@ -841,7 +841,7 @@
result = result === undefined ? current : (result + current);
}
}
return length ? result : 0;
return result;
}
/**
@@ -1254,14 +1254,14 @@
* lodash.isFunction(lodash.bar);
* // => true
*
* // using `context` to mock `Date#getTime` use in `_.now`
* // Use `context` to mock `Date#getTime` use in `_.now`.
* var mock = _.runInContext({
* 'Date': function() {
* return { 'getTime': getTimeMock };
* }
* });
*
* // or creating a suped-up `defer` in Node.js
* // Create a suped-up `defer` in Node.js.
* var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
*/
function runInContext(context) {
@@ -1451,11 +1451,11 @@
*
* var wrapped = _([1, 2, 3]);
*
* // returns an unwrapped value
* // Returns an unwrapped value.
* wrapped.reduce(_.add);
* // => 6
*
* // returns a wrapped value
* // Returns a wrapped value.
* var squares = wrapped.map(square);
*
* _.isArray(squares);
@@ -5471,7 +5471,7 @@
* _.differenceBy([3.1, 2.2, 1.3], [4.4, 2.5], Math.floor);
* // => [3.1, 1.3]
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
* // => [{ 'x': 2 }]
*/
@@ -5603,15 +5603,15 @@
* _.dropRightWhile(users, function(o) { return !o.active; });
* // => objects for ['barney']
*
* // using the `_.matches` iteratee shorthand
* // The `_.matches` iteratee shorthand.
* _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
* // => objects for ['barney', 'fred']
*
* // using the `_.matchesProperty` iteratee shorthand
* // The `_.matchesProperty` iteratee shorthand.
* _.dropRightWhile(users, ['active', false]);
* // => objects for ['barney']
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.dropRightWhile(users, 'active');
* // => objects for ['barney', 'fred', 'pebbles']
*/
@@ -5643,15 +5643,15 @@
* _.dropWhile(users, function(o) { return !o.active; });
* // => objects for ['pebbles']
*
* // using the `_.matches` iteratee shorthand
* // The `_.matches` iteratee shorthand.
* _.dropWhile(users, { 'user': 'barney', 'active': false });
* // => objects for ['fred', 'pebbles']
*
* // using the `_.matchesProperty` iteratee shorthand
* // The `_.matchesProperty` iteratee shorthand.
* _.dropWhile(users, ['active', false]);
* // => objects for ['pebbles']
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.dropWhile(users, 'active');
* // => objects for ['barney', 'fred', 'pebbles']
*/
@@ -5722,15 +5722,15 @@
* _.findIndex(users, function(o) { return o.user == 'barney'; });
* // => 0
*
* // using the `_.matches` iteratee shorthand
* // The `_.matches` iteratee shorthand.
* _.findIndex(users, { 'user': 'fred', 'active': false });
* // => 1
*
* // using the `_.matchesProperty` iteratee shorthand
* // The `_.matchesProperty` iteratee shorthand.
* _.findIndex(users, ['active', false]);
* // => 0
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.findIndex(users, 'active');
* // => 2
*/
@@ -5761,15 +5761,15 @@
* _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
* // => 2
*
* // using the `_.matches` iteratee shorthand
* // The `_.matches` iteratee shorthand.
* _.findLastIndex(users, { 'user': 'barney', 'active': true });
* // => 0
*
* // using the `_.matchesProperty` iteratee shorthand
* // The `_.matchesProperty` iteratee shorthand.
* _.findLastIndex(users, ['active', false]);
* // => 2
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.findLastIndex(users, 'active');
* // => 0
*/
@@ -5779,31 +5779,6 @@
: -1;
}
/**
* Creates an array of flattened values by running each element in `array`
* through `iteratee` and concating its result to the other mapped values.
* The iteratee is invoked with three arguments: (value, index|key, array).
*
* @static
* @memberOf _
* @category Array
* @param {Array} array The array to iterate over.
* @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration.
* @returns {Array} Returns the new array.
* @example
*
* function duplicate(n) {
* return [n, n];
* }
*
* _.flatMap([1, 2], duplicate);
* // => [1, 1, 2, 2]
*/
function flatMap(array, iteratee) {
var length = array ? array.length : 0;
return length ? baseFlatten(arrayMap(array, getIteratee(iteratee, 3))) : [];
}
/**
* Flattens `array` a single level.
*
@@ -5891,8 +5866,7 @@
* 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)
* 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`
* performs a faster binary search.
* from the end of `array`.
*
* @static
* @memberOf _
@@ -5906,7 +5880,7 @@
* _.indexOf([1, 2, 1, 2], 2);
* // => 1
*
* // using `fromIndex`
* // Search from the `fromIndex`.
* _.indexOf([1, 2, 1, 2], 2, 2);
* // => 3
*/
@@ -5977,7 +5951,7 @@
* _.intersectionBy([2.1, 1.2], [4.3, 2.4], Math.floor);
* // => [2.1]
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 1 }]
*/
@@ -6080,7 +6054,7 @@
* _.lastIndexOf([1, 2, 1, 2], 2);
* // => 3
*
* // using `fromIndex`
* // Search from the `fromIndex`.
* _.lastIndexOf([1, 2, 1, 2], 2, 2);
* // => 1
*/
@@ -6356,7 +6330,7 @@
* _.sortedIndexBy(['thirty', 'fifty'], 'forty', _.propertyOf(dict));
* // => 1
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.sortedIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x');
* // => 0
*/
@@ -6424,7 +6398,7 @@
* @returns {number} Returns the index at which `value` should be inserted into `array`.
* @example
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.sortedLastIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x');
* // => 1
*/
@@ -6491,7 +6465,7 @@
* @example
*
* _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
* // => [1.1, 2.2]
* // => [1.1, 2.3]
*/
function sortedUniqBy(array, iteratee) {
return (array && array.length)
@@ -6604,15 +6578,15 @@
* _.takeRightWhile(users, function(o) { return !o.active; });
* // => objects for ['fred', 'pebbles']
*
* // using the `_.matches` iteratee shorthand
* // The `_.matches` iteratee shorthand.
* _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
* // => objects for ['pebbles']
*
* // using the `_.matchesProperty` iteratee shorthand
* // The `_.matchesProperty` iteratee shorthand.
* _.takeRightWhile(users, ['active', false]);
* // => objects for ['fred', 'pebbles']
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.takeRightWhile(users, 'active');
* // => []
*/
@@ -6644,15 +6618,15 @@
* _.takeWhile(users, function(o) { return !o.active; });
* // => objects for ['barney', 'fred']
*
* // using the `_.matches` iteratee shorthand
* // The `_.matches` iteratee shorthand.
* _.takeWhile(users, { 'user': 'barney', 'active': false });
* // => objects for ['barney']
*
* // using the `_.matchesProperty` iteratee shorthand
* // The `_.matchesProperty` iteratee shorthand.
* _.takeWhile(users, ['active', false]);
* // => objects for ['barney', 'fred']
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.takeWhile(users, 'active');
* // => []
*/
@@ -6697,7 +6671,7 @@
* _.unionBy([2.1, 1.2], [4.3, 2.4], Math.floor);
* // => [2.1, 1.2, 4.3]
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 1 }, { 'x': 2 }]
*/
@@ -6774,7 +6748,7 @@
* _.uniqBy([2.1, 1.2, 2.3], Math.floor);
* // => [2.1, 1.2]
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 1 }, { 'x': 2 }]
*/
@@ -6930,7 +6904,7 @@
* _.xorBy([2.1, 1.2], [4.3, 2.4], Math.floor);
* // => [1.2, 4.3]
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 2 }]
*/
@@ -7085,10 +7059,9 @@
}
/**
* This method invokes `interceptor` and returns `value`. The interceptor is
* invoked with one argument; (value). The purpose of this method is to "tap into"
* a method chain in order to perform operations on intermediate results within
* the chain.
* This method invokes `interceptor` and returns `value`. The interceptor
* is invoked with one argument; (value). The purpose of this method is to
* "tap into" a method chain in order to modify intermediate results.
*
* @static
* @memberOf _
@@ -7100,6 +7073,7 @@
*
* _([1, 2, 3])
* .tap(function(array) {
* // Mutate input array.
* array.pop();
* })
* .reverse()
@@ -7113,6 +7087,8 @@
/**
* 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
* @memberOf _
@@ -7188,11 +7164,11 @@
* { 'user': 'fred', 'age': 40 }
* ];
*
* // without explicit chaining
* // A sequence without explicit chaining.
* _(users).head();
* // => { 'user': 'barney', 'age': 36 }
*
* // with explicit chaining
* // A sequence with explicit chaining.
* _(users)
* .chain()
* .head()
@@ -7447,15 +7423,15 @@
* { 'user': 'fred', 'active': false }
* ];
*
* // using the `_.matches` iteratee shorthand
* // The `_.matches` iteratee shorthand.
* _.every(users, { 'user': 'barney', 'active': false });
* // => false
*
* // using the `_.matchesProperty` iteratee shorthand
* // The `_.matchesProperty` iteratee shorthand.
* _.every(users, ['active', false]);
* // => true
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.every(users, 'active');
* // => false
*/
@@ -7488,15 +7464,15 @@
* _.filter(users, function(o) { return !o.active; });
* // => objects for ['fred']
*
* // using the `_.matches` iteratee shorthand
* // The `_.matches` iteratee shorthand.
* _.filter(users, { 'age': 36, 'active': true });
* // => objects for ['barney']
*
* // using the `_.matchesProperty` iteratee shorthand
* // The `_.matchesProperty` iteratee shorthand.
* _.filter(users, ['active', false]);
* // => objects for ['fred']
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.filter(users, 'active');
* // => objects for ['barney']
*/
@@ -7527,15 +7503,15 @@
* _.find(users, function(o) { return o.age < 40; });
* // => object for 'barney'
*
* // using the `_.matches` iteratee shorthand
* // The `_.matches` iteratee shorthand.
* _.find(users, { 'age': 1, 'active': true });
* // => object for 'pebbles'
*
* // using the `_.matchesProperty` iteratee shorthand
* // The `_.matchesProperty` iteratee shorthand.
* _.find(users, ['active', false]);
* // => object for 'fred'
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.find(users, 'active');
* // => object for 'barney'
*/
@@ -7574,6 +7550,30 @@
return baseFind(collection, predicate, baseEachRight);
}
/**
* Creates an array of flattened values by running each element in `collection`
* through `iteratee` and concating its result to the other mapped values.
* The iteratee is invoked with three arguments: (value, index|key, collection).
*
* @static
* @memberOf _
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration.
* @returns {Array} Returns the new flattened array.
* @example
*
* function duplicate(n) {
* return [n, n];
* }
*
* _.flatMap([1, 2], duplicate);
* // => [1, 1, 2, 2]
*/
function flatMap(collection, iteratee) {
return baseFlatten(map(collection, iteratee));
}
/**
* Iterates over elements of `collection` invoking `iteratee` for each element.
* The iteratee is invoked with three arguments: (value, index|key, collection).
@@ -7649,7 +7649,7 @@
* _.groupBy([6.1, 4.2, 6.3], Math.floor);
* // => { '4': [4.2], '6': [6.1, 6.3] }
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.groupBy(['one', 'two', 'three'], 'length');
* // => { '3': ['one', 'two'], '5': ['three'] }
*/
@@ -7805,7 +7805,7 @@
* { 'user': 'fred' }
* ];
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.map(users, 'user');
* // => ['barney', 'fred']
*/
@@ -7837,7 +7837,7 @@
* { 'user': 'barney', 'age': 36 }
* ];
*
* // sort by `user` in ascending order and by `age` in descending order
* // Sort by `user` in ascending order and by `age` in descending order.
* _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
* // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]
*/
@@ -7878,15 +7878,15 @@
* _.partition(users, function(o) { return o.active; });
* // => objects for [['fred'], ['barney', 'pebbles']]
*
* // using the `_.matches` iteratee shorthand
* // The `_.matches` iteratee shorthand.
* _.partition(users, { 'age': 1, 'active': false });
* // => objects for [['pebbles'], ['barney', 'fred']]
*
* // using the `_.matchesProperty` iteratee shorthand
* // The `_.matchesProperty` iteratee shorthand.
* _.partition(users, ['active', false]);
* // => objects for [['barney', 'pebbles'], ['fred']]
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.partition(users, 'active');
* // => objects for [['fred'], ['barney', 'pebbles']]
*/
@@ -7983,15 +7983,15 @@
* _.reject(users, function(o) { return !o.active; });
* // => objects for ['fred']
*
* // using the `_.matches` iteratee shorthand
* // The `_.matches` iteratee shorthand.
* _.reject(users, { 'age': 40, 'active': true });
* // => objects for ['barney']
*
* // using the `_.matchesProperty` iteratee shorthand
* // The `_.matchesProperty` iteratee shorthand.
* _.reject(users, ['active', false]);
* // => objects for ['fred']
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.reject(users, 'active');
* // => objects for ['barney']
*/
@@ -8130,15 +8130,15 @@
* { 'user': 'fred', 'active': false }
* ];
*
* // using the `_.matches` iteratee shorthand
* // The `_.matches` iteratee shorthand.
* _.some(users, { 'user': 'barney', 'active': false });
* // => false
*
* // using the `_.matchesProperty` iteratee shorthand
* // The `_.matchesProperty` iteratee shorthand.
* _.some(users, ['active', false]);
* // => true
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.some(users, 'active');
* // => true
*/
@@ -8338,7 +8338,7 @@
* bound('!');
* // => 'hi fred!'
*
* // using placeholders
* // Bound with placeholders.
* var bound = _.bind(greet, object, _, '!');
* bound('hi');
* // => 'hi fred!'
@@ -8391,7 +8391,7 @@
* bound('!');
* // => 'hiya fred!'
*
* // using placeholders
* // Bound with placeholders.
* var bound = _.bindKey(object, 'greet', _, '!');
* bound('hi');
* // => 'hiya fred!'
@@ -8441,7 +8441,7 @@
* curried(1, 2, 3);
* // => [1, 2, 3]
*
* // using placeholders
* // Curried with placeholders.
* curried(1)(_, 3)(2);
* // => [1, 2, 3]
*/
@@ -8485,7 +8485,7 @@
* curried(1, 2, 3);
* // => [1, 2, 3]
*
* // using placeholders
* // Curried with placeholders.
* curried(3)(1, _)(2);
* // => [1, 2, 3]
*/
@@ -8528,21 +8528,21 @@
* @returns {Function} Returns the new debounced function.
* @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));
*
* // invoke `sendMail` when clicked, debouncing subsequent calls
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
* jQuery(element).on('click', _.debounce(sendMail, 300, {
* 'leading': true,
* '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 source = new EventSource('/stream');
* jQuery(source).on('message', debounced);
*
* // cancel a trailing debounced invocation
* // Cancel the trailing debounced invocation.
* jQuery(window).on('popstate', debounced.cancel);
*/
function debounce(func, wait, options) {
@@ -8675,7 +8675,7 @@
* _.defer(function(text) {
* console.log(text);
* }, 'deferred');
* // logs 'deferred' after one or more milliseconds
* // => logs 'deferred' after one or more milliseconds
*/
var defer = rest(function(func, args) {
return baseDelay(func, 1, args);
@@ -8758,12 +8758,12 @@
* values(object);
* // => [1, 2]
*
* // modifying the result cache
* // Modify the result cache.
* values.cache.set(object, ['a', 'b']);
* values(object);
* // => ['a', 'b']
*
* // replacing `_.memoize.Cache`
* // Replace `_.memoize.Cache`.
* _.memoize.Cache = WeakMap;
*/
function memoize(func, resolver) {
@@ -8908,7 +8908,7 @@
* sayHelloTo('fred');
* // => 'hello fred'
*
* // using placeholders
* // Partially applied with placeholders.
* var greetFred = _.partial(greet, _, 'fred');
* greetFred('hi');
* // => 'hi fred'
@@ -8944,7 +8944,7 @@
* greetFred('hi');
* // => 'hi fred'
*
* // using placeholders
* // Partially applied with placeholders.
* var sayHelloTo = _.partialRight(greet, 'hello', _);
* sayHelloTo('fred');
* // => 'hello fred'
@@ -9041,6 +9041,7 @@
* @memberOf _
* @category Function
* @param {Function} func The function to spread arguments over.
* @param {number} [start=0] The start position of the spread.
* @returns {Function} Returns the new function.
* @example
*
@@ -9051,7 +9052,6 @@
* say(['fred', 'hello']);
* // => 'fred says hello'
*
* // with a Promise
* var numbers = Promise.all([
* Promise.resolve(40),
* Promise.resolve(36)
@@ -9062,13 +9062,20 @@
* }));
* // => a Promise of 76
*/
function spread(func) {
function spread(func, start) {
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
return function(array) {
return apply(func, this, array);
};
start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
return rest(function(args) {
var array = args[start],
otherArgs = args.slice(0, start);
if (array) {
arrayPush(otherArgs, array);
}
return apply(func, this, otherArgs);
});
}
/**
@@ -9101,14 +9108,14 @@
* @returns {Function} Returns the new throttled function.
* @example
*
* // avoid excessively updating the position while scrolling
* // Avoid excessively updating the position while scrolling.
* jQuery(window).on('scroll', _.throttle(updatePosition, 100));
*
* // invoke `renewToken` when the click event is fired, but not more than once every 5 minutes
* // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
* var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
* jQuery(element).on('click', throttled);
*
* // cancel a trailing throttled invocation
* // Cancel the trailing throttled invocation.
* jQuery(window).on('popstate', throttled.cancel);
*/
function throttle(func, wait, options) {
@@ -10727,15 +10734,15 @@
* _.findKey(users, function(o) { return o.age < 40; });
* // => 'barney' (iteration order is not guaranteed)
*
* // using the `_.matches` iteratee shorthand
* // The `_.matches` iteratee shorthand.
* _.findKey(users, { 'age': 1, 'active': true });
* // => 'pebbles'
*
* // using the `_.matchesProperty` iteratee shorthand
* // The `_.matchesProperty` iteratee shorthand.
* _.findKey(users, ['active', false]);
* // => 'fred'
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.findKey(users, 'active');
* // => 'barney'
*/
@@ -10764,15 +10771,15 @@
* _.findLastKey(users, function(o) { return o.age < 40; });
* // => returns 'pebbles' assuming `_.findKey` returns 'barney'
*
* // using the `_.matches` iteratee shorthand
* // The `_.matches` iteratee shorthand.
* _.findLastKey(users, { 'age': 36, 'active': true });
* // => 'barney'
*
* // using the `_.matchesProperty` iteratee shorthand
* // The `_.matchesProperty` iteratee shorthand.
* _.findLastKey(users, ['active', false]);
* // => 'fred'
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.findLastKey(users, 'active');
* // => 'pebbles'
*/
@@ -11245,7 +11252,7 @@
* _.mapValues(users, function(o) { return o.age; });
* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.mapValues(users, 'age');
* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
*/
@@ -11299,6 +11306,8 @@
* method instead. The `customizer` is invoked with seven arguments:
* (objValue, srcValue, key, object, source, stack).
*
* **Note:** This method mutates `object`.
*
* @static
* @memberOf _
* @category Object
@@ -11405,7 +11414,7 @@
/**
* Creates an object composed of the `object` properties `predicate` returns
* truthy for. The predicate is invoked with one argument: (value).
* truthy for. The predicate is invoked with two arguments: (value, key).
*
* @static
* @memberOf _
@@ -11472,6 +11481,8 @@
* are created for all other missing properties. Use `_.setWith` to customize
* `path` creation.
*
* **Note:** This method mutates `object`.
*
* @static
* @memberOf _
* @category Object
@@ -11501,6 +11512,8 @@
* path creation is handled by the method instead. The `customizer` is invoked
* with three arguments: (nsValue, key, nsObject).
*
* **Note:** This method mutates `object`.
*
* @static
* @memberOf _
* @category Object
@@ -11620,6 +11633,8 @@
/**
* Removes the property at `path` of `object`.
*
* **Note:** This method mutates `object`.
*
* @static
* @memberOf _
* @category Object
@@ -12409,54 +12424,54 @@
* @returns {Function} Returns the compiled template function.
* @example
*
* // using the "interpolate" delimiter to create a compiled template
* // Use the "interpolate" delimiter to create a compiled template.
* var compiled = _.template('hello <%= user %>!');
* compiled({ 'user': 'fred' });
* // => 'hello fred!'
*
* // using the HTML "escape" delimiter to escape data property values
* // Use the HTML "escape" delimiter to escape data property values.
* var compiled = _.template('<b><%- value %></b>');
* compiled({ 'value': '<script>' });
* // => '<b>&lt;script&gt;</b>'
*
* // using the "evaluate" delimiter to execute JavaScript and generate HTML
* // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
* var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
* compiled({ 'users': ['fred', 'barney'] });
* // => '<li>fred</li><li>barney</li>'
*
* // using the internal `print` function in "evaluate" delimiters
* // Use the internal `print` function in "evaluate" delimiters.
* var compiled = _.template('<% print("hello " + user); %>!');
* compiled({ 'user': 'barney' });
* // => 'hello barney!'
*
* // using the ES delimiter as an alternative to the default "interpolate" delimiter
* // Use the ES delimiter as an alternative to the default "interpolate" delimiter.
* var compiled = _.template('hello ${ user }!');
* compiled({ 'user': 'pebbles' });
* // => 'hello pebbles!'
*
* // using custom template delimiters
* // Use custom template delimiters.
* _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
* var compiled = _.template('hello {{ user }}!');
* compiled({ 'user': 'mustache' });
* // => 'hello mustache!'
*
* // using backslashes to treat delimiters as plain text
* // Use backslashes to treat delimiters as plain text.
* var compiled = _.template('<%= "\\<%- value %\\>" %>');
* compiled({ 'value': 'ignored' });
* // => '<%- value %>'
*
* // using the `imports` option to import `jQuery` as `jq`
* // Use the `imports` option to import `jQuery` as `jq`.
* var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
* var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
* compiled({ 'users': ['fred', 'barney'] });
* // => '<li>fred</li><li>barney</li>'
*
* // using the `sourceURL` option to specify a custom sourceURL for the template
* // Use the `sourceURL` option to specify a custom sourceURL for the template.
* var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
* compiled(data);
* // => find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector
*
* // using the `variable` option to ensure a with-statement isn't used in the compiled template
* // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
* var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
* compiled.source;
* // => function(data) {
@@ -12465,8 +12480,8 @@
* // return __p;
* // }
*
* // using the `source` property to inline compiled templates for meaningful
* // line numbers in error messages and a stack trace
* // Use the `source` property to inline compiled templates for meaningful
* // line numbers in error messages and stack traces.
* fs.writeFileSync(path.join(cwd, 'jst.js'), '\
* var JST = {\
* "main": ' + _.template(mainText).source + '\
@@ -12913,7 +12928,7 @@
* @returns {*} Returns the `func` result or error object.
* @example
*
* // avoid throwing errors for invalid selectors
* // Avoid throwing errors for invalid selectors.
* var elements = _.attempt(function(selector) {
* return document.querySelectorAll(selector);
* }, '>_>');
@@ -12926,7 +12941,7 @@
try {
return apply(func, undefined, args);
} catch (e) {
return isError(e) ? e : new Error(e);
return isObject(e) ? e : new Error(e);
}
});
@@ -13139,7 +13154,7 @@
* { 'user': 'fred', 'age': 40 }
* ];
*
* // create custom iteratee shorthands
* // Create custom iteratee shorthands.
* _.iteratee = _.wrap(_.iteratee, function(callback, func) {
* var p = /^(\S+)\s*([<>])\s*(\S+)$/.exec(func);
* return !p ? callback(func) : function(object) {
@@ -13151,9 +13166,7 @@
* // => [{ 'user': 'fred', 'age': 40 }]
*/
function iteratee(func) {
return (isObjectLike(func) && !isArray(func))
? matches(func)
: baseIteratee(func);
return baseIteratee(typeof func == 'function' ? func : baseClone(func, true));
}
/**
@@ -13789,7 +13802,7 @@
* _.maxBy(objects, function(o) { return o.n; });
* // => { 'n': 2 }
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.maxBy(objects, 'n');
* // => { 'n': 2 }
*/
@@ -13857,7 +13870,7 @@
* _.minBy(objects, function(o) { return o.n; });
* // => { 'n': 1 }
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.minBy(objects, 'n');
* // => { 'n': 1 }
*/
@@ -13951,7 +13964,7 @@
* _.sumBy(objects, function(o) { return o.n; });
* // => 20
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.sumBy(objects, 'n');
* // => 20
*/

2
map.js
View File

@@ -40,7 +40,7 @@ var arrayMap = require('./_arrayMap'),
* { 'user': 'fred' }
* ];
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.map(users, 'user');
* // => ['barney', 'fred']
*/

View File

@@ -22,7 +22,7 @@ var baseForOwn = require('./_baseForOwn'),
* _.mapValues(users, function(o) { return o.age; });
* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.mapValues(users, 'age');
* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
*/

View File

@@ -20,7 +20,7 @@ var baseExtremum = require('./_baseExtremum'),
* _.maxBy(objects, function(o) { return o.n; });
* // => { 'n': 2 }
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.maxBy(objects, 'n');
* // => { 'n': 2 }
*/

View File

@@ -37,12 +37,12 @@ var FUNC_ERROR_TEXT = 'Expected a function';
* values(object);
* // => [1, 2]
*
* // modifying the result cache
* // Modify the result cache.
* values.cache.set(object, ['a', 'b']);
* values(object);
* // => ['a', 'b']
*
* // replacing `_.memoize.Cache`
* // Replace `_.memoize.Cache`.
* _.memoize.Cache = WeakMap;
*/
function memoize(func, resolver) {

View File

@@ -8,6 +8,8 @@ var baseMerge = require('./_baseMerge'),
* method instead. The `customizer` is invoked with seven arguments:
* (objValue, srcValue, key, object, source, stack).
*
* **Note:** This method mutates `object`.
*
* @static
* @memberOf _
* @category Object

View File

@@ -20,7 +20,7 @@ var baseExtremum = require('./_baseExtremum'),
* _.minBy(objects, function(o) { return o.n; });
* // => { 'n': 1 }
*
* // using the `_.property` iteratee shorthand
* // The `_.property` iteratee shorthand.
* _.minBy(objects, 'n');
* // => { 'n': 1 }
*/

View File

@@ -24,7 +24,7 @@ var baseOrderBy = require('./_baseOrderBy'),
* { 'user': 'barney', 'age': 36 }
* ];
*
* // sort by `user` in ascending order and by `age` in descending order
* // Sort by `user` in ascending order and by `age` in descending order.
* _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
* // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]
*/

View File

@@ -1,6 +1,6 @@
{
"name": "lodash",
"version": "4.1.0",
"version": "4.2.0",
"description": "Lodash modular utilities.",
"homepage": "https://lodash.com/",
"icon": "https://lodash.com/icon.svg",

View File

@@ -1,4 +1,5 @@
var toString = require('./toString');
var root = require('./_root'),
toString = require('./toString');
/** Used to match leading and trailing whitespace. */
var reTrim = /^\s+|\s+$/g;
@@ -7,7 +8,7 @@ var reTrim = /^\s+|\s+$/g;
var reHasHexPrefix = /^0x/i;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeParseInt = global.parseInt;
var nativeParseInt = root.parseInt;
/**
* Converts `string` to an integer of the specified radix. If `radix` is

View File

@@ -32,7 +32,7 @@ var PARTIAL_FLAG = 32;
* sayHelloTo('fred');
* // => 'hello fred'
*
* // using placeholders
* // Partially applied with placeholders.
* var greetFred = _.partial(greet, _, 'fred');
* greetFred('hi');
* // => 'hi fred'

View File

@@ -31,7 +31,7 @@ var PARTIAL_RIGHT_FLAG = 64;
* greetFred('hi');
* // => 'hi fred'
*
* // using placeholders
* // Partially applied with placeholders.
* var sayHelloTo = _.partialRight(greet, 'hello', _);
* sayHelloTo('fred');
* // => 'hello fred'

View File

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

View File

@@ -3,7 +3,7 @@ var baseIteratee = require('./_baseIteratee'),
/**
* Creates an object composed of the `object` properties `predicate` returns
* truthy for. The predicate is invoked with one argument: (value).
* truthy for. The predicate is invoked with two arguments: (value, key).
*
* @static
* @memberOf _

View File

@@ -2,7 +2,7 @@ var baseRandom = require('./_baseRandom'),
isIterateeCall = require('./_isIterateeCall'),
toNumber = require('./toNumber');
/** Built-in method references without a dependency on `global`. */
/** Built-in method references without a dependency on `root`. */
var freeParseFloat = parseFloat;
/* Built-in method references for those with the same name as other `lodash` methods. */

View File

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

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