Compare commits

..

2 Commits

Author SHA1 Message Date
John-David Dalton
63d9a3fc42 Bump to v4.11.0. 2016-04-13 10:19:22 -07:00
John-David Dalton
76b289fe6e Bump to v4.10.0. 2016-04-10 22:53:08 -07:00
68 changed files with 551 additions and 410 deletions

View File

@@ -1,4 +1,4 @@
# lodash-amd v4.9.0
# lodash-amd v4.11.0
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.9.0-amd) for more details.
See the [package source](https://github.com/lodash/lodash/tree/4.11.0-amd) for more details.

View File

@@ -2,7 +2,7 @@ define(['./_createBaseFor'], function(createBaseFor) {
/**
* The base implementation of `baseForOwn` which iterates over `object`
* properties returned by `keysFunc` invoking `iteratee` for each property.
* properties returned by `keysFunc` and invokes `iteratee` for each property.
* Iteratee functions may exit iteration early by explicitly returning `false`.
*
* @private

View File

@@ -1,4 +1,4 @@
define(['./_baseCastPath', './_isKey'], function(baseCastPath, isKey) {
define(['./_castPath', './_isKey'], function(castPath, isKey) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -12,7 +12,7 @@ define(['./_baseCastPath', './_isKey'], function(baseCastPath, isKey) {
* @returns {*} Returns the resolved value.
*/
function baseGet(object, path) {
path = isKey(path, object) ? [path] : baseCastPath(path);
path = isKey(path, object) ? [path] : castPath(path);
var index = 0,
length = path.length;

View File

@@ -1,4 +1,4 @@
define(['./_apply', './_baseCastPath', './_isKey', './last', './_parent'], function(apply, baseCastPath, isKey, last, parent) {
define(['./_apply', './_castPath', './_isKey', './last', './_parent'], function(apply, castPath, isKey, last, parent) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -15,7 +15,7 @@ define(['./_apply', './_baseCastPath', './_isKey', './last', './_parent'], funct
*/
function baseInvoke(object, path, args) {
if (!isKey(path, object)) {
path = baseCastPath(path);
path = castPath(path);
object = parent(object, path);
path = last(path);
}

24
_baseNth.js Normal file
View File

@@ -0,0 +1,24 @@
define(['./_isIndex'], function(isIndex) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* The base implementation of `_.nth` which doesn't coerce `n` to an integer.
*
* @private
* @param {Array} array The array to query.
* @param {number} n The index of the element to return.
* @returns {*} Returns the nth element of `array`.
*/
function baseNth(array, n) {
var length = array.length;
if (!length) {
return;
}
n += n < 0 ? length : 0;
return isIndex(n, length) ? array[n] : undefined;
}
return baseNth;
});

View File

@@ -1,4 +1,4 @@
define(['./_arrayMap', './_baseIteratee', './_baseMap', './_baseSortBy', './_compareMultiple', './identity'], function(arrayMap, baseIteratee, baseMap, baseSortBy, compareMultiple, identity) {
define(['./_arrayMap', './_baseIteratee', './_baseMap', './_baseSortBy', './_baseUnary', './_compareMultiple', './identity'], function(arrayMap, baseIteratee, baseMap, baseSortBy, baseUnary, compareMultiple, identity) {
/**
* The base implementation of `_.orderBy` without param guards.
@@ -11,7 +11,7 @@ define(['./_arrayMap', './_baseIteratee', './_baseMap', './_baseSortBy', './_com
*/
function baseOrderBy(collection, iteratees, orders) {
var index = -1;
iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseIteratee);
iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(baseIteratee));
var result = baseMap(collection, function(value, key, collection) {
var criteria = arrayMap(iteratees, function(iteratee) {

View File

@@ -1,4 +1,4 @@
define(['./_baseCastPath', './_isIndex', './_isKey', './last', './_parent'], function(baseCastPath, isIndex, isKey, last, parent) {
define(['./_castPath', './_isIndex', './_isKey', './last', './_parent'], function(castPath, isIndex, isKey, last, parent) {
/** Used for built-in method references. */
var arrayProto = Array.prototype;
@@ -27,7 +27,7 @@ define(['./_baseCastPath', './_isIndex', './_isKey', './last', './_parent'], fun
splice.call(array, index, 1);
}
else if (!isKey(index, array)) {
var path = baseCastPath(index),
var path = castPath(index),
object = parent(array, path);
if (object != null) {

View File

@@ -1,4 +1,4 @@
define(['./_assignValue', './_baseCastPath', './_isIndex', './_isKey', './isObject'], function(assignValue, baseCastPath, isIndex, isKey, isObject) {
define(['./_assignValue', './_castPath', './_isIndex', './_isKey', './isObject'], function(assignValue, castPath, isIndex, isKey, isObject) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -14,7 +14,7 @@ define(['./_assignValue', './_baseCastPath', './_isIndex', './_isKey', './isObje
* @returns {Object} Returns `object`.
*/
function baseSet(object, path, value, customizer) {
path = isKey(path, object) ? [path] : baseCastPath(path);
path = isKey(path, object) ? [path] : castPath(path);
var index = -1,
length = path.length,

View File

@@ -1,4 +1,4 @@
define(['./_baseCastPath', './has', './_isKey', './last', './_parent'], function(baseCastPath, has, isKey, last, parent) {
define(['./_castPath', './has', './_isKey', './last', './_parent'], function(castPath, has, isKey, last, parent) {
/**
* The base implementation of `_.unset`.
@@ -9,7 +9,7 @@ define(['./_baseCastPath', './has', './_isKey', './last', './_parent'], function
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
*/
function baseUnset(object, path) {
path = isKey(path, object) ? [path] : baseCastPath(path);
path = isKey(path, object) ? [path] : castPath(path);
object = parent(object, path);
var key = last(path);
return (object != null && has(object, key)) ? delete object[key] : true;

View File

@@ -7,9 +7,9 @@ define(['./isArrayLikeObject'], function(isArrayLikeObject) {
* @param {*} value The value to inspect.
* @returns {Array|Object} Returns the cast array-like object.
*/
function baseCastArrayLikeObject(value) {
function castArrayLikeObject(value) {
return isArrayLikeObject(value) ? value : [];
}
return baseCastArrayLikeObject;
return castArrayLikeObject;
});

View File

@@ -7,9 +7,9 @@ define(['./identity'], function(identity) {
* @param {*} value The value to inspect.
* @returns {Function} Returns cast function.
*/
function baseCastFunction(value) {
function castFunction(value) {
return typeof value == 'function' ? value : identity;
}
return baseCastFunction;
return castFunction;
});

View File

@@ -7,9 +7,9 @@ define(['./isArray', './_stringToPath'], function(isArray, stringToPath) {
* @param {*} value The value to inspect.
* @returns {Array} Returns the cast property path array.
*/
function baseCastPath(value) {
function castPath(value) {
return isArray(value) ? value : stringToPath(value);
}
return baseCastPath;
return castPath;
});

22
_castSlice.js Normal file
View File

@@ -0,0 +1,22 @@
define(['./_baseSlice'], function(baseSlice) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* Casts `array` to a slice if it's needed.
*
* @private
* @param {Array} array The array to inspect.
* @param {number} start The start position.
* @param {number} [end=array.length] The end position.
* @returns {Array} Returns the cast slice.
*/
function castSlice(array, start, end) {
var length = array.length;
end = end === undefined ? length : end;
return (!start && end >= length) ? array : baseSlice(array, start, end);
}
return castSlice;
});

View File

@@ -1,4 +1,4 @@
define(['./_copyObjectWith'], function(copyObjectWith) {
define(['./_assignValue'], function(assignValue) {
/**
* Copies properties of `source` to `object`.
@@ -7,10 +7,25 @@ define(['./_copyObjectWith'], function(copyObjectWith) {
* @param {Object} source The object to copy properties from.
* @param {Array} props The property identifiers to copy.
* @param {Object} [object={}] The object to copy properties to.
* @param {Function} [customizer] The function to customize copied values.
* @returns {Object} Returns `object`.
*/
function copyObject(source, props, object) {
return copyObjectWith(source, props, object);
function copyObject(source, props, object, customizer) {
object || (object = {});
var index = -1,
length = props.length;
while (++index < length) {
var key = props[index];
var newValue = customizer
? customizer(object[key], source[key], key, object, source)
: source[key];
assignValue(object, key, newValue);
}
return object;
}
return copyObject;

View File

@@ -1,33 +0,0 @@
define(['./_assignValue'], function(assignValue) {
/**
* This function is like `copyObject` except that it accepts a function to
* customize copied values.
*
* @private
* @param {Object} source The object to copy properties from.
* @param {Array} props The property identifiers to copy.
* @param {Object} [object={}] The object to copy properties to.
* @param {Function} [customizer] The function to customize copied values.
* @returns {Object} Returns `object`.
*/
function copyObjectWith(source, props, object, customizer) {
object || (object = {});
var index = -1,
length = props.length;
while (++index < length) {
var key = props[index];
var newValue = customizer
? customizer(object[key], source[key], key, object, source)
: source[key];
assignValue(object, key, newValue);
}
return object;
}
return copyObjectWith;
});

View File

@@ -1,20 +1,8 @@
define(['./_stringToArray', './toString'], function(stringToArray, toString) {
define(['./_castSlice', './_reHasComplexSymbol', './_stringToArray', './toString'], function(castSlice, reHasComplexSymbol, stringToArray, toString) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboSymbolsRange = '\\u20d0-\\u20f0',
rsVarRange = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsZWJ = '\\u200d';
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
/**
* Creates a function like `_.lowerFirst`.
*
@@ -30,8 +18,13 @@ define(['./_stringToArray', './toString'], function(stringToArray, toString) {
? stringToArray(string)
: undefined;
var chr = strSymbols ? strSymbols[0] : string.charAt(0),
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
var chr = strSymbols
? strSymbols[0]
: string.charAt(0);
var trailing = strSymbols
? castSlice(strSymbols, 1).join('')
: string.slice(1);
return chr[methodName]() + trailing;
};

View File

@@ -1,5 +1,11 @@
define(['./_arrayReduce', './deburr', './words'], function(arrayReduce, deburr, words) {
/** Used to compose unicode capture groups. */
var rsApos = "['\u2019]";
/** Used to match apostrophes. */
var reApos = RegExp(rsApos, 'g');
/**
* Creates a function like `_.camelCase`.
*
@@ -9,7 +15,7 @@ define(['./_arrayReduce', './deburr', './words'], function(arrayReduce, deburr,
*/
function createCompounder(callback) {
return function(string) {
return arrayReduce(words(deburr(string)), callback, '');
return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
};
}

View File

@@ -1,4 +1,4 @@
define(['./_apply', './_arrayMap', './_baseFlatten', './_baseIteratee', './_isFlattenableIteratee', './rest'], function(apply, arrayMap, baseFlatten, baseIteratee, isFlattenableIteratee, rest) {
define(['./_apply', './_arrayMap', './_baseFlatten', './_baseIteratee', './_baseUnary', './isArray', './_isFlattenableIteratee', './rest'], function(apply, arrayMap, baseFlatten, baseIteratee, baseUnary, isArray, isFlattenableIteratee, rest) {
/**
* Creates a function like `_.over`.
@@ -9,7 +9,10 @@ define(['./_apply', './_arrayMap', './_baseFlatten', './_baseIteratee', './_isFl
*/
function createOver(arrayFunc) {
return rest(function(iteratees) {
iteratees = arrayMap(baseFlatten(iteratees, 1, isFlattenableIteratee), baseIteratee);
iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
? arrayMap(iteratees[0], baseUnary(baseIteratee))
: arrayMap(baseFlatten(iteratees, 1, isFlattenableIteratee), baseUnary(baseIteratee));
return rest(function(args) {
var thisArg = this;
return arrayFunc(iteratees, function(iteratee) {

View File

@@ -1,20 +1,8 @@
define(['./_baseRepeat', './_stringSize', './_stringToArray'], function(baseRepeat, stringSize, stringToArray) {
define(['./_baseRepeat', './_castSlice', './_reHasComplexSymbol', './_stringSize', './_stringToArray'], function(baseRepeat, castSlice, reHasComplexSymbol, stringSize, stringToArray) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboSymbolsRange = '\\u20d0-\\u20f0',
rsVarRange = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsZWJ = '\\u200d';
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeCeil = Math.ceil;
@@ -36,7 +24,7 @@ define(['./_baseRepeat', './_stringSize', './_stringToArray'], function(baseRepe
}
var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
return reHasComplexSymbol.test(chars)
? stringToArray(result).slice(0, length).join('')
? castSlice(stringToArray(result), 0, length).join('')
: result.slice(0, length);
}

View File

@@ -1,4 +1,4 @@
define(['./_copyArray', './_isLaziable', './_setData'], function(copyArray, isLaziable, setData) {
define(['./_isLaziable', './_setData'], function(isLaziable, setData) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -31,7 +31,6 @@ define(['./_copyArray', './_isLaziable', './_setData'], function(copyArray, isLa
*/
function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
var isCurry = bitmask & CURRY_FLAG,
newArgPos = argPos ? copyArray(argPos) : undefined,
newHolders = isCurry ? holders : undefined,
newHoldersRight = isCurry ? undefined : holders,
newPartials = isCurry ? partials : undefined,
@@ -45,7 +44,7 @@ define(['./_copyArray', './_isLaziable', './_setData'], function(copyArray, isLa
}
var newData = [
func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
newHoldersRight, newArgPos, ary, arity
newHoldersRight, argPos, ary, arity
];
var result = wrapFunc.apply(undefined, newData);

View File

@@ -1,4 +1,4 @@
define(['./_baseCastPath', './isArguments', './isArray', './_isIndex', './_isKey', './isLength', './isString'], function(baseCastPath, isArguments, isArray, isIndex, isKey, isLength, isString) {
define(['./_castPath', './isArguments', './isArray', './_isIndex', './_isKey', './isLength', './isString'], function(castPath, isArguments, isArray, isIndex, isKey, isLength, isString) {
/**
* Checks if `path` exists on `object`.
@@ -10,7 +10,7 @@ define(['./_baseCastPath', './isArguments', './isArray', './_isIndex', './_isKey
* @returns {boolean} Returns `true` if `path` exists, else `false`.
*/
function hasPath(object, path, hasFunc) {
path = isKey(path, object) ? [path] : baseCastPath(path);
path = isKey(path, object) ? [path] : castPath(path);
var result,
index = -1,

View File

@@ -1,4 +1,4 @@
define(['./_composeArgs', './_composeArgsRight', './_copyArray', './_replaceHolders'], function(composeArgs, composeArgsRight, copyArray, replaceHolders) {
define(['./_composeArgs', './_composeArgsRight', './_replaceHolders'], function(composeArgs, composeArgsRight, replaceHolders) {
/** Used as the internal argument placeholder. */
var PLACEHOLDER = '__lodash_placeholder__';
@@ -55,20 +55,20 @@ define(['./_composeArgs', './_composeArgsRight', './_copyArray', './_replaceHold
var value = source[3];
if (value) {
var partials = data[3];
data[3] = partials ? composeArgs(partials, value, source[4]) : copyArray(value);
data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : copyArray(source[4]);
data[3] = partials ? composeArgs(partials, value, source[4]) : value;
data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
}
// Compose partial right arguments.
value = source[5];
if (value) {
partials = data[5];
data[5] = partials ? composeArgsRight(partials, value, source[6]) : copyArray(value);
data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : copyArray(source[6]);
data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
}
// Use source `argPos` if available.
value = source[7];
if (value) {
data[7] = copyArray(value);
data[7] = value;
}
// Use source `ary` if it's smaller.
if (srcBitmask & ARY_FLAG) {

16
_reHasComplexSymbol.js Normal file
View File

@@ -0,0 +1,16 @@
define([], function() {
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboSymbolsRange = '\\u20d0-\\u20f0',
rsVarRange = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsZWJ = '\\u200d';
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
return reHasComplexSymbol;
});

View File

@@ -1,4 +1,4 @@
define([], function() {
define(['./_reHasComplexSymbol'], function(reHasComplexSymbol) {
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
@@ -26,9 +26,6 @@ define([], function() {
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
/**
* Gets the number of symbols in `string`.
*

View File

@@ -1,15 +1,15 @@
define(['./isSymbol'], function(isSymbol) {
/**
* Casts `value` to a string if it's not a string or symbol.
* Converts `value` to a string key if it's not a string or symbol.
*
* @private
* @param {*} value The value to inspect.
* @returns {string|symbol} Returns the cast key.
* @returns {string|symbol} Returns the key.
*/
function baseCastKey(key) {
function toKey(key) {
return (typeof key == 'string' || isSymbol(key)) ? key : (key + '');
}
return baseCastKey;
return toKey;
});

View File

@@ -1,4 +1,4 @@
define(['./chunk', './compact', './concat', './difference', './differenceBy', './differenceWith', './drop', './dropRight', './dropRightWhile', './dropWhile', './fill', './findIndex', './findLastIndex', './flatten', './flattenDeep', './flattenDepth', './fromPairs', './head', './indexOf', './initial', './intersection', './intersectionBy', './intersectionWith', './join', './last', './lastIndexOf', './pull', './pullAll', './pullAllBy', './pullAllWith', './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, flattenDepth, fromPairs, head, indexOf, initial, intersection, intersectionBy, intersectionWith, join, last, lastIndexOf, pull, pullAll, pullAllBy, pullAllWith, 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', './flattenDepth', './fromPairs', './head', './indexOf', './initial', './intersection', './intersectionBy', './intersectionWith', './join', './last', './lastIndexOf', './nth', './pull', './pullAll', './pullAllBy', './pullAllWith', './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, flattenDepth, fromPairs, head, indexOf, initial, intersection, intersectionBy, intersectionWith, join, last, lastIndexOf, nth, pull, pullAll, pullAllBy, pullAllWith, 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 {
'chunk': chunk,
'compact': compact,
@@ -26,6 +26,7 @@ define(['./chunk', './compact', './concat', './difference', './differenceBy', '.
'join': join,
'last': last,
'lastIndexOf': lastIndexOf,
'nth': nth,
'pull': pull,
'pullAll': pullAll,
'pullAllBy': pullAllBy,

View File

@@ -1,4 +1,4 @@
define(['./_copyObjectWith', './_createAssigner', './keysIn'], function(copyObjectWith, createAssigner, keysIn) {
define(['./_copyObject', './_createAssigner', './keysIn'], function(copyObject, createAssigner, keysIn) {
/**
* This method is like `_.assignIn` except that it accepts `customizer`
@@ -29,7 +29,7 @@ define(['./_copyObjectWith', './_createAssigner', './keysIn'], function(copyObje
* // => { 'a': 1, 'b': 2 }
*/
var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
copyObjectWith(source, keysIn(source), object, customizer);
copyObject(source, keysIn(source), object, customizer);
});
return assignInWith;

View File

@@ -1,4 +1,4 @@
define(['./_copyObjectWith', './_createAssigner', './keys'], function(copyObjectWith, createAssigner, keys) {
define(['./_copyObject', './_createAssigner', './keys'], function(copyObject, createAssigner, keys) {
/**
* This method is like `_.assign` except that it accepts `customizer`
@@ -28,7 +28,7 @@ define(['./_copyObjectWith', './_createAssigner', './keys'], function(copyObject
* // => { 'a': 1, 'b': 2 }
*/
var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
copyObjectWith(source, keys(source), object, customizer);
copyObject(source, keys(source), object, customizer);
});
return assignWith;

3
at.js
View File

@@ -8,8 +8,7 @@ define(['./_baseAt', './_baseFlatten', './rest'], function(baseAt, baseFlatten,
* @since 1.0.0
* @category Object
* @param {Object} object The object to iterate over.
* @param {...(string|string[])} [paths] The property paths of elements to pick,
* specified individually or in arrays.
* @param {...(string|string[])} [paths] The property paths of elements to pick.
* @returns {Array} Returns the new array of picked elements.
* @example
*

View File

@@ -11,8 +11,7 @@ define(['./_arrayEach', './_baseFlatten', './bind', './rest'], function(arrayEac
* @memberOf _
* @category Util
* @param {Object} object The object to bind and assign the bound methods to.
* @param {...(string|string[])} methodNames The object method names to bind,
* specified individually or in arrays.
* @param {...(string|string[])} methodNames The object method names to bind.
* @returns {Object} Returns `object`.
* @example
*

View File

@@ -4,7 +4,7 @@ define(['./_apply', './_arrayMap', './_baseIteratee', './rest'], function(apply,
var FUNC_ERROR_TEXT = 'Expected a function';
/**
* Creates a function that iterates over `pairs` invoking the corresponding
* Creates a function that iterates over `pairs` and invokes the corresponding
* function of the first predicate to return truthy. The predicate-function
* pairs are invoked with the `this` binding and arguments of the created
* function.

View File

@@ -170,6 +170,9 @@ define(['./isObject', './now', './toNumber'], function(isObject, now, toNumber)
timerId = setTimeout(timerExpired, wait);
return invokeFunc(lastCallTime);
}
if (timerId === undefined) {
timerId = setTimeout(timerExpired, wait);
}
return result;
}
debounced.cancel = cancel;

View File

@@ -1,7 +1,7 @@
define(['./_arrayEach', './_baseEach', './_baseIteratee', './isArray'], function(arrayEach, baseEach, baseIteratee, isArray) {
/**
* Iterates over elements of `collection` invoking `iteratee` for each element.
* Iterates over elements of `collection` and invokes `iteratee` for each element.
* The iteratee is invoked with three arguments: (value, index|key, collection).
* Iteratee functions may exit iteration early by explicitly returning `false`.
*

View File

@@ -2,9 +2,9 @@ define(['./_baseFor', './_baseIteratee', './keysIn'], function(baseFor, baseIter
/**
* Iterates over own and inherited enumerable string keyed properties of an
* object invoking `iteratee` for each property. The iteratee is invoked with
* three arguments: (value, key, object). Iteratee functions may exit iteration
* early by explicitly returning `false`.
* object and invokes `iteratee` for each property. The iteratee is invoked
* with three arguments: (value, key, object). Iteratee functions may exit
* iteration early by explicitly returning `false`.
*
* @static
* @memberOf _

View File

@@ -1,10 +1,10 @@
define(['./_baseForOwn', './_baseIteratee'], function(baseForOwn, baseIteratee) {
/**
* Iterates over own enumerable string keyed properties of an object invoking
* `iteratee` for each property. The iteratee is invoked with three arguments:
* (value, key, object). Iteratee functions may exit iteration early by
* explicitly returning `false`.
* Iterates over own enumerable string keyed properties of an object and
* invokes `iteratee` for each property. The iteratee is invoked with three
* arguments: (value, key, object). Iteratee functions may exit iteration
* early by explicitly returning `false`.
*
* @static
* @memberOf _

View File

@@ -22,7 +22,7 @@ define([], function() {
* // => undefined
*/
function head(array) {
return array ? array[0] : undefined;
return (array && array.length) ? array[0] : undefined;
}
return head;

View File

@@ -1,4 +1,4 @@
define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './rest'], function(arrayMap, baseCastArrayLikeObject, baseIntersection, rest) {
define(['./_arrayMap', './_baseIntersection', './_castArrayLikeObject', './rest'], function(arrayMap, baseIntersection, castArrayLikeObject, rest) {
/**
* Creates an array of unique values that are included in all given arrays
@@ -18,7 +18,7 @@ define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './r
* // => [2]
*/
var intersection = rest(function(arrays) {
var mapped = arrayMap(arrays, baseCastArrayLikeObject);
var mapped = arrayMap(arrays, castArrayLikeObject);
return (mapped.length && mapped[0] === arrays[0])
? baseIntersection(mapped)
: [];

View File

@@ -1,4 +1,4 @@
define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './_baseIteratee', './last', './rest'], function(arrayMap, baseCastArrayLikeObject, baseIntersection, baseIteratee, last, rest) {
define(['./_arrayMap', './_baseIntersection', './_baseIteratee', './_castArrayLikeObject', './last', './rest'], function(arrayMap, baseIntersection, baseIteratee, castArrayLikeObject, last, rest) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -28,7 +28,7 @@ define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './_
*/
var intersectionBy = rest(function(arrays) {
var iteratee = last(arrays),
mapped = arrayMap(arrays, baseCastArrayLikeObject);
mapped = arrayMap(arrays, castArrayLikeObject);
if (iteratee === last(mapped)) {
iteratee = undefined;

View File

@@ -1,4 +1,4 @@
define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './last', './rest'], function(arrayMap, baseCastArrayLikeObject, baseIntersection, last, rest) {
define(['./_arrayMap', './_baseIntersection', './_castArrayLikeObject', './last', './rest'], function(arrayMap, baseIntersection, castArrayLikeObject, last, rest) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -26,7 +26,7 @@ define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './l
*/
var intersectionWith = rest(function(arrays) {
var comparator = last(arrays),
mapped = arrayMap(arrays, baseCastArrayLikeObject);
mapped = arrayMap(arrays, castArrayLikeObject);
if (comparator === last(mapped)) {
comparator = undefined;

418
main.js
View File

@@ -1,6 +1,6 @@
/**
* @license
* lodash 4.9.0 (Custom Build) <https://lodash.com/>
* lodash 4.11.0 (Custom Build) <https://lodash.com/>
* Build: `lodash exports="amd" -d -o ./main.js`
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
* Released under MIT license <https://lodash.com/license>
@@ -13,7 +13,7 @@
var undefined;
/** Used as the semantic version number. */
var VERSION = '4.9.0';
var VERSION = '4.11.0';
/** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200;
@@ -131,6 +131,9 @@
reTrimStart = /^\s+/,
reTrimEnd = /\s+$/;
/** Used to match non-compound words composed of alphanumeric characters. */
var reBasicWord = /[a-zA-Z0-9]+/g;
/** Used to match backslashes in property paths. */
var reEscapeChar = /\\(\\)?/g;
@@ -185,7 +188,8 @@
rsBreakRange = rsMathOpRange + rsNonCharRange + rsQuoteRange + rsSpaceRange;
/** Used to compose unicode capture groups. */
var rsAstral = '[' + rsAstralRange + ']',
var rsApos = "['\u2019]",
rsAstral = '[' + rsAstralRange + ']',
rsBreak = '[' + rsBreakRange + ']',
rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
rsDigits = '\\d+',
@@ -203,6 +207,8 @@
/** Used to compose unicode regexes. */
var rsLowerMisc = '(?:' + rsLower + '|' + rsMisc + ')',
rsUpperMisc = '(?:' + rsUpper + '|' + rsMisc + ')',
rsOptLowerContr = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
rsOptUpperContr = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
reOptMod = rsModifier + '?',
rsOptVar = '[' + rsVarRange + ']?',
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
@@ -210,6 +216,9 @@
rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
/** Used to match apostrophes. */
var reApos = RegExp(rsApos, 'g');
/**
* Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
* [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
@@ -219,22 +228,19 @@
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
/** Used to match non-compound words composed of alphanumeric characters. */
var reBasicWord = /[a-zA-Z0-9]+/g;
/** Used to match complex or compound words. */
var reComplexWord = RegExp([
rsUpper + '?' + rsLower + '+(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
rsUpperMisc + '+(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')',
rsUpper + '?' + rsLowerMisc + '+',
rsUpper + '+',
rsUpper + '?' + rsLower + '+' + rsOptLowerContr + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
rsUpperMisc + '+' + rsOptUpperContr + '(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')',
rsUpper + '?' + rsLowerMisc + '+' + rsOptLowerContr,
rsUpper + '+' + rsOptUpperContr,
rsDigits,
rsEmoji
].join('|'), 'g');
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
/** Used to detect strings that need a more robust regexp to match words. */
var reHasComplexWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
@@ -1382,7 +1388,8 @@
/** Used for built-in method references. */
var arrayProto = context.Array.prototype,
objectProto = context.Object.prototype;
objectProto = context.Object.prototype,
stringProto = context.String.prototype;
/** Used to resolve the decompiled source of functions. */
var funcToString = context.Function.prototype.toString;
@@ -1437,7 +1444,9 @@
nativeMin = Math.min,
nativeParseInt = context.parseInt,
nativeRandom = Math.random,
nativeReverse = arrayProto.reverse;
nativeReplace = stringProto.replace,
nativeReverse = arrayProto.reverse,
nativeSplit = stringProto.split;
/* Built-in method references that are verified to be native. */
var DataView = getNative(context, 'DataView'),
@@ -1550,7 +1559,7 @@
* `isSet`, `isString`, `isUndefined`, `isTypedArray`, `isWeakMap`, `isWeakSet`,
* `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`,
* `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, `min`, `minBy`, `multiply`,
* `noConflict`, `noop`, `now`, `pad`, `padEnd`, `padStart`, `parseInt`,
* `noConflict`, `noop`, `now`, `nth`, `pad`, `padEnd`, `padStart`, `parseInt`,
* `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`,
* `runInContext`, `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`,
* `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, `startCase`,
@@ -2357,50 +2366,6 @@
return result;
}
/**
* Casts `value` to an empty array if it's not an array like object.
*
* @private
* @param {*} value The value to inspect.
* @returns {Array|Object} Returns the cast array-like object.
*/
function baseCastArrayLikeObject(value) {
return isArrayLikeObject(value) ? value : [];
}
/**
* Casts `value` to `identity` if it's not a function.
*
* @private
* @param {*} value The value to inspect.
* @returns {Function} Returns cast function.
*/
function baseCastFunction(value) {
return typeof value == 'function' ? value : identity;
}
/**
* Casts `value` to a string if it's not a string or symbol.
*
* @private
* @param {*} value The value to inspect.
* @returns {string|symbol} Returns the cast key.
*/
function baseCastKey(key) {
return (typeof key == 'string' || isSymbol(key)) ? key : (key + '');
}
/**
* Casts `value` to a path array if it's not one.
*
* @private
* @param {*} value The value to inspect.
* @returns {Array} Returns the cast property path array.
*/
function baseCastPath(value) {
return isArray(value) ? value : stringToPath(value);
}
/**
* The base implementation of `_.clamp` which doesn't coerce arguments to numbers.
*
@@ -2731,7 +2696,7 @@
/**
* The base implementation of `baseForOwn` which iterates over `object`
* properties returned by `keysFunc` invoking `iteratee` for each property.
* properties returned by `keysFunc` and invokes `iteratee` for each property.
* Iteratee functions may exit iteration early by explicitly returning `false`.
*
* @private
@@ -2802,7 +2767,7 @@
* @returns {*} Returns the resolved value.
*/
function baseGet(object, path) {
path = isKey(path, object) ? [path] : baseCastPath(path);
path = isKey(path, object) ? [path] : castPath(path);
var index = 0,
length = path.length;
@@ -2964,7 +2929,7 @@
*/
function baseInvoke(object, path, args) {
if (!isKey(path, object)) {
path = baseCastPath(path);
path = castPath(path);
object = parent(object, path);
path = last(path);
}
@@ -3335,6 +3300,23 @@
assignMergeValue(object, key, newValue);
}
/**
* The base implementation of `_.nth` which doesn't coerce `n` to an integer.
*
* @private
* @param {Array} array The array to query.
* @param {number} n The index of the element to return.
* @returns {*} Returns the nth element of `array`.
*/
function baseNth(array, n) {
var length = array.length;
if (!length) {
return;
}
n += n < 0 ? length : 0;
return isIndex(n, length) ? array[n] : undefined;
}
/**
* The base implementation of `_.orderBy` without param guards.
*
@@ -3346,7 +3328,7 @@
*/
function baseOrderBy(collection, iteratees, orders) {
var index = -1;
iteratees = arrayMap(iteratees.length ? iteratees : [identity], getIteratee());
iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
var result = baseMap(collection, function(value, key, collection) {
var criteria = arrayMap(iteratees, function(iteratee) {
@@ -3486,7 +3468,7 @@
splice.call(array, index, 1);
}
else if (!isKey(index, array)) {
var path = baseCastPath(index),
var path = castPath(index),
object = parent(array, path);
if (object != null) {
@@ -3576,7 +3558,7 @@
* @returns {Object} Returns `object`.
*/
function baseSet(object, path, value, customizer) {
path = isKey(path, object) ? [path] : baseCastPath(path);
path = isKey(path, object) ? [path] : castPath(path);
var index = -1,
length = path.length,
@@ -3855,7 +3837,7 @@
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
*/
function baseUnset(object, path) {
path = isKey(path, object) ? [path] : baseCastPath(path);
path = isKey(path, object) ? [path] : castPath(path);
object = parent(object, path);
var key = last(path);
return (object != null && has(object, key)) ? delete object[key] : true;
@@ -3965,6 +3947,54 @@
return result;
}
/**
* Casts `value` to an empty array if it's not an array like object.
*
* @private
* @param {*} value The value to inspect.
* @returns {Array|Object} Returns the cast array-like object.
*/
function castArrayLikeObject(value) {
return isArrayLikeObject(value) ? value : [];
}
/**
* Casts `value` to `identity` if it's not a function.
*
* @private
* @param {*} value The value to inspect.
* @returns {Function} Returns cast function.
*/
function castFunction(value) {
return typeof value == 'function' ? value : identity;
}
/**
* Casts `value` to a path array if it's not one.
*
* @private
* @param {*} value The value to inspect.
* @returns {Array} Returns the cast property path array.
*/
function castPath(value) {
return isArray(value) ? value : stringToPath(value);
}
/**
* Casts `array` to a slice if it's needed.
*
* @private
* @param {Array} array The array to inspect.
* @param {number} start The start position.
* @param {number} [end=array.length] The end position.
* @returns {Array} Returns the cast slice.
*/
function castSlice(array, start, end) {
var length = array.length;
end = end === undefined ? length : end;
return (!start && end >= length) ? array : baseSlice(array, start, end);
}
/**
* Creates a clone of `buffer`.
*
@@ -4171,24 +4201,10 @@
* @param {Object} source The object to copy properties from.
* @param {Array} props The property identifiers to copy.
* @param {Object} [object={}] The object to copy properties to.
* @returns {Object} Returns `object`.
*/
function copyObject(source, props, object) {
return copyObjectWith(source, props, object);
}
/**
* This function is like `copyObject` except that it accepts a function to
* customize copied values.
*
* @private
* @param {Object} source The object to copy properties from.
* @param {Array} props The property identifiers to copy.
* @param {Object} [object={}] The object to copy properties to.
* @param {Function} [customizer] The function to customize copied values.
* @returns {Object} Returns `object`.
*/
function copyObjectWith(source, props, object, customizer) {
function copyObject(source, props, object, customizer) {
object || (object = {});
var index = -1,
@@ -4358,8 +4374,13 @@
? stringToArray(string)
: undefined;
var chr = strSymbols ? strSymbols[0] : string.charAt(0),
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
var chr = strSymbols
? strSymbols[0]
: string.charAt(0);
var trailing = strSymbols
? castSlice(strSymbols, 1).join('')
: string.slice(1);
return chr[methodName]() + trailing;
};
@@ -4374,7 +4395,7 @@
*/
function createCompounder(callback) {
return function(string) {
return arrayReduce(words(deburr(string)), callback, '');
return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
};
}
@@ -4610,7 +4631,10 @@
*/
function createOver(arrayFunc) {
return rest(function(iteratees) {
iteratees = arrayMap(baseFlatten(iteratees, 1, isFlattenableIteratee), getIteratee());
iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
? arrayMap(iteratees[0], baseUnary(getIteratee()))
: arrayMap(baseFlatten(iteratees, 1, isFlattenableIteratee), baseUnary(getIteratee()));
return rest(function(args) {
var thisArg = this;
return arrayFunc(iteratees, function(iteratee) {
@@ -4638,7 +4662,7 @@
}
var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
return reHasComplexSymbol.test(chars)
? stringToArray(result).slice(0, length).join('')
? castSlice(stringToArray(result), 0, length).join('')
: result.slice(0, length);
}
@@ -4724,7 +4748,6 @@
*/
function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
var isCurry = bitmask & CURRY_FLAG,
newArgPos = argPos ? copyArray(argPos) : undefined,
newHolders = isCurry ? holders : undefined,
newHoldersRight = isCurry ? undefined : holders,
newPartials = isCurry ? partials : undefined,
@@ -4738,7 +4761,7 @@
}
var newData = [
func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
newHoldersRight, newArgPos, ary, arity
newHoldersRight, argPos, ary, arity
];
var result = wrapFunc.apply(undefined, newData);
@@ -5346,7 +5369,7 @@
* @returns {boolean} Returns `true` if `path` exists, else `false`.
*/
function hasPath(object, path, hasFunc) {
path = isKey(path, object) ? [path] : baseCastPath(path);
path = isKey(path, object) ? [path] : castPath(path);
var result,
index = -1,
@@ -5651,20 +5674,20 @@
var value = source[3];
if (value) {
var partials = data[3];
data[3] = partials ? composeArgs(partials, value, source[4]) : copyArray(value);
data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : copyArray(source[4]);
data[3] = partials ? composeArgs(partials, value, source[4]) : value;
data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
}
// Compose partial right arguments.
value = source[5];
if (value) {
partials = data[5];
data[5] = partials ? composeArgsRight(partials, value, source[6]) : copyArray(value);
data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : copyArray(source[6]);
data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
}
// Use source `argPos` if available.
value = source[7];
if (value) {
data[7] = copyArray(value);
data[7] = value;
}
// Use source `ary` if it's smaller.
if (srcBitmask & ARY_FLAG) {
@@ -5784,6 +5807,17 @@
return result;
});
/**
* Converts `value` to a string key if it's not a string or symbol.
*
* @private
* @param {*} value The value to inspect.
* @returns {string|symbol} Returns the key.
*/
function toKey(key) {
return (typeof key == 'string' || isSymbol(key)) ? key : (key + '');
}
/**
* Converts `func` to its source code.
*
@@ -6408,7 +6442,7 @@
* // => undefined
*/
function head(array) {
return array ? array[0] : undefined;
return (array && array.length) ? array[0] : undefined;
}
/**
@@ -6482,7 +6516,7 @@
* // => [2]
*/
var intersection = rest(function(arrays) {
var mapped = arrayMap(arrays, baseCastArrayLikeObject);
var mapped = arrayMap(arrays, castArrayLikeObject);
return (mapped.length && mapped[0] === arrays[0])
? baseIntersection(mapped)
: [];
@@ -6513,7 +6547,7 @@
*/
var intersectionBy = rest(function(arrays) {
var iteratee = last(arrays),
mapped = arrayMap(arrays, baseCastArrayLikeObject);
mapped = arrayMap(arrays, castArrayLikeObject);
if (iteratee === last(mapped)) {
iteratee = undefined;
@@ -6548,7 +6582,7 @@
*/
var intersectionWith = rest(function(arrays) {
var comparator = last(arrays),
mapped = arrayMap(arrays, baseCastArrayLikeObject);
mapped = arrayMap(arrays, castArrayLikeObject);
if (comparator === last(mapped)) {
comparator = undefined;
@@ -6644,6 +6678,31 @@
return -1;
}
/**
* Gets the nth element of `array`. If `n` is negative, the nth element
* from the end is returned.
*
* @static
* @memberOf _
* @since 4.11.0
* @category Array
* @param {Array} array The array to query.
* @param {number} [n=0] The index of the element to return.
* @returns {*} Returns the nth element of `array`.
* @example
*
* var array = ['a', 'b', 'c', 'd'];
*
* _.nth(array, 1);
* // => 'b'
*
* _.nth(array, -2);
* // => 'c';
*/
function nth(array, n) {
return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
}
/**
* Removes all given values from `array` using
* [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
@@ -6765,8 +6824,7 @@
* @since 3.0.0
* @category Array
* @param {Array} array The array to modify.
* @param {...(number|number[])} [indexes] The indexes of elements to remove,
* specified individually or in arrays.
* @param {...(number|number[])} [indexes] The indexes of elements to remove.
* @returns {Array} Returns the new array of removed elements.
* @example
*
@@ -7774,8 +7832,7 @@
* @memberOf _
* @since 1.0.0
* @category Seq
* @param {...(string|string[])} [paths] The property paths of elements to pick,
* specified individually or in arrays.
* @param {...(string|string[])} [paths] The property paths of elements to pick.
* @returns {Object} Returns the new `lodash` wrapper instance.
* @example
*
@@ -8292,7 +8349,7 @@
}
/**
* Iterates over elements of `collection` invoking `iteratee` for each element.
* Iterates over elements of `collection` and invokes `iteratee` for each element.
* The iteratee is invoked with three arguments: (value, index|key, collection).
* Iteratee functions may exit iteration early by explicitly returning `false`.
*
@@ -8506,8 +8563,8 @@
* The guarded methods are:
* `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
* `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
* `sampleSize`, `slice`, `some`, `sortBy`, `take`, `takeRight`, `template`,
* `trim`, `trimEnd`, `trimStart`, and `words`
* `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
* `template`, `trim`, `trimEnd`, `trimStart`, and `words`
*
* @static
* @memberOf _
@@ -8917,8 +8974,7 @@
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
* [iteratees=[_.identity]] The iteratees to sort by, specified individually
* or in arrays.
* [iteratees=[_.identity]] The iteratees to sort by.
* @returns {Array} Returns the new sorted array.
* @example
*
@@ -8948,9 +9004,13 @@
if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
iteratees = [];
} else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
iteratees.length = 1;
iteratees = [iteratees[0]];
}
return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
? iteratees[0]
: baseFlatten(iteratees, 1, isFlattenableIteratee);
return baseOrderBy(collection, iteratees, []);
});
/*------------------------------------------------------------------------*/
@@ -9420,6 +9480,9 @@
timerId = setTimeout(timerExpired, wait);
return invokeFunc(lastCallTime);
}
if (timerId === undefined) {
timerId = setTimeout(timerExpired, wait);
}
return result;
}
debounced.cancel = cancel;
@@ -9621,8 +9684,8 @@
* @memberOf _
* @category Function
* @param {Function} func The function to wrap.
* @param {...(Function|Function[])} [transforms] The functions to transform.
* arguments, specified individually or in arrays.
* @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
* [transforms[_.identity]] The functions to transform.
* @returns {Function} Returns the new function.
* @example
*
@@ -9645,7 +9708,10 @@
* // => [100, 10]
*/
var overArgs = rest(function(func, transforms) {
transforms = arrayMap(baseFlatten(transforms, 1, isFlattenableIteratee), getIteratee());
transforms = (transforms.length == 1 && isArray(transforms[0]))
? arrayMap(transforms[0], baseUnary(getIteratee()))
: arrayMap(baseFlatten(transforms, 1, isFlattenableIteratee), baseUnary(getIteratee()));
var funcsLength = transforms.length;
return rest(function(args) {
var index = -1,
@@ -9744,8 +9810,7 @@
* @since 3.0.0
* @category Function
* @param {Function} func The function to rearrange arguments for.
* @param {...(number|number[])} indexes The arranged argument indexes,
* specified individually or in arrays.
* @param {...(number|number[])} indexes The arranged argument indexes.
* @returns {Function} Returns the new function.
* @example
*
@@ -9855,7 +9920,7 @@
start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
return rest(function(args) {
var array = args[start],
otherArgs = args.slice(0, start);
otherArgs = castSlice(args, 0, start);
if (array) {
arrayPush(otherArgs, array);
@@ -11503,8 +11568,8 @@
}
/**
* Converts `value` to a string if it's not one. An empty string is returned
* for `null` and `undefined` values. The sign of `-0` is preserved.
* Converts `value` to a string. An empty string is returned for `null`
* and `undefined` values. The sign of `-0` is preserved.
*
* @static
* @memberOf _
@@ -11652,7 +11717,7 @@
* // => { 'a': 1, 'b': 2 }
*/
var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
copyObjectWith(source, keysIn(source), object, customizer);
copyObject(source, keysIn(source), object, customizer);
});
/**
@@ -11683,7 +11748,7 @@
* // => { 'a': 1, 'b': 2 }
*/
var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
copyObjectWith(source, keys(source), object, customizer);
copyObject(source, keys(source), object, customizer);
});
/**
@@ -11694,8 +11759,7 @@
* @since 1.0.0
* @category Object
* @param {Object} object The object to iterate over.
* @param {...(string|string[])} [paths] The property paths of elements to pick,
* specified individually or in arrays.
* @param {...(string|string[])} [paths] The property paths of elements to pick.
* @returns {Array} Returns the new array of picked elements.
* @example
*
@@ -11881,9 +11945,9 @@
/**
* Iterates over own and inherited enumerable string keyed properties of an
* object invoking `iteratee` for each property. The iteratee is invoked with
* three arguments: (value, key, object). Iteratee functions may exit iteration
* early by explicitly returning `false`.
* object and invokes `iteratee` for each property. The iteratee is invoked
* with three arguments: (value, key, object). Iteratee functions may exit
* iteration early by explicitly returning `false`.
*
* @static
* @memberOf _
@@ -11944,10 +12008,10 @@
}
/**
* Iterates over own enumerable string keyed properties of an object invoking
* `iteratee` for each property. The iteratee is invoked with three arguments:
* (value, key, object). Iteratee functions may exit iteration early by
* explicitly returning `false`.
* Iterates over own enumerable string keyed properties of an object and
* invokes `iteratee` for each property. The iteratee is invoked with three
* arguments: (value, key, object). Iteratee functions may exit iteration
* early by explicitly returning `false`.
*
* @static
* @memberOf _
@@ -12470,8 +12534,7 @@
* @memberOf _
* @category Object
* @param {Object} object The source object.
* @param {...(string|string[])} [props] The property identifiers to omit,
* specified individually or in arrays.
* @param {...(string|string[])} [props] The property identifiers to omit.
* @returns {Object} Returns the new object.
* @example
*
@@ -12484,7 +12547,7 @@
if (object == null) {
return {};
}
props = arrayMap(baseFlatten(props, 1), baseCastKey);
props = arrayMap(baseFlatten(props, 1), toKey);
return basePick(object, baseDifference(getAllKeysIn(object), props));
});
@@ -12524,8 +12587,7 @@
* @memberOf _
* @category Object
* @param {Object} object The source object.
* @param {...(string|string[])} [props] The property identifiers to pick,
* specified individually or in arrays.
* @param {...(string|string[])} [props] The property identifiers to pick.
* @returns {Object} Returns the new object.
* @example
*
@@ -12591,7 +12653,7 @@
* // => 'default'
*/
function result(object, path, defaultValue) {
path = isKey(path, object) ? [path] : baseCastPath(path);
path = isKey(path, object) ? [path] : castPath(path);
var index = -1,
length = path.length;
@@ -12837,7 +12899,7 @@
* // => 0
*/
function update(object, path, updater) {
return object == null ? object : baseUpdate(object, path, baseCastFunction(updater));
return object == null ? object : baseUpdate(object, path, castFunction(updater));
}
/**
@@ -12866,7 +12928,7 @@
*/
function updateWith(object, path, updater, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined;
return object == null ? object : baseUpdate(object, path, baseCastFunction(updater), customizer);
return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
}
/**
@@ -13513,7 +13575,7 @@
var args = arguments,
string = toString(args[0]);
return args.length < 3 ? string : string.replace(args[1], args[2]);
return args.length < 3 ? string : nativeReplace.call(string, args[1], args[2]);
}
/**
@@ -13561,6 +13623,13 @@
* // => ['a', 'b']
*/
function split(string, separator, limit) {
if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
separator = limit = undefined;
}
limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
if (!limit) {
return [];
}
string = toString(string);
if (string && (
typeof separator == 'string' ||
@@ -13568,11 +13637,10 @@
)) {
separator += '';
if (separator == '' && reHasComplexSymbol.test(string)) {
var strSymbols = stringToArray(string);
return limit === undefined ? strSymbols : strSymbols.slice(0, limit < 0 ? 0 : limit);
return castSlice(stringToArray(string), 0, limit);
}
}
return string.split(separator, limit);
return nativeSplit.call(string, separator, limit);
}
/**
@@ -13920,16 +13988,15 @@
if (guard || chars === undefined) {
return string.replace(reTrim, '');
}
chars = (chars + '');
if (!chars) {
if (!(chars += '')) {
return string;
}
var strSymbols = stringToArray(string),
chrSymbols = stringToArray(chars);
chrSymbols = stringToArray(chars),
start = charsStartIndex(strSymbols, chrSymbols),
end = charsEndIndex(strSymbols, chrSymbols) + 1;
return strSymbols
.slice(charsStartIndex(strSymbols, chrSymbols), charsEndIndex(strSymbols, chrSymbols) + 1)
.join('');
return castSlice(strSymbols, start, end).join('');
}
/**
@@ -13959,14 +14026,13 @@
if (guard || chars === undefined) {
return string.replace(reTrimEnd, '');
}
chars = (chars + '');
if (!chars) {
if (!(chars += '')) {
return string;
}
var strSymbols = stringToArray(string);
return strSymbols
.slice(0, charsEndIndex(strSymbols, stringToArray(chars)) + 1)
.join('');
var strSymbols = stringToArray(string),
end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
return castSlice(strSymbols, 0, end).join('');
}
/**
@@ -13996,14 +14062,13 @@
if (guard || chars === undefined) {
return string.replace(reTrimStart, '');
}
chars = (chars + '');
if (!chars) {
if (!(chars += '')) {
return string;
}
var strSymbols = stringToArray(string);
return strSymbols
.slice(charsStartIndex(strSymbols, stringToArray(chars)))
.join('');
var strSymbols = stringToArray(string),
start = charsStartIndex(strSymbols, stringToArray(chars));
return castSlice(strSymbols, start).join('');
}
/**
@@ -14067,7 +14132,7 @@
return omission;
}
var result = strSymbols
? strSymbols.slice(0, end).join('')
? castSlice(strSymbols, 0, end).join('')
: string.slice(0, end);
if (separator === undefined) {
@@ -14240,8 +14305,7 @@
* @memberOf _
* @category Util
* @param {Object} object The object to bind and assign the bound methods to.
* @param {...(string|string[])} methodNames The object method names to bind,
* specified individually or in arrays.
* @param {...(string|string[])} methodNames The object method names to bind.
* @returns {Object} Returns `object`.
* @example
*
@@ -14264,7 +14328,7 @@
});
/**
* Creates a function that iterates over `pairs` invoking the corresponding
* Creates a function that iterates over `pairs` and invokes the corresponding
* function of the first predicate to return truthy. The predicate-function
* pairs are invoked with the `this` binding and arguments of the created
* function.
@@ -14700,7 +14764,8 @@
}
/**
* Creates a function that returns its nth argument.
* Creates a function that returns its nth argument. If `n` is negative,
* the nth argument from the end is returned.
*
* @static
* @memberOf _
@@ -14711,15 +14776,18 @@
* @example
*
* var func = _.nthArg(1);
*
* func('a', 'b', 'c');
* func('a', 'b', 'c', 'd');
* // => 'b'
*
* var func = _.nthArg(-2);
* func('a', 'b', 'c', 'd');
* // => 'c'
*/
function nthArg(n) {
n = toInteger(n);
return function() {
return arguments[n];
};
return rest(function(args) {
return baseNth(args, n);
});
}
/**
@@ -14730,7 +14798,8 @@
* @memberOf _
* @since 4.0.0
* @category Util
* @param {...(Function|Function[])} iteratees The iteratees to invoke.
* @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
* [iteratees=[_.identity]] The iteratees to invoke.
* @returns {Function} Returns the new function.
* @example
*
@@ -14749,7 +14818,8 @@
* @memberOf _
* @since 4.0.0
* @category Util
* @param {...(Function|Function[])} predicates The predicates to check.
* @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
* [predicates=[_.identity]] The predicates to check.
* @returns {Function} Returns the new function.
* @example
*
@@ -14774,7 +14844,8 @@
* @memberOf _
* @since 4.0.0
* @category Util
* @param {...(Function|Function[])} predicates The predicates to check.
* @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
* [predicates=[_.identity]] The predicates to check.
* @returns {Function} Returns the new function.
* @example
*
@@ -14988,7 +15059,7 @@
*/
function toPath(value) {
if (isArray(value)) {
return arrayMap(value, baseCastKey);
return arrayMap(value, toKey);
}
return isSymbol(value) ? [value] : copyArray(stringToPath(value));
}
@@ -15624,6 +15695,7 @@
lodash.min = min;
lodash.minBy = minBy;
lodash.multiply = multiply;
lodash.nth = nth;
lodash.noConflict = noConflict;
lodash.noop = noop;
lodash.now = now;

4
map.js
View File

@@ -11,8 +11,8 @@ define(['./_arrayMap', './_baseIteratee', './_baseMap', './isArray'], function(a
* The guarded methods are:
* `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
* `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
* `sampleSize`, `slice`, `some`, `sortBy`, `take`, `takeRight`, `template`,
* `trim`, `trimEnd`, `trimStart`, and `words`
* `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
* `template`, `trim`, `trimEnd`, `trimStart`, and `words`
*
* @static
* @memberOf _

32
nth.js Normal file
View File

@@ -0,0 +1,32 @@
define(['./_baseNth', './toInteger'], function(baseNth, toInteger) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* Gets the nth element of `array`. If `n` is negative, the nth element
* from the end is returned.
*
* @static
* @memberOf _
* @since 4.11.0
* @category Array
* @param {Array} array The array to query.
* @param {number} [n=0] The index of the element to return.
* @returns {*} Returns the nth element of `array`.
* @example
*
* var array = ['a', 'b', 'c', 'd'];
*
* _.nth(array, 1);
* // => 'b'
*
* _.nth(array, -2);
* // => 'c';
*/
function nth(array, n) {
return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
}
return nth;
});

View File

@@ -1,7 +1,8 @@
define(['./toInteger'], function(toInteger) {
define(['./_baseNth', './rest', './toInteger'], function(baseNth, rest, toInteger) {
/**
* Creates a function that returns its nth argument.
* Creates a function that returns its nth argument. If `n` is negative,
* the nth argument from the end is returned.
*
* @static
* @memberOf _
@@ -12,15 +13,18 @@ define(['./toInteger'], function(toInteger) {
* @example
*
* var func = _.nthArg(1);
*
* func('a', 'b', 'c');
* func('a', 'b', 'c', 'd');
* // => 'b'
*
* var func = _.nthArg(-2);
* func('a', 'b', 'c', 'd');
* // => 'c'
*/
function nthArg(n) {
n = toInteger(n);
return function() {
return arguments[n];
};
return rest(function(args) {
return baseNth(args, n);
});
}
return nthArg;

View File

@@ -1,4 +1,4 @@
define(['./_arrayMap', './_baseCastKey', './_baseDifference', './_baseFlatten', './_basePick', './_getAllKeysIn', './rest'], function(arrayMap, baseCastKey, baseDifference, baseFlatten, basePick, getAllKeysIn, rest) {
define(['./_arrayMap', './_baseDifference', './_baseFlatten', './_basePick', './_getAllKeysIn', './rest', './_toKey'], function(arrayMap, baseDifference, baseFlatten, basePick, getAllKeysIn, rest, toKey) {
/**
* The opposite of `_.pick`; this method creates an object composed of the
@@ -10,8 +10,7 @@ define(['./_arrayMap', './_baseCastKey', './_baseDifference', './_baseFlatten',
* @memberOf _
* @category Object
* @param {Object} object The source object.
* @param {...(string|string[])} [props] The property identifiers to omit,
* specified individually or in arrays.
* @param {...(string|string[])} [props] The property identifiers to omit.
* @returns {Object} Returns the new object.
* @example
*
@@ -24,7 +23,7 @@ define(['./_arrayMap', './_baseCastKey', './_baseDifference', './_baseFlatten',
if (object == null) {
return {};
}
props = arrayMap(baseFlatten(props, 1), baseCastKey);
props = arrayMap(baseFlatten(props, 1), toKey);
return basePick(object, baseDifference(getAllKeysIn(object), props));
});

View File

@@ -8,7 +8,8 @@ define(['./_arrayMap', './_createOver'], function(arrayMap, createOver) {
* @memberOf _
* @since 4.0.0
* @category Util
* @param {...(Function|Function[])} iteratees The iteratees to invoke.
* @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
* [iteratees=[_.identity]] The iteratees to invoke.
* @returns {Function} Returns the new function.
* @example
*

View File

@@ -1,4 +1,4 @@
define(['./_apply', './_arrayMap', './_baseFlatten', './_baseIteratee', './_isFlattenableIteratee', './rest'], function(apply, arrayMap, baseFlatten, baseIteratee, isFlattenableIteratee, rest) {
define(['./_apply', './_arrayMap', './_baseFlatten', './_baseIteratee', './_baseUnary', './isArray', './_isFlattenableIteratee', './rest'], function(apply, arrayMap, baseFlatten, baseIteratee, baseUnary, isArray, isFlattenableIteratee, rest) {
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMin = Math.min;
@@ -12,8 +12,8 @@ define(['./_apply', './_arrayMap', './_baseFlatten', './_baseIteratee', './_isFl
* @memberOf _
* @category Function
* @param {Function} func The function to wrap.
* @param {...(Function|Function[])} [transforms] The functions to transform.
* arguments, specified individually or in arrays.
* @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
* [transforms[_.identity]] The functions to transform.
* @returns {Function} Returns the new function.
* @example
*
@@ -36,7 +36,10 @@ define(['./_apply', './_arrayMap', './_baseFlatten', './_baseIteratee', './_isFl
* // => [100, 10]
*/
var overArgs = rest(function(func, transforms) {
transforms = arrayMap(baseFlatten(transforms, 1, isFlattenableIteratee), baseIteratee);
transforms = (transforms.length == 1 && isArray(transforms[0]))
? arrayMap(transforms[0], baseUnary(baseIteratee))
: arrayMap(baseFlatten(transforms, 1, isFlattenableIteratee), baseUnary(baseIteratee));
var funcsLength = transforms.length;
return rest(function(args) {
var index = -1,

View File

@@ -8,7 +8,8 @@ define(['./_arrayEvery', './_createOver'], function(arrayEvery, createOver) {
* @memberOf _
* @since 4.0.0
* @category Util
* @param {...(Function|Function[])} predicates The predicates to check.
* @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
* [predicates=[_.identity]] The predicates to check.
* @returns {Function} Returns the new function.
* @example
*

View File

@@ -8,7 +8,8 @@ define(['./_arraySome', './_createOver'], function(arraySome, createOver) {
* @memberOf _
* @since 4.0.0
* @category Util
* @param {...(Function|Function[])} predicates The predicates to check.
* @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
* [predicates=[_.identity]] The predicates to check.
* @returns {Function} Returns the new function.
* @example
*

View File

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

View File

@@ -8,8 +8,7 @@ define(['./_baseFlatten', './_basePick', './rest'], function(baseFlatten, basePi
* @memberOf _
* @category Object
* @param {Object} object The source object.
* @param {...(string|string[])} [props] The property identifiers to pick,
* specified individually or in arrays.
* @param {...(string|string[])} [props] The property identifiers to pick.
* @returns {Object} Returns the new object.
* @example
*

View File

@@ -11,8 +11,7 @@ define(['./_arrayMap', './_baseAt', './_baseFlatten', './_basePullAt', './_compa
* @since 3.0.0
* @category Array
* @param {Array} array The array to modify.
* @param {...(number|number[])} [indexes] The indexes of elements to remove,
* specified individually or in arrays.
* @param {...(number|number[])} [indexes] The indexes of elements to remove.
* @returns {Array} Returns the new array of removed elements.
* @example
*

View File

@@ -17,8 +17,7 @@ define(['./_baseFlatten', './_createWrapper', './rest'], function(baseFlatten, c
* @since 3.0.0
* @category Function
* @param {Function} func The function to rearrange arguments for.
* @param {...(number|number[])} indexes The arranged argument indexes,
* specified individually or in arrays.
* @param {...(number|number[])} indexes The arranged argument indexes.
* @returns {Function} Returns the new function.
* @example
*

View File

@@ -1,5 +1,11 @@
define(['./toString'], function(toString) {
/** Used for built-in method references. */
var stringProto = String.prototype;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeReplace = stringProto.replace;
/**
* Replaces matches for `pattern` in `string` with `replacement`.
*
@@ -23,7 +29,7 @@ define(['./toString'], function(toString) {
var args = arguments,
string = toString(args[0]);
return args.length < 3 ? string : string.replace(args[1], args[2]);
return args.length < 3 ? string : nativeReplace.call(string, args[1], args[2]);
}
return replace;

View File

@@ -1,4 +1,4 @@
define(['./_baseCastPath', './isFunction', './_isKey'], function(baseCastPath, isFunction, isKey) {
define(['./_castPath', './isFunction', './_isKey'], function(castPath, isFunction, isKey) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -33,7 +33,7 @@ define(['./_baseCastPath', './isFunction', './_isKey'], function(baseCastPath, i
* // => 'default'
*/
function result(object, path, defaultValue) {
path = isKey(path, object) ? [path] : baseCastPath(path);
path = isKey(path, object) ? [path] : castPath(path);
var index = -1,
length = path.length;

View File

@@ -1,4 +1,4 @@
define(['./_baseFlatten', './_baseOrderBy', './_isIterateeCall', './rest'], function(baseFlatten, baseOrderBy, isIterateeCall, rest) {
define(['./_baseFlatten', './_baseOrderBy', './isArray', './_isFlattenableIteratee', './_isIterateeCall', './rest'], function(baseFlatten, baseOrderBy, isArray, isFlattenableIteratee, isIterateeCall, rest) {
/**
* Creates an array of elements, sorted in ascending order by the results of
@@ -12,8 +12,7 @@ define(['./_baseFlatten', './_baseOrderBy', './_isIterateeCall', './rest'], func
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
* [iteratees=[_.identity]] The iteratees to sort by, specified individually
* or in arrays.
* [iteratees=[_.identity]] The iteratees to sort by.
* @returns {Array} Returns the new sorted array.
* @example
*
@@ -43,9 +42,13 @@ define(['./_baseFlatten', './_baseOrderBy', './_isIterateeCall', './rest'], func
if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
iteratees = [];
} else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
iteratees.length = 1;
iteratees = [iteratees[0]];
}
return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
? iteratees[0]
: baseFlatten(iteratees, 1, isFlattenableIteratee);
return baseOrderBy(collection, iteratees, []);
});
return sortBy;

View File

@@ -1,19 +1,16 @@
define(['./isRegExp', './_stringToArray', './toString'], function(isRegExp, stringToArray, toString) {
define(['./_castSlice', './_isIterateeCall', './isRegExp', './_reHasComplexSymbol', './_stringToArray', './toString'], function(castSlice, isIterateeCall, isRegExp, reHasComplexSymbol, stringToArray, toString) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboSymbolsRange = '\\u20d0-\\u20f0',
rsVarRange = '\\ufe0e\\ufe0f';
/** Used as references for the maximum length and index of an array. */
var MAX_ARRAY_LENGTH = 4294967295;
/** Used to compose unicode capture groups. */
var rsZWJ = '\\u200d';
/** Used for built-in method references. */
var stringProto = String.prototype;
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeSplit = stringProto.split;
/**
* Splits `string` by `separator`.
@@ -35,6 +32,13 @@ define(['./isRegExp', './_stringToArray', './toString'], function(isRegExp, stri
* // => ['a', 'b']
*/
function split(string, separator, limit) {
if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
separator = limit = undefined;
}
limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
if (!limit) {
return [];
}
string = toString(string);
if (string && (
typeof separator == 'string' ||
@@ -42,11 +46,10 @@ define(['./isRegExp', './_stringToArray', './toString'], function(isRegExp, stri
)) {
separator += '';
if (separator == '' && reHasComplexSymbol.test(string)) {
var strSymbols = stringToArray(string);
return limit === undefined ? strSymbols : strSymbols.slice(0, limit < 0 ? 0 : limit);
return castSlice(stringToArray(string), 0, limit);
}
}
return string.split(separator, limit);
return nativeSplit.call(string, separator, limit);
}
return split;

View File

@@ -1,4 +1,4 @@
define(['./_apply', './_arrayPush', './rest', './toInteger'], function(apply, arrayPush, rest, toInteger) {
define(['./_apply', './_arrayPush', './_castSlice', './rest', './toInteger'], function(apply, arrayPush, castSlice, rest, toInteger) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -50,7 +50,7 @@ define(['./_apply', './_arrayPush', './rest', './toInteger'], function(apply, ar
start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
return rest(function(args) {
var array = args[start],
otherArgs = args.slice(0, start);
otherArgs = castSlice(args, 0, start);
if (array) {
arrayPush(otherArgs, array);

View File

@@ -1,4 +1,4 @@
define(['./_arrayMap', './_baseCastKey', './_copyArray', './isArray', './isSymbol', './_stringToPath'], function(arrayMap, baseCastKey, copyArray, isArray, isSymbol, stringToPath) {
define(['./_arrayMap', './_copyArray', './isArray', './isSymbol', './_stringToPath', './_toKey'], function(arrayMap, copyArray, isArray, isSymbol, stringToPath, toKey) {
/**
* Converts `value` to a property path array.
@@ -28,7 +28,7 @@ define(['./_arrayMap', './_baseCastKey', './_copyArray', './isArray', './isSymbo
*/
function toPath(value) {
if (isArray(value)) {
return arrayMap(value, baseCastKey);
return arrayMap(value, toKey);
}
return isSymbol(value) ? [value] : copyArray(stringToPath(value));
}

View File

@@ -11,8 +11,8 @@ define(['./_Symbol', './isSymbol'], function(Symbol, isSymbol) {
symbolToString = symbolProto ? symbolProto.toString : undefined;
/**
* Converts `value` to a string if it's not one. An empty string is returned
* for `null` and `undefined` values. The sign of `-0` is preserved.
* Converts `value` to a string. An empty string is returned for `null`
* and `undefined` values. The sign of `-0` is preserved.
*
* @static
* @memberOf _

13
trim.js
View File

@@ -1,4 +1,4 @@
define(['./_charsEndIndex', './_charsStartIndex', './_stringToArray', './toString'], function(charsEndIndex, charsStartIndex, stringToArray, toString) {
define(['./_castSlice', './_charsEndIndex', './_charsStartIndex', './_stringToArray', './toString'], function(castSlice, charsEndIndex, charsStartIndex, stringToArray, toString) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -36,16 +36,15 @@ define(['./_charsEndIndex', './_charsStartIndex', './_stringToArray', './toStrin
if (guard || chars === undefined) {
return string.replace(reTrim, '');
}
chars = (chars + '');
if (!chars) {
if (!(chars += '')) {
return string;
}
var strSymbols = stringToArray(string),
chrSymbols = stringToArray(chars);
chrSymbols = stringToArray(chars),
start = charsStartIndex(strSymbols, chrSymbols),
end = charsEndIndex(strSymbols, chrSymbols) + 1;
return strSymbols
.slice(charsStartIndex(strSymbols, chrSymbols), charsEndIndex(strSymbols, chrSymbols) + 1)
.join('');
return castSlice(strSymbols, start, end).join('');
}
return trim;

View File

@@ -1,4 +1,4 @@
define(['./_charsEndIndex', './_stringToArray', './toString'], function(charsEndIndex, stringToArray, toString) {
define(['./_castSlice', './_charsEndIndex', './_stringToArray', './toString'], function(castSlice, charsEndIndex, stringToArray, toString) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -33,14 +33,13 @@ define(['./_charsEndIndex', './_stringToArray', './toString'], function(charsEnd
if (guard || chars === undefined) {
return string.replace(reTrimEnd, '');
}
chars = (chars + '');
if (!chars) {
if (!(chars += '')) {
return string;
}
var strSymbols = stringToArray(string);
return strSymbols
.slice(0, charsEndIndex(strSymbols, stringToArray(chars)) + 1)
.join('');
var strSymbols = stringToArray(string),
end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
return castSlice(strSymbols, 0, end).join('');
}
return trimEnd;

View File

@@ -1,4 +1,4 @@
define(['./_charsStartIndex', './_stringToArray', './toString'], function(charsStartIndex, stringToArray, toString) {
define(['./_castSlice', './_charsStartIndex', './_stringToArray', './toString'], function(castSlice, charsStartIndex, stringToArray, toString) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -33,14 +33,13 @@ define(['./_charsStartIndex', './_stringToArray', './toString'], function(charsS
if (guard || chars === undefined) {
return string.replace(reTrimStart, '');
}
chars = (chars + '');
if (!chars) {
if (!(chars += '')) {
return string;
}
var strSymbols = stringToArray(string);
return strSymbols
.slice(charsStartIndex(strSymbols, stringToArray(chars)))
.join('');
var strSymbols = stringToArray(string),
start = charsStartIndex(strSymbols, stringToArray(chars));
return castSlice(strSymbols, start).join('');
}
return trimStart;

View File

@@ -1,4 +1,4 @@
define(['./isObject', './isRegExp', './_stringSize', './_stringToArray', './toInteger', './toString'], function(isObject, isRegExp, stringSize, stringToArray, toInteger, toString) {
define(['./_castSlice', './isObject', './isRegExp', './_reHasComplexSymbol', './_stringSize', './_stringToArray', './toInteger', './toString'], function(castSlice, isObject, isRegExp, reHasComplexSymbol, stringSize, stringToArray, toInteger, toString) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -10,18 +10,6 @@ define(['./isObject', './isRegExp', './_stringSize', './_stringToArray', './toIn
/** Used to match `RegExp` flags from their coerced string values. */
var reFlags = /\w*$/;
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboSymbolsRange = '\\u20d0-\\u20f0',
rsVarRange = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsZWJ = '\\u200d';
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
/**
* Truncates `string` if it's longer than the given maximum string length.
* The last characters of the truncated string are replaced with the omission
@@ -83,7 +71,7 @@ define(['./isObject', './isRegExp', './_stringSize', './_stringToArray', './toIn
return omission;
}
var result = strSymbols
? strSymbols.slice(0, end).join('')
? castSlice(strSymbols, 0, end).join('')
: string.slice(0, end);
if (separator === undefined) {

View File

@@ -1,4 +1,4 @@
define(['./_baseCastFunction', './_baseUpdate'], function(baseCastFunction, baseUpdate) {
define(['./_baseUpdate', './_castFunction'], function(baseUpdate, castFunction) {
/**
* This method is like `_.set` except that accepts `updater` to produce the
@@ -28,7 +28,7 @@ define(['./_baseCastFunction', './_baseUpdate'], function(baseCastFunction, base
* // => 0
*/
function update(object, path, updater) {
return object == null ? object : baseUpdate(object, path, baseCastFunction(updater));
return object == null ? object : baseUpdate(object, path, castFunction(updater));
}
return update;

View File

@@ -1,4 +1,4 @@
define(['./_baseCastFunction', './_baseUpdate'], function(baseCastFunction, baseUpdate) {
define(['./_baseUpdate', './_castFunction'], function(baseUpdate, castFunction) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -29,7 +29,7 @@ define(['./_baseCastFunction', './_baseUpdate'], function(baseCastFunction, base
*/
function updateWith(object, path, updater, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined;
return object == null ? object : baseUpdate(object, path, baseCastFunction(updater), customizer);
return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
}
return updateWith;

View File

@@ -3,6 +3,9 @@ define(['./toString'], function(toString) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used to match non-compound words composed of alphanumeric characters. */
var reBasicWord = /[a-zA-Z0-9]+/g;
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
@@ -18,7 +21,8 @@ define(['./toString'], function(toString) {
rsBreakRange = rsMathOpRange + rsNonCharRange + rsQuoteRange + rsSpaceRange;
/** Used to compose unicode capture groups. */
var rsBreak = '[' + rsBreakRange + ']',
var rsApos = "['\u2019]",
rsBreak = '[' + rsBreakRange + ']',
rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
rsDigits = '\\d+',
rsDingbat = '[' + rsDingbatRange + ']',
@@ -35,21 +39,20 @@ define(['./toString'], function(toString) {
/** Used to compose unicode regexes. */
var rsLowerMisc = '(?:' + rsLower + '|' + rsMisc + ')',
rsUpperMisc = '(?:' + rsUpper + '|' + rsMisc + ')',
rsOptLowerContr = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
rsOptUpperContr = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
reOptMod = rsModifier + '?',
rsOptVar = '[' + rsVarRange + ']?',
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
rsSeq = rsOptVar + reOptMod + rsOptJoin,
rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq;
/** Used to match non-compound words composed of alphanumeric characters. */
var reBasicWord = /[a-zA-Z0-9]+/g;
/** Used to match complex or compound words. */
var reComplexWord = RegExp([
rsUpper + '?' + rsLower + '+(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
rsUpperMisc + '+(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')',
rsUpper + '?' + rsLowerMisc + '+',
rsUpper + '+',
rsUpper + '?' + rsLower + '+' + rsOptLowerContr + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
rsUpperMisc + '+' + rsOptUpperContr + '(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')',
rsUpper + '?' + rsLowerMisc + '+' + rsOptLowerContr,
rsUpper + '+' + rsOptUpperContr,
rsDigits,
rsEmoji
].join('|'), 'g');

View File

@@ -10,8 +10,7 @@ define(['./_LazyWrapper', './_LodashWrapper', './_baseAt', './_baseFlatten', './
* @memberOf _
* @since 1.0.0
* @category Seq
* @param {...(string|string[])} [paths] The property paths of elements to pick,
* specified individually or in arrays.
* @param {...(string|string[])} [paths] The property paths of elements to pick.
* @returns {Object} Returns the new `lodash` wrapper instance.
* @example
*

View File

@@ -86,7 +86,7 @@ define(['./_LazyWrapper', './_LodashWrapper', './_baseLodash', './isArray', './i
* `isSet`, `isString`, `isUndefined`, `isTypedArray`, `isWeakMap`, `isWeakSet`,
* `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`,
* `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, `min`, `minBy`, `multiply`,
* `noConflict`, `noop`, `now`, `pad`, `padEnd`, `padStart`, `parseInt`,
* `noConflict`, `noop`, `now`, `nth`, `pad`, `padEnd`, `padStart`, `parseInt`,
* `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`,
* `runInContext`, `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`,
* `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, `startCase`,