Compare commits

...

1 Commits

Author SHA1 Message Date
John-David Dalton
764eccfdc0 Bump to v4.11.0. 2016-04-13 10:21:06 -07:00
25 changed files with 159 additions and 82 deletions

View File

@@ -1,4 +1,4 @@
# lodash-es v4.10.0
# lodash-es v4.11.0
The [Lodash](https://lodash.com/) library exported as [ES](http://www.ecma-international.org/ecma-262/6.0/) modules.
@@ -7,4 +7,4 @@ Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli):
$ lodash modularize exports=es -o ./
```
See the [package source](https://github.com/lodash/lodash/tree/4.10.0-es) for more details.
See the [package source](https://github.com/lodash/lodash/tree/4.11.0-es) for more details.

20
_baseNth.js Normal file
View File

@@ -0,0 +1,20 @@
import isIndex from './_isIndex';
/**
* 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;
}
export default baseNth;

View File

@@ -2,6 +2,7 @@ import arrayMap from './_arrayMap';
import baseIteratee from './_baseIteratee';
import baseMap from './_baseMap';
import baseSortBy from './_baseSortBy';
import baseUnary from './_baseUnary';
import compareMultiple from './_compareMultiple';
import identity from './identity';
@@ -16,7 +17,7 @@ import identity from './identity';
*/
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 @@
import copyObjectWith from './_copyObjectWith';
import assignValue from './_assignValue';
/**
* Copies properties of `source` to `object`.
@@ -7,10 +7,25 @@ import copyObjectWith from './_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;
}
export default copyObject;

View File

@@ -1,32 +0,0 @@
import assignValue from './_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;
}
export default copyObjectWith;

View File

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

View File

@@ -2,6 +2,8 @@ import apply from './_apply';
import arrayMap from './_arrayMap';
import baseFlatten from './_baseFlatten';
import baseIteratee from './_baseIteratee';
import baseUnary from './_baseUnary';
import isArray from './isArray';
import isFlattenableIteratee from './_isFlattenableIteratee';
import rest from './rest';
@@ -14,7 +16,10 @@ import rest from './rest';
*/
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,4 +1,3 @@
import copyArray from './_copyArray';
import isLaziable from './_isLaziable';
import setData from './_setData';
@@ -30,7 +29,6 @@ var BIND_FLAG = 1,
*/
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,
@@ -44,7 +42,7 @@ function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, par
}
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,6 +1,5 @@
import composeArgs from './_composeArgs';
import composeArgsRight from './_composeArgsRight';
import copyArray from './_copyArray';
import replaceHolders from './_replaceHolders';
/** Used as the internal argument placeholder. */
@@ -58,20 +57,20 @@ function mergeData(data, source) {
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) {

View File

@@ -24,6 +24,7 @@ import intersectionWith from './intersectionWith';
import join from './join';
import last from './last';
import lastIndexOf from './lastIndexOf';
import nth from './nth';
import pull from './pull';
import pullAll from './pullAll';
import pullAllBy from './pullAllBy';
@@ -68,12 +69,12 @@ export default {
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
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
};

View File

@@ -24,6 +24,7 @@ export { default as intersectionWith } from './intersectionWith';
export { default as join } from './join';
export { default as last } from './last';
export { default as lastIndexOf } from './lastIndexOf';
export { default as nth } from './nth';
export { default as pull } from './pull';
export { default as pullAll } from './pullAll';
export { default as pullAllBy } from './pullAllBy';

View File

@@ -1,4 +1,4 @@
import copyObjectWith from './_copyObjectWith';
import copyObject from './_copyObject';
import createAssigner from './_createAssigner';
import keysIn from './keysIn';
@@ -31,7 +31,7 @@ import keysIn from './keysIn';
* // => { 'a': 1, 'b': 2 }
*/
var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
copyObjectWith(source, keysIn(source), object, customizer);
copyObject(source, keysIn(source), object, customizer);
});
export default assignInWith;

View File

@@ -1,4 +1,4 @@
import copyObjectWith from './_copyObjectWith';
import copyObject from './_copyObject';
import createAssigner from './_createAssigner';
import keys from './keys';
@@ -30,7 +30,7 @@ import keys from './keys';
* // => { 'a': 1, 'b': 2 }
*/
var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
copyObjectWith(source, keys(source), object, customizer);
copyObject(source, keys(source), object, customizer);
});
export default assignWith;

View File

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

View File

@@ -1,6 +1,6 @@
/**
* @license
* lodash 4.10.0 (Custom Build) <https://lodash.com/>
* lodash 4.11.0 (Custom Build) <https://lodash.com/>
* Build: `lodash modularize exports="es" -o ./`
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
* Released under MIT license <https://lodash.com/license>
@@ -44,7 +44,7 @@ import toInteger from './toInteger';
import lodash from './wrapperLodash';
/** Used as the semantic version number. */
var VERSION = '4.10.0';
var VERSION = '4.11.0';
/** Used to compose bitmasks for wrapper metadata. */
var BIND_KEY_FLAG = 2;
@@ -342,6 +342,7 @@ lodash.meanBy = math.meanBy;
lodash.min = math.min;
lodash.minBy = math.minBy;
lodash.multiply = math.multiply;
lodash.nth = array.nth;
lodash.noop = util.noop;
lodash.now = date.now;
lodash.pad = string.pad;

View File

@@ -1,6 +1,6 @@
/**
* @license
* lodash 4.10.0 (Custom Build) <https://lodash.com/>
* lodash 4.11.0 (Custom Build) <https://lodash.com/>
* Build: `lodash modularize exports="es" -o ./`
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
* Released under MIT license <https://lodash.com/license>
@@ -184,6 +184,7 @@ export { default as negate } from './negate';
export { default as next } from './next';
export { default as noop } from './noop';
export { default as now } from './now';
export { default as nth } from './nth';
export { default as nthArg } from './nthArg';
export { default as omit } from './omit';
export { default as omitBy } from './omitBy';

29
nth.js Normal file
View File

@@ -0,0 +1,29 @@
import baseNth from './_baseNth';
import toInteger from './toInteger';
/**
* 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;
}
export default nth;

View File

@@ -1,7 +1,10 @@
import baseNth from './_baseNth';
import rest from './rest';
import toInteger from './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 +15,18 @@ import toInteger from './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);
});
}
export default nthArg;

View File

@@ -2,6 +2,8 @@ import apply from './_apply';
import arrayMap from './_arrayMap';
import baseFlatten from './_baseFlatten';
import baseIteratee from './_baseIteratee';
import baseUnary from './_baseUnary';
import isArray from './isArray';
import isFlattenableIteratee from './_isFlattenableIteratee';
import rest from './rest';
@@ -41,7 +43,10 @@ var nativeMin = Math.min;
* // => [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

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

View File

@@ -1,5 +1,11 @@
import toString from './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 @@ function replace() {
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]);
}
export default replace;

View File

@@ -1,5 +1,7 @@
import baseFlatten from './_baseFlatten';
import baseOrderBy from './_baseOrderBy';
import isArray from './isArray';
import isFlattenableIteratee from './_isFlattenableIteratee';
import isIterateeCall from './_isIterateeCall';
import rest from './rest';
@@ -47,7 +49,11 @@ var sortBy = rest(function(collection, iteratees) {
} else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
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, []);
});
export default sortBy;

View File

@@ -8,6 +8,12 @@ import toString from './toString';
/** Used as references for the maximum length and index of an array. */
var MAX_ARRAY_LENGTH = 4294967295;
/** 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 nativeSplit = stringProto.split;
/**
* Splits `string` by `separator`.
*
@@ -45,7 +51,7 @@ function split(string, separator, limit) {
return castSlice(stringToArray(string), 0, limit);
}
}
return string.split(separator, limit);
return nativeSplit.call(string, separator, limit);
}
export default split;

View File

@@ -18,7 +18,8 @@ var rsAstralRange = '\\ud800-\\udfff',
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,6 +36,8 @@ var rsBreak = '[' + rsBreakRange + ']',
/** 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 + ')*',
@@ -43,10 +46,10 @@ var rsLowerMisc = '(?:' + rsLower + '|' + rsMisc + ')',
/** 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

@@ -91,7 +91,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* `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`,