Compare commits

...

3 Commits

Author SHA1 Message Date
John-David Dalton
3514f50902 Bump to v4.3.0. 2016-02-08 00:49:56 -08:00
John-David Dalton
e2a6db008f Bump to v4.2.1. 2016-02-03 00:57:54 -08:00
John-David Dalton
5ca813254d Bump to v4.2.0. 2016-02-02 00:02:37 -08:00
94 changed files with 861 additions and 393 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-amd v4.1.0 # lodash-amd v4.3.0
The [lodash](https://lodash.com/) library exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules. The [lodash](https://lodash.com/) library exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules.
@@ -27,4 +27,4 @@ require({
}); });
``` ```
See the [package source](https://github.com/lodash/lodash/tree/4.1.0-amd) for more details. See the [package source](https://github.com/lodash/lodash/tree/4.3.0-amd) for more details.

View File

@@ -7,11 +7,11 @@ define([], function() {
* @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,4 +1,4 @@
define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_baseForOwn', './_copyArray', './_copySymbols', './_getTag', './_initCloneArray', './_initCloneByTag', './_initCloneObject', './isArray', './_isHostObject', './isObject'], function(Stack, arrayEach, assignValue, baseAssign, baseForOwn, copyArray, copySymbols, getTag, initCloneArray, initCloneByTag, initCloneObject, isArray, isHostObject, isObject) { define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_baseForOwn', './_cloneBuffer', './_copyArray', './_copySymbols', './_getTag', './_initCloneArray', './_initCloneByTag', './_initCloneObject', './isArray', './isBuffer', './_isHostObject', './isObject'], function(Stack, arrayEach, assignValue, baseAssign, baseForOwn, cloneBuffer, copyArray, copySymbols, getTag, initCloneArray, initCloneByTag, initCloneObject, isArray, isBuffer, isHostObject, isObject) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined; var undefined;
@@ -81,6 +81,9 @@ define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_baseF
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

@@ -13,7 +13,7 @@ define([], 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

@@ -2,7 +2,7 @@ define(['./_arrayFilter', './isFunction'], function(arrayFilter, isFunction) {
/** /**
* 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

@@ -22,7 +22,7 @@ define([], function() {
result = result === undefined ? current : (result + current); result = result === undefined ? current : (result + current);
} }
} }
return length ? result : 0; return result;
} }
return baseSum; return baseSum;

20
_cloneArrayBuffer.js Normal file
View File

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

View File

@@ -1,18 +1,21 @@
define(['./_Uint8Array'], function(Uint8Array) { define([], function() {
/** /**
* 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 @@
define(['./_cloneBuffer'], function(cloneBuffer) { define(['./_cloneArrayBuffer'], function(cloneArrayBuffer) {
/** /**
* Creates a clone of `typedArray`. * Creates a clone of `typedArray`.
@@ -12,7 +12,7 @@ define(['./_cloneBuffer'], function(cloneBuffer) {
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);
} }
return cloneTypedArray; return cloneTypedArray;

View File

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

View File

@@ -1,4 +1,4 @@
define(['./_cloneBuffer', './_cloneMap', './_cloneRegExp', './_cloneSet', './_cloneSymbol', './_cloneTypedArray'], function(cloneBuffer, cloneMap, cloneRegExp, cloneSet, cloneSymbol, cloneTypedArray) { define(['./_cloneArrayBuffer', './_cloneMap', './_cloneRegExp', './_cloneSet', './_cloneSymbol', './_cloneTypedArray'], function(cloneArrayBuffer, cloneMap, cloneRegExp, cloneSet, cloneSymbol, cloneTypedArray) {
/** `Object#toString` result references. */ /** `Object#toString` result references. */
var boolTag = '[object Boolean]', var boolTag = '[object Boolean]',
@@ -37,7 +37,7 @@ define(['./_cloneBuffer', './_cloneMap', './_cloneRegExp', './_cloneSet', './_cl
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

@@ -1,7 +1,7 @@
define(['./eq', './isArrayLike', './_isIndex', './isObject'], function(eq, isArrayLike, isIndex, isObject) { define(['./eq', './isArrayLike', './_isIndex', './isObject'], function(eq, isArrayLike, isIndex, isObject) {
/** /**
* Checks if the provided arguments are from an iteratee call. * Checks if the given arguments are from an iteratee call.
* *
* @private * @private
* @param {*} value The potential iteratee value argument. * @param {*} value The potential iteratee value argument.

3
add.js
View File

@@ -19,6 +19,9 @@ define([], function() {
*/ */
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

@@ -1,4 +1,4 @@
define(['./chunk', './compact', './concat', './difference', './differenceBy', './differenceWith', './drop', './dropRight', './dropRightWhile', './dropWhile', './fill', './findIndex', './findLastIndex', './flatMap', './flatten', './flattenDeep', './fromPairs', './head', './indexOf', './initial', './intersection', './intersectionBy', './intersectionWith', './join', './last', './lastIndexOf', './pull', './pullAll', './pullAllBy', './pullAt', './remove', './reverse', './slice', './sortedIndex', './sortedIndexBy', './sortedIndexOf', './sortedLastIndex', './sortedLastIndexBy', './sortedLastIndexOf', './sortedUniq', './sortedUniqBy', './tail', './take', './takeRight', './takeRightWhile', './takeWhile', './union', './unionBy', './unionWith', './uniq', './uniqBy', './uniqWith', './unzip', './unzipWith', './without', './xor', './xorBy', './xorWith', './zip', './zipObject', './zipObjectDeep', './zipWith'], function(chunk, compact, concat, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, fill, findIndex, findLastIndex, flatMap, flatten, flattenDeep, fromPairs, head, indexOf, initial, intersection, intersectionBy, intersectionWith, join, last, lastIndexOf, pull, pullAll, pullAllBy, pullAt, remove, reverse, slice, sortedIndex, sortedIndexBy, sortedIndexOf, sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf, sortedUniq, sortedUniqBy, tail, take, takeRight, takeRightWhile, takeWhile, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, without, xor, xorBy, xorWith, zip, zipObject, zipObjectDeep, zipWith) { define(['./chunk', './compact', './concat', './difference', './differenceBy', './differenceWith', './drop', './dropRight', './dropRightWhile', './dropWhile', './fill', './findIndex', './findLastIndex', './flatten', './flattenDeep', './fromPairs', './head', './indexOf', './initial', './intersection', './intersectionBy', './intersectionWith', './join', './last', './lastIndexOf', './pull', './pullAll', './pullAllBy', './pullAt', './remove', './reverse', './slice', './sortedIndex', './sortedIndexBy', './sortedIndexOf', './sortedLastIndex', './sortedLastIndexBy', './sortedLastIndexOf', './sortedUniq', './sortedUniqBy', './tail', './take', './takeRight', './takeRightWhile', './takeWhile', './union', './unionBy', './unionWith', './uniq', './uniqBy', './uniqWith', './unzip', './unzipWith', './without', './xor', './xorBy', './xorWith', './zip', './zipObject', './zipObjectDeep', './zipWith'], function(chunk, compact, concat, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, fill, findIndex, findLastIndex, flatten, flattenDeep, fromPairs, head, indexOf, initial, intersection, intersectionBy, intersectionWith, join, last, lastIndexOf, pull, pullAll, pullAllBy, pullAt, remove, reverse, slice, sortedIndex, sortedIndexBy, sortedIndexOf, sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf, sortedUniq, sortedUniqBy, tail, take, takeRight, takeRightWhile, takeWhile, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, without, xor, xorBy, xorWith, zip, zipObject, zipObjectDeep, zipWith) {
return { return {
'chunk': chunk, 'chunk': chunk,
'compact': compact, 'compact': compact,
@@ -13,7 +13,6 @@ define(['./chunk', './compact', './concat', './difference', './differenceBy', '.
'fill': fill, 'fill': fill,
'findIndex': findIndex, 'findIndex': findIndex,
'findLastIndex': findLastIndex, 'findLastIndex': findLastIndex,
'flatMap': flatMap,
'flatten': flatten, 'flatten': flatten,
'flattenDeep': flattenDeep, 'flattenDeep': flattenDeep,
'fromPairs': fromPairs, 'fromPairs': fromPairs,

View File

@@ -1,4 +1,4 @@
define(['./_apply', './isError', './rest'], function(apply, isError, rest) { define(['./_apply', './isObject', './rest'], function(apply, isObject, rest) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined; var undefined;
@@ -14,7 +14,7 @@ define(['./_apply', './isError', './rest'], function(apply, isError, rest) {
* @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);
* }, '>_>'); * }, '>_>');
@@ -27,7 +27,7 @@ define(['./_apply', './isError', './rest'], function(apply, isError, rest) {
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

@@ -34,7 +34,7 @@ define(['./_createWrapper', './_replaceHolders', './rest'], function(createWrapp
* 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!'
@@ -42,11 +42,16 @@ define(['./_createWrapper', './_replaceHolders', './rest'], function(createWrapp
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 = {};
return bind; return bind;
}); });

View File

@@ -44,7 +44,7 @@ define(['./_createWrapper', './_replaceHolders', './rest'], function(createWrapp
* 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!'
@@ -52,11 +52,16 @@ define(['./_createWrapper', './_replaceHolders', './rest'], function(createWrapp
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 = {};
return bindKey; return bindKey;
}); });

View File

@@ -1,4 +1,4 @@
define(['./at', './countBy', './each', './eachRight', './every', './filter', './find', './findLast', './forEach', './forEachRight', './groupBy', './includes', './invokeMap', './keyBy', './map', './orderBy', './partition', './reduce', './reduceRight', './reject', './sample', './sampleSize', './shuffle', './size', './some', './sortBy'], function(at, countBy, each, eachRight, every, filter, find, findLast, forEach, forEachRight, groupBy, includes, invokeMap, keyBy, map, orderBy, partition, reduce, reduceRight, reject, sample, sampleSize, shuffle, size, some, sortBy) { define(['./at', './countBy', './each', './eachRight', './every', './filter', './find', './findLast', './flatMap', './forEach', './forEachRight', './groupBy', './includes', './invokeMap', './keyBy', './map', './orderBy', './partition', './reduce', './reduceRight', './reject', './sample', './sampleSize', './shuffle', './size', './some', './sortBy'], function(at, countBy, each, eachRight, every, filter, find, findLast, flatMap, forEach, forEachRight, groupBy, includes, invokeMap, keyBy, map, orderBy, partition, reduce, reduceRight, reject, sample, sampleSize, shuffle, size, some, sortBy) {
return { return {
'at': at, 'at': at,
'countBy': countBy, 'countBy': countBy,
@@ -8,6 +8,7 @@ define(['./at', './countBy', './each', './eachRight', './every', './filter', './
'filter': filter, 'filter': filter,
'find': find, 'find': find,
'findLast': findLast, 'findLast': findLast,
'flatMap': flatMap,
'forEach': forEach, 'forEach': forEach,
'forEachRight': forEachRight, 'forEachRight': forEachRight,
'groupBy': groupBy, 'groupBy': groupBy,

View File

@@ -2,7 +2,7 @@ define(['./_baseAssign', './_baseCreate'], function(baseAssign, baseCreate) {
/** /**
* 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

@@ -42,7 +42,7 @@ define(['./_createWrapper'], function(createWrapper) {
* 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]
*/ */
@@ -53,5 +53,8 @@ define(['./_createWrapper'], function(createWrapper) {
return result; return result;
} }
// Assign default placeholders.
curry.placeholder = {};
return curry; return curry;
}); });

View File

@@ -39,7 +39,7 @@ define(['./_createWrapper'], function(createWrapper) {
* 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]
*/ */
@@ -50,5 +50,8 @@ define(['./_createWrapper'], function(createWrapper) {
return result; return result;
} }
// Assign default placeholders.
curryRight.placeholder = {};
return curryRight; return curryRight;
}); });

View File

@@ -20,7 +20,7 @@ define(['./isObject', './now', './toNumber'], function(isObject, now, toNumber)
* 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)
@@ -41,21 +41,21 @@ define(['./isObject', './now', './toNumber'], function(isObject, now, toNumber)
* @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) {
@@ -136,7 +136,7 @@ define(['./isObject', './now', './toNumber'], function(isObject, now, toNumber)
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

@@ -15,7 +15,7 @@ define(['./_baseDelay', './rest'], function(baseDelay, rest) {
* _.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

@@ -2,7 +2,7 @@ define(['./_baseDifference', './_baseFlatten', './isArrayLikeObject', './rest'],
/** /**
* 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

@@ -20,7 +20,7 @@ define(['./_baseDifference', './_baseFlatten', './_baseIteratee', './isArrayLike
* _.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

@@ -22,15 +22,15 @@ define(['./_baseIteratee', './_baseWhile'], function(baseIteratee, baseWhile) {
* _.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

@@ -22,15 +22,15 @@ define(['./_baseIteratee', './_baseWhile'], function(baseIteratee, baseWhile) {
* _.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

@@ -25,15 +25,15 @@ define(['./_arrayEvery', './_baseEvery', './_baseIteratee', './isArray', './_isI
* { '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

@@ -21,15 +21,15 @@ define(['./_arrayFilter', './_baseFilter', './_baseIteratee', './isArray'], func
* _.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

@@ -25,15 +25,15 @@ define(['./_baseEach', './_baseFind', './_baseFindIndex', './_baseIteratee', './
* _.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

@@ -21,15 +21,15 @@ define(['./_baseFindIndex', './_baseIteratee'], function(baseFindIndex, baseIter
* _.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

@@ -21,15 +21,15 @@ define(['./_baseFind', './_baseForOwn', './_baseIteratee'], function(baseFind, b
* _.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

@@ -21,15 +21,15 @@ define(['./_baseFindIndex', './_baseIteratee'], function(baseFindIndex, baseIter
* _.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

@@ -21,15 +21,15 @@ define(['./_baseFind', './_baseForOwnRight', './_baseIteratee'], function(baseFi
* _.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,16 +1,16 @@
define(['./_arrayMap', './_baseFlatten', './_baseIteratee'], function(arrayMap, baseFlatten, baseIteratee) { define(['./_baseFlatten', './map'], function(baseFlatten, 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. * 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) {
@@ -20,9 +20,8 @@ define(['./_arrayMap', './_baseFlatten', './_baseIteratee'], function(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))) : [];
} }
return flatMap; return flatMap;

View File

@@ -1,9 +1,9 @@
define(['./_createFlow'], function(createFlow) { define(['./_createFlow'], function(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 @@ define(['./_createFlow'], function(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

@@ -23,7 +23,7 @@ define(['./_createAggregator'], function(createAggregator) {
* _.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,7 +1,7 @@
define([], function() { define([], function() {
/** /**
* This method returns the first argument provided to it. * This method returns the first argument given to it.
* *
* @static * @static
* @memberOf _ * @memberOf _

View File

@@ -7,8 +7,7 @@ define(['./_baseIndexOf', './toInteger'], function(baseIndexOf, toInteger) {
* 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 _
@@ -22,7 +21,7 @@ define(['./_baseIndexOf', './toInteger'], function(baseIndexOf, toInteger) {
* _.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

@@ -1,8 +1,8 @@
define(['./_arrayMap', './_baseIntersection', './rest', './_toArrayLikeObject'], function(arrayMap, baseIntersection, rest, toArrayLikeObject) { define(['./_arrayMap', './_baseIntersection', './rest', './_toArrayLikeObject'], function(arrayMap, baseIntersection, rest, 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

@@ -19,7 +19,7 @@ define(['./_arrayMap', './_baseIntersection', './_baseIteratee', './last', './re
* _.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 }]
*/ */

36
isArrayBuffer.js Normal file
View File

@@ -0,0 +1,36 @@
define(['./isObjectLike'], function(isObjectLike) {
var arrayBufferTag = '[object ArrayBuffer]';
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/**
* Checks if `value` is classified as an `ArrayBuffer` object.
*
* @static
* @memberOf _
* @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;
}
return isArrayBuffer;
});

45
isBuffer.js Normal file
View File

@@ -0,0 +1,45 @@
define(['./constant', './_root'], function(constant, root) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used to determine if values are of the language type `Object`. */
var objectTypes = {
'function': true,
'object': true
};
/** Detect free variable `exports`. */
var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : 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;
};
return isBuffer;
});

27
isMap.js Normal file
View File

@@ -0,0 +1,27 @@
define(['./_getTag', './isObjectLike'], function(getTag, isObjectLike) {
/** `Object#toString` result references. */
var mapTag = '[object Map]';
/**
* Checks if `value` is classified as a `Map` object.
*
* @static
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
* @example
*
* _.isMap(new Map);
* // => true
*
* _.isMap(new WeakMap);
* // => false
*/
function isMap(value) {
return isObjectLike(value) && getTag(value) == mapTag;
}
return isMap;
});

27
isSet.js Normal file
View File

@@ -0,0 +1,27 @@
define(['./_getTag', './isObjectLike'], function(getTag, isObjectLike) {
/** `Object#toString` result references. */
var setTag = '[object Set]';
/**
* Checks if `value` is classified as a `Set` object.
*
* @static
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
* @example
*
* _.isSet(new Set);
* // => true
*
* _.isSet(new WeakSet);
* // => false
*/
function isSet(value) {
return isObjectLike(value) && getTag(value) == setTag;
}
return isSet;
});

27
isWeakMap.js Normal file
View File

@@ -0,0 +1,27 @@
define(['./_getTag', './isObjectLike'], function(getTag, isObjectLike) {
/** `Object#toString` result references. */
var weakMapTag = '[object WeakMap]';
/**
* Checks if `value` is classified as a `WeakMap` object.
*
* @static
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
* @example
*
* _.isWeakMap(new WeakMap);
* // => true
*
* _.isWeakMap(new Map);
* // => false
*/
function isWeakMap(value) {
return isObjectLike(value) && getTag(value) == weakMapTag;
}
return isWeakMap;
});

36
isWeakSet.js Normal file
View File

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

View File

@@ -1,4 +1,4 @@
define(['./_baseIteratee', './isArray', './isObjectLike', './matches'], function(baseIteratee, isArray, isObjectLike, matches) { define(['./_baseClone', './_baseIteratee'], function(baseClone, baseIteratee) {
/** /**
* Creates a function that invokes `func` with the arguments of the created * Creates a function that invokes `func` with the arguments of the created
@@ -18,7 +18,7 @@ define(['./_baseIteratee', './isArray', './isObjectLike', './matches'], function
* { '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) {
@@ -30,9 +30,7 @@ define(['./_baseIteratee', './isArray', './isObjectLike', './matches'], function
* // => [{ 'user': 'fred', 'age': 40 }] * // => [{ 'user': 'fred', 'age': 40 }]
*/ */
function iteratee(func) { function iteratee(func) {
return (isObjectLike(func) && !isArray(func)) return baseIteratee(typeof func == 'function' ? func : baseClone(func, true));
? matches(func)
: baseIteratee(func);
} }
return iteratee; return iteratee;

View File

@@ -1,4 +1,4 @@
define(['./clone', './cloneDeep', './cloneDeepWith', './cloneWith', './eq', './gt', './gte', './isArguments', './isArray', './isArrayLike', './isArrayLikeObject', './isBoolean', './isDate', './isElement', './isEmpty', './isEqual', './isEqualWith', './isError', './isFinite', './isFunction', './isInteger', './isLength', './isMatch', './isMatchWith', './isNaN', './isNative', './isNil', './isNull', './isNumber', './isObject', './isObjectLike', './isPlainObject', './isRegExp', './isSafeInteger', './isString', './isSymbol', './isTypedArray', './isUndefined', './lt', './lte', './toArray', './toInteger', './toLength', './toNumber', './toPlainObject', './toSafeInteger', './toString'], function(clone, cloneDeep, cloneDeepWith, cloneWith, eq, gt, gte, isArguments, isArray, isArrayLike, isArrayLikeObject, isBoolean, isDate, isElement, isEmpty, isEqual, isEqualWith, isError, isFinite, isFunction, isInteger, isLength, isMatch, isMatchWith, isNaN, isNative, isNil, isNull, isNumber, isObject, isObjectLike, isPlainObject, isRegExp, isSafeInteger, isString, isSymbol, isTypedArray, isUndefined, lt, lte, toArray, toInteger, toLength, toNumber, toPlainObject, toSafeInteger, toString) { define(['./clone', './cloneDeep', './cloneDeepWith', './cloneWith', './eq', './gt', './gte', './isArguments', './isArray', './isArrayBuffer', './isArrayLike', './isArrayLikeObject', './isBoolean', './isBuffer', './isDate', './isElement', './isEmpty', './isEqual', './isEqualWith', './isError', './isFinite', './isFunction', './isInteger', './isLength', './isMap', './isMatch', './isMatchWith', './isNaN', './isNative', './isNil', './isNull', './isNumber', './isObject', './isObjectLike', './isPlainObject', './isRegExp', './isSafeInteger', './isSet', './isString', './isSymbol', './isTypedArray', './isUndefined', './isWeakMap', './isWeakSet', './lt', './lte', './toArray', './toInteger', './toLength', './toNumber', './toPlainObject', './toSafeInteger', './toString'], function(clone, cloneDeep, cloneDeepWith, cloneWith, eq, gt, gte, isArguments, isArray, isArrayBuffer, isArrayLike, isArrayLikeObject, isBoolean, isBuffer, isDate, isElement, isEmpty, isEqual, isEqualWith, isError, isFinite, isFunction, isInteger, isLength, isMap, isMatch, isMatchWith, isNaN, isNative, isNil, isNull, isNumber, isObject, isObjectLike, isPlainObject, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet, lt, lte, toArray, toInteger, toLength, toNumber, toPlainObject, toSafeInteger, toString) {
return { return {
'clone': clone, 'clone': clone,
'cloneDeep': cloneDeep, 'cloneDeep': cloneDeep,
@@ -9,9 +9,11 @@ define(['./clone', './cloneDeep', './cloneDeepWith', './cloneWith', './eq', './g
'gte': gte, 'gte': gte,
'isArguments': isArguments, 'isArguments': isArguments,
'isArray': isArray, 'isArray': isArray,
'isArrayBuffer': isArrayBuffer,
'isArrayLike': isArrayLike, 'isArrayLike': isArrayLike,
'isArrayLikeObject': isArrayLikeObject, 'isArrayLikeObject': isArrayLikeObject,
'isBoolean': isBoolean, 'isBoolean': isBoolean,
'isBuffer': isBuffer,
'isDate': isDate, 'isDate': isDate,
'isElement': isElement, 'isElement': isElement,
'isEmpty': isEmpty, 'isEmpty': isEmpty,
@@ -22,6 +24,7 @@ define(['./clone', './cloneDeep', './cloneDeepWith', './cloneWith', './eq', './g
'isFunction': isFunction, 'isFunction': isFunction,
'isInteger': isInteger, 'isInteger': isInteger,
'isLength': isLength, 'isLength': isLength,
'isMap': isMap,
'isMatch': isMatch, 'isMatch': isMatch,
'isMatchWith': isMatchWith, 'isMatchWith': isMatchWith,
'isNaN': isNaN, 'isNaN': isNaN,
@@ -34,10 +37,13 @@ define(['./clone', './cloneDeep', './cloneDeepWith', './cloneWith', './eq', './g
'isPlainObject': isPlainObject, 'isPlainObject': isPlainObject,
'isRegExp': isRegExp, 'isRegExp': isRegExp,
'isSafeInteger': isSafeInteger, 'isSafeInteger': isSafeInteger,
'isSet': isSet,
'isString': isString, 'isString': isString,
'isSymbol': isSymbol, 'isSymbol': isSymbol,
'isTypedArray': isTypedArray, 'isTypedArray': isTypedArray,
'isUndefined': isUndefined, 'isUndefined': isUndefined,
'isWeakMap': isWeakMap,
'isWeakSet': isWeakSet,
'lt': lt, 'lt': lt,
'lte': lte, 'lte': lte,
'toArray': toArray, 'toArray': toArray,

View File

@@ -23,7 +23,7 @@ define(['./_indexOfNaN', './toInteger'], function(indexOfNaN, toInteger) {
* _.lastIndexOf([1, 2, 1, 2], 2); * _.lastIndexOf([1, 2, 1, 2], 2);
* // => 3 * // => 3
* *
* // using `fromIndex` * // Search from the `fromIndex`.
* _.lastIndexOf([1, 2, 1, 2], 2, 2); * _.lastIndexOf([1, 2, 1, 2], 2, 2);
* // => 1 * // => 1
*/ */

571
main.js

File diff suppressed because it is too large Load Diff

2
map.js
View File

@@ -37,7 +37,7 @@ define(['./_arrayMap', './_baseIteratee', './_baseMap', './isArray'], function(a
* { 'user': 'fred' } * { 'user': 'fred' }
* ]; * ];
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.map(users, 'user'); * _.map(users, 'user');
* // => ['barney', 'fred'] * // => ['barney', 'fred']
*/ */

View File

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

View File

@@ -21,7 +21,7 @@ define(['./_baseExtremum', './_baseIteratee', './gt'], function(baseExtremum, ba
* _.maxBy(objects, function(o) { return o.n; }); * _.maxBy(objects, function(o) { return o.n; });
* // => { 'n': 2 } * // => { 'n': 2 }
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.maxBy(objects, 'n'); * _.maxBy(objects, 'n');
* // => { 'n': 2 } * // => { 'n': 2 }
*/ */

View File

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

View File

@@ -7,6 +7,8 @@ define(['./_baseMerge', './_createAssigner'], function(baseMerge, createAssigner
* method instead. The `customizer` is invoked with seven arguments: * method instead. The `customizer` is invoked with seven arguments:
* (objValue, srcValue, key, object, source, stack). * (objValue, srcValue, key, object, source, stack).
* *
* **Note:** This method mutates `object`.
*
* @static * @static
* @memberOf _ * @memberOf _
* @category Object * @category Object

View File

@@ -21,7 +21,7 @@ define(['./_baseExtremum', './_baseIteratee', './lt'], function(baseExtremum, ba
* _.minBy(objects, function(o) { return o.n; }); * _.minBy(objects, function(o) { return o.n; });
* // => { 'n': 1 } * // => { 'n': 1 }
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.minBy(objects, 'n'); * _.minBy(objects, 'n');
* // => { 'n': 1 } * // => { 'n': 1 }
*/ */

View File

@@ -26,7 +26,7 @@ define(['./_baseOrderBy', './isArray'], function(baseOrderBy, isArray) {
* { 'user': 'barney', 'age': 36 } * { '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']); * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
* // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]
*/ */

View File

@@ -1,6 +1,6 @@
{ {
"name": "lodash-amd", "name": "lodash-amd",
"version": "4.1.0", "version": "4.3.0",
"description": "Lodash exported as AMD modules.", "description": "Lodash exported as AMD modules.",
"homepage": "https://lodash.com/custom-builds", "homepage": "https://lodash.com/custom-builds",
"license": "MIT", "license": "MIT",

View File

@@ -33,15 +33,20 @@ define(['./_createWrapper', './_replaceHolders', './rest'], function(createWrapp
* sayHelloTo('fred'); * sayHelloTo('fred');
* // => 'hello fred' * // => 'hello fred'
* *
* // using placeholders * // Partially applied with placeholders.
* var greetFred = _.partial(greet, _, 'fred'); * var greetFred = _.partial(greet, _, 'fred');
* greetFred('hi'); * greetFred('hi');
* // => 'hi fred' * // => 'hi fred'
*/ */
var partial = rest(function(func, partials) { var partial = rest(function(func, partials) {
var holders = replaceHolders(partials, partial.placeholder); var placeholder = partial.placeholder,
holders = replaceHolders(partials, placeholder);
return createWrapper(func, PARTIAL_FLAG, undefined, partials, holders); return createWrapper(func, PARTIAL_FLAG, undefined, partials, holders);
}); });
// Assign default placeholders.
partial.placeholder = {};
return partial; return partial;
}); });

View File

@@ -32,15 +32,20 @@ define(['./_createWrapper', './_replaceHolders', './rest'], function(createWrapp
* greetFred('hi'); * greetFred('hi');
* // => 'hi fred' * // => 'hi fred'
* *
* // using placeholders * // Partially applied with placeholders.
* var sayHelloTo = _.partialRight(greet, 'hello', _); * var sayHelloTo = _.partialRight(greet, 'hello', _);
* sayHelloTo('fred'); * sayHelloTo('fred');
* // => 'hello fred' * // => 'hello fred'
*/ */
var partialRight = rest(function(func, partials) { var partialRight = rest(function(func, partials) {
var holders = replaceHolders(partials, partialRight.placeholder); var placeholder = partialRight.placeholder,
holders = replaceHolders(partials, placeholder);
return createWrapper(func, PARTIAL_RIGHT_FLAG, undefined, partials, holders); return createWrapper(func, PARTIAL_RIGHT_FLAG, undefined, partials, holders);
}); });
// Assign default placeholders.
partialRight.placeholder = {};
return partialRight; return partialRight;
}); });

View File

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

View File

@@ -2,7 +2,7 @@ define(['./_baseIteratee', './_basePickBy'], function(baseIteratee, basePickBy)
/** /**
* Creates an object composed of the `object` properties `predicate` returns * 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 * @static
* @memberOf _ * @memberOf _

View File

@@ -1,7 +1,7 @@
define(['./pullAll', './rest'], function(pullAll, rest) { define(['./pullAll', './rest'], function(pullAll, rest) {
/** /**
* Removes all provided values from `array` using * Removes all given values from `array` using
* [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* for equality comparisons. * for equality comparisons.
* *

View File

@@ -2,7 +2,7 @@ define(['./_baseIteratee', './_basePullAllBy'], function(baseIteratee, basePullA
/** /**
* This method is like `_.pullAll` except that it accepts `iteratee` which is * This method is like `_.pullAll` except that it accepts `iteratee` which is
* invoked for each element of `array` and `values` to to generate the criterion * invoked for each element of `array` and `values` to generate the criterion
* by which uniqueness is computed. The iteratee is invoked with one argument: (value). * by which uniqueness is computed. The iteratee is invoked with one argument: (value).
* *
* **Note:** Unlike `_.differenceBy`, this method mutates `array`. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.

View File

@@ -4,7 +4,7 @@ define(['./_arrayReduce', './_baseEach', './_baseIteratee', './_baseReduce', './
* 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).
* *

View File

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

2
set.js
View File

@@ -6,6 +6,8 @@ define(['./_baseSet'], function(baseSet) {
* are created for all other missing properties. Use `_.setWith` to customize * are created for all other missing properties. Use `_.setWith` to customize
* `path` creation. * `path` creation.
* *
* **Note:** This method mutates `object`.
*
* @static * @static
* @memberOf _ * @memberOf _
* @category Object * @category Object

View File

@@ -9,6 +9,8 @@ define(['./_baseSet'], function(baseSet) {
* path creation is handled by the method instead. The `customizer` is invoked * path creation is handled by the method instead. The `customizer` is invoked
* with three arguments: (nsValue, key, nsObject). * with three arguments: (nsValue, key, nsObject).
* *
* **Note:** This method mutates `object`.
*
* @static * @static
* @memberOf _ * @memberOf _
* @category Object * @category Object

View File

@@ -25,15 +25,15 @@ define(['./_arraySome', './_baseIteratee', './_baseSome', './isArray', './_isIte
* { '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
*/ */

View File

@@ -19,7 +19,7 @@ define(['./_baseIteratee', './_baseSortedIndexBy'], function(baseIteratee, baseS
* _.sortedIndexBy(['thirty', 'fifty'], 'forty', _.propertyOf(dict)); * _.sortedIndexBy(['thirty', 'fifty'], 'forty', _.propertyOf(dict));
* // => 1 * // => 1
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.sortedIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x'); * _.sortedIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x');
* // => 0 * // => 0
*/ */

View File

@@ -14,7 +14,7 @@ define(['./_baseIteratee', './_baseSortedIndexBy'], function(baseIteratee, baseS
* @returns {number} Returns the index at which `value` should be inserted into `array`. * @returns {number} Returns the index at which `value` should be inserted into `array`.
* @example * @example
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.sortedLastIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x'); * _.sortedLastIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x');
* // => 1 * // => 1
*/ */

View File

@@ -13,7 +13,7 @@ define(['./_baseIteratee', './_baseSortedUniqBy'], function(baseIteratee, baseSo
* @example * @example
* *
* _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
* // => [1.1, 2.2] * // => [1.1, 2.3]
*/ */
function sortedUniqBy(array, iteratee) { function sortedUniqBy(array, iteratee) {
return (array && array.length) return (array && array.length)

View File

@@ -1,8 +1,14 @@
define(['./_apply'], function(apply) { define(['./_apply', './_arrayPush', './rest', './toInteger'], function(apply, arrayPush, rest, toInteger) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used as the `TypeError` message for "Functions" methods. */ /** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function'; var FUNC_ERROR_TEXT = 'Expected a function';
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max;
/** /**
* Creates a function that invokes `func` with the `this` binding of the created * Creates a function that invokes `func` with the `this` binding of the created
* function and an array of arguments much like [`Function#apply`](https://es5.github.io/#x15.3.4.3). * function and an array of arguments much like [`Function#apply`](https://es5.github.io/#x15.3.4.3).
@@ -13,6 +19,7 @@ define(['./_apply'], function(apply) {
* @memberOf _ * @memberOf _
* @category Function * @category Function
* @param {Function} func The function to spread arguments over. * @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. * @returns {Function} Returns the new function.
* @example * @example
* *
@@ -23,7 +30,6 @@ define(['./_apply'], function(apply) {
* say(['fred', 'hello']); * say(['fred', 'hello']);
* // => 'fred says hello' * // => 'fred says hello'
* *
* // with a Promise
* var numbers = Promise.all([ * var numbers = Promise.all([
* Promise.resolve(40), * Promise.resolve(40),
* Promise.resolve(36) * Promise.resolve(36)
@@ -34,13 +40,20 @@ define(['./_apply'], function(apply) {
* })); * }));
* // => a Promise of 76 * // => a Promise of 76
*/ */
function spread(func) { function spread(func, start) {
if (typeof func != 'function') { if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT); throw new TypeError(FUNC_ERROR_TEXT);
} }
return function(array) { start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
return apply(func, this, array); return rest(function(args) {
}; var array = args[start],
otherArgs = args.slice(0, start);
if (array) {
arrayPush(otherArgs, array);
}
return apply(func, this, otherArgs);
});
} }
return spread; return spread;

View File

@@ -19,6 +19,9 @@ define([], function() {
*/ */
function subtract(minuend, subtrahend) { function subtract(minuend, subtrahend) {
var result; var result;
if (minuend === undefined && subtrahend === undefined) {
return 0;
}
if (minuend !== undefined) { if (minuend !== undefined) {
result = minuend; result = minuend;
} }

View File

@@ -18,7 +18,7 @@ define(['./_baseIteratee', './_baseSum'], function(baseIteratee, baseSum) {
* _.sumBy(objects, function(o) { return o.n; }); * _.sumBy(objects, function(o) { return o.n; });
* // => 20 * // => 20
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.sumBy(objects, 'n'); * _.sumBy(objects, 'n');
* // => 20 * // => 20
*/ */

View File

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

View File

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

8
tap.js
View File

@@ -1,10 +1,9 @@
define([], function() { define([], function() {
/** /**
* 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 _
@@ -16,6 +15,7 @@ define([], function() {
* *
* _([1, 2, 3]) * _([1, 2, 3])
* .tap(function(array) { * .tap(function(array) {
* // Mutate input array.
* array.pop(); * array.pop();
* }) * })
* .reverse() * .reverse()

View File

@@ -22,7 +22,7 @@ define(['./_assignInDefaults', './assignInWith', './attempt', './_baseValues', '
* in "interpolate" delimiters, HTML-escape interpolated data properties in * in "interpolate" delimiters, HTML-escape interpolated data properties in
* "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
* properties may be accessed as free variables in the template. If a setting * properties may be accessed as free variables in the template. If a setting
* object is provided it takes precedence over `_.templateSettings` values. * object is given it takes precedence over `_.templateSettings` values.
* *
* **Note:** In the development build `_.template` utilizes * **Note:** In the development build `_.template` utilizes
* [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
@@ -49,54 +49,54 @@ define(['./_assignInDefaults', './assignInWith', './attempt', './_baseValues', '
* @returns {Function} Returns the compiled template function. * @returns {Function} Returns the compiled template function.
* @example * @example
* *
* // using the "interpolate" delimiter to create a compiled template * // Use the "interpolate" delimiter to create a compiled template.
* var compiled = _.template('hello <%= user %>!'); * var compiled = _.template('hello <%= user %>!');
* compiled({ 'user': 'fred' }); * compiled({ 'user': 'fred' });
* // => 'hello 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>'); * var compiled = _.template('<b><%- value %></b>');
* compiled({ 'value': '<script>' }); * compiled({ 'value': '<script>' });
* // => '<b>&lt;script&gt;</b>' * // => '<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><% }); %>'); * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
* compiled({ 'users': ['fred', 'barney'] }); * compiled({ 'users': ['fred', 'barney'] });
* // => '<li>fred</li><li>barney</li>' * // => '<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); %>!'); * var compiled = _.template('<% print("hello " + user); %>!');
* compiled({ 'user': 'barney' }); * compiled({ 'user': 'barney' });
* // => 'hello 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 }!'); * var compiled = _.template('hello ${ user }!');
* compiled({ 'user': 'pebbles' }); * compiled({ 'user': 'pebbles' });
* // => 'hello pebbles!' * // => 'hello pebbles!'
* *
* // using custom template delimiters * // Use custom template delimiters.
* _.templateSettings.interpolate = /{{([\s\S]+?)}}/g; * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
* var compiled = _.template('hello {{ user }}!'); * var compiled = _.template('hello {{ user }}!');
* compiled({ 'user': 'mustache' }); * compiled({ 'user': 'mustache' });
* // => 'hello mustache!' * // => 'hello mustache!'
* *
* // using backslashes to treat delimiters as plain text * // Use backslashes to treat delimiters as plain text.
* var compiled = _.template('<%= "\\<%- value %\\>" %>'); * var compiled = _.template('<%= "\\<%- value %\\>" %>');
* compiled({ 'value': 'ignored' }); * compiled({ 'value': 'ignored' });
* // => '<%- value %>' * // => '<%- 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 text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
* var compiled = _.template(text, { 'imports': { 'jq': jQuery } }); * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
* compiled({ 'users': ['fred', 'barney'] }); * compiled({ 'users': ['fred', 'barney'] });
* // => '<li>fred</li><li>barney</li>' * // => '<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' }); * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
* compiled(data); * compiled(data);
* // => find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector * // => 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' }); * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
* compiled.source; * compiled.source;
* // => function(data) { * // => function(data) {
@@ -105,8 +105,8 @@ define(['./_assignInDefaults', './assignInWith', './attempt', './_baseValues', '
* // return __p; * // return __p;
* // } * // }
* *
* // using the `source` property to inline compiled templates for meaningful * // Use the `source` property to inline compiled templates for meaningful
* // line numbers in error messages and a stack trace * // line numbers in error messages and stack traces.
* fs.writeFileSync(path.join(cwd, 'jst.js'), '\ * fs.writeFileSync(path.join(cwd, 'jst.js'), '\
* var JST = {\ * var JST = {\
* "main": ' + _.template(mainText).source + '\ * "main": ' + _.template(mainText).source + '\

View File

@@ -14,7 +14,7 @@ define(['./debounce', './isObject'], function(debounce, isObject) {
* result of the last `func` invocation. * 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 throttled function is * on the trailing edge of the timeout only if the throttled 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)
@@ -33,14 +33,14 @@ define(['./debounce', './isObject'], function(debounce, isObject) {
* @returns {Function} Returns the new throttled function. * @returns {Function} Returns the new throttled function.
* @example * @example
* *
* // avoid excessively updating the position while scrolling * // Avoid excessively updating the position while scrolling.
* jQuery(window).on('scroll', _.throttle(updatePosition, 100)); * 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 }); * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
* jQuery(element).on('click', throttled); * jQuery(element).on('click', throttled);
* *
* // cancel a trailing throttled invocation * // Cancel the trailing throttled invocation.
* jQuery(window).on('popstate', throttled.cancel); * jQuery(window).on('popstate', throttled.cancel);
*/ */
function throttle(func, wait, options) { function throttle(func, wait, options) {

View File

@@ -2,6 +2,8 @@ define([], function() {
/** /**
* 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 _

View File

@@ -1,8 +1,8 @@
define(['./_baseFlatten', './_baseUniq', './rest'], function(baseFlatten, baseUniq, rest) { define(['./_baseFlatten', './_baseUniq', './rest'], function(baseFlatten, baseUniq, rest) {
/** /**
* Creates an array of unique values, in order, from all of the provided arrays * Creates an array of unique values, in order, from all given arrays using
* using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* for equality comparisons. * for equality comparisons.
* *
* @static * @static

View File

@@ -19,7 +19,7 @@ define(['./_baseFlatten', './_baseIteratee', './_baseUniq', './isArrayLikeObject
* _.unionBy([2.1, 1.2], [4.3, 2.4], Math.floor); * _.unionBy([2.1, 1.2], [4.3, 2.4], Math.floor);
* // => [2.1, 1.2, 4.3] * // => [2.1, 1.2, 4.3]
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 1 }, { 'x': 2 }] * // => [{ 'x': 1 }, { 'x': 2 }]
*/ */

View File

@@ -16,7 +16,7 @@ define(['./_baseIteratee', './_baseUniq'], function(baseIteratee, baseUniq) {
* _.uniqBy([2.1, 1.2, 2.3], Math.floor); * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
* // => [2.1, 1.2] * // => [2.1, 1.2]
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 1 }, { 'x': 2 }] * // => [{ 'x': 1 }, { 'x': 2 }]
*/ */

View File

@@ -4,7 +4,7 @@ define(['./toString'], function(toString) {
var idCounter = 0; var idCounter = 0;
/** /**
* 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

@@ -3,6 +3,8 @@ define(['./_baseUnset'], function(baseUnset) {
/** /**
* Removes the property at `path` of `object`. * Removes the property at `path` of `object`.
* *
* **Note:** This method mutates `object`.
*
* @static * @static
* @memberOf _ * @memberOf _
* @category Object * @category Object

View File

@@ -1,7 +1,7 @@
define(['./_baseDifference', './isArrayLikeObject', './rest'], function(baseDifference, isArrayLikeObject, rest) { define(['./_baseDifference', './isArrayLikeObject', './rest'], function(baseDifference, isArrayLikeObject, rest) {
/** /**
* Creates an array excluding all provided values using * Creates an array excluding all given values using
* [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* for equality comparisons. * for equality comparisons.
* *

View File

@@ -14,11 +14,11 @@ define(['./chain'], function(chain) {
* { '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()

View File

@@ -104,11 +104,11 @@ define(['./_LazyWrapper', './_LodashWrapper', './_baseLodash', './isArray', './i
* *
* 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);

2
xor.js
View File

@@ -2,7 +2,7 @@ define(['./_arrayFilter', './_baseXor', './isArrayLikeObject', './rest'], functi
/** /**
* Creates an array of unique values that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) * Creates an array of unique values that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
* of the provided arrays. * of the given arrays.
* *
* @static * @static
* @memberOf _ * @memberOf _

View File

@@ -19,7 +19,7 @@ define(['./_arrayFilter', './_baseIteratee', './_baseXor', './isArrayLikeObject'
* _.xorBy([2.1, 1.2], [4.3, 2.4], Math.floor); * _.xorBy([2.1, 1.2], [4.3, 2.4], Math.floor);
* // => [1.2, 4.3] * // => [1.2, 4.3]
* *
* // using the `_.property` iteratee shorthand * // The `_.property` iteratee shorthand.
* _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 2 }] * // => [{ 'x': 2 }]
*/ */