Compare commits

..

3 Commits

Author SHA1 Message Date
John-David Dalton
94d714007e Bump to v3.10.1. 2015-12-16 17:52:47 -08:00
John-David Dalton
75c633becb Bump to v3.10.0. 2015-12-16 17:52:15 -08:00
John-David Dalton
32393ae520 Bump to v3.9.3. 2015-12-16 17:51:44 -08:00
145 changed files with 1613 additions and 1269 deletions

View File

@@ -1,4 +1,4 @@
# lodash v3.9.2
# lodash v3.10.1
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules.
@@ -13,8 +13,8 @@ $ lodash modern exports=amd -d -o ./main.js
Using bower or volo:
```bash
$ bower i lodash#3.9.2-amd
$ volo add lodash/3.9.2-amd
$ bower i lodash#3.10.1-amd
$ volo add lodash/3.10.1-amd
```
Defining a build as `'lodash'`.

View File

@@ -1,10 +1,9 @@
define(['../internal/baseSlice', '../internal/isIterateeCall'], function(baseSlice, isIterateeCall) {
/** Native method references. */
var ceil = Math.ceil;
/* Native method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max;
var nativeCeil = Math.ceil,
nativeFloor = Math.floor,
nativeMax = Math.max;
/**
* Creates an array of elements split into groups the length of `size`.
@@ -30,12 +29,12 @@ define(['../internal/baseSlice', '../internal/isIterateeCall'], function(baseSli
if (guard ? isIterateeCall(array, size, guard) : size == null) {
size = 1;
} else {
size = nativeMax(+size || 1, 1);
size = nativeMax(nativeFloor(size) || 1, 1);
}
var index = 0,
length = array ? array.length : 0,
resIndex = -1,
result = Array(ceil(length / size));
result = Array(nativeCeil(length / size));
while (index < length) {
result[++resIndex] = baseSlice(array, index, (index += size));

View File

@@ -1,8 +1,8 @@
define(['../internal/baseDifference', '../internal/baseFlatten', '../internal/isArrayLike', '../function/restParam'], function(baseDifference, baseFlatten, isArrayLike, restParam) {
define(['../internal/baseDifference', '../internal/baseFlatten', '../internal/isArrayLike', '../internal/isObjectLike', '../function/restParam'], function(baseDifference, baseFlatten, isArrayLike, isObjectLike, restParam) {
/**
* Creates an array of unique `array` values not included in the other
* provided arrays using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* provided arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* for equality comparisons.
*
* @static
@@ -17,7 +17,7 @@ define(['../internal/baseDifference', '../internal/baseFlatten', '../internal/is
* // => [1, 3]
*/
var difference = restParam(function(array, values) {
return isArrayLike(array)
return (isObjectLike(array) && isArrayLike(array))
? baseDifference(array, baseFlatten(values, false, true))
: [];
});

View File

@@ -2,7 +2,7 @@ define(['../internal/baseFlatten', '../internal/isIterateeCall'], function(baseF
/**
* Flattens a nested array. If `isDeep` is `true` the array is recursively
* flattened, otherwise it is only flattened a single level.
* flattened, otherwise it's only flattened a single level.
*
* @static
* @memberOf _

View File

@@ -5,8 +5,8 @@ define(['../internal/baseIndexOf', '../internal/binaryIndex'], function(baseInde
/**
* Gets the index at which the first occurrence of `value` is found in `array`
* using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* for equality comparisons. If `fromIndex` is negative, it is used as the offset
* using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* for equality comparisons. If `fromIndex` is negative, it's used as the offset
* from the end of `array`. If `array` is sorted providing `true` for `fromIndex`
* performs a faster binary search.
*
@@ -39,10 +39,9 @@ define(['../internal/baseIndexOf', '../internal/binaryIndex'], function(baseInde
if (typeof fromIndex == 'number') {
fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex;
} else if (fromIndex) {
var index = binaryIndex(array, value),
other = array[index];
if (value === value ? (value === other) : (other !== other)) {
var index = binaryIndex(array, value);
if (index < length &&
(value === value ? (value === array[index]) : (array[index] !== array[index]))) {
return index;
}
return -1;

View File

@@ -2,7 +2,7 @@ define(['../internal/baseIndexOf', '../internal/cacheIndexOf', '../internal/crea
/**
* Creates an array of unique values that are included in all of the provided
* arrays using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* for equality comparisons.
*
* @static

View File

@@ -8,7 +8,7 @@ define(['../internal/baseIndexOf'], function(baseIndexOf) {
/**
* Removes all provided values from `array` using
* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* for equality comparisons.
*
* **Note:** Unlike `_.without`, this method mutates `array`.

View File

@@ -3,7 +3,7 @@ define(['../internal/createSortedIndex'], function(createSortedIndex) {
/**
* Uses a binary search to determine the lowest index at which `value` should
* be inserted into `array` in order to maintain its sort order. If an iteratee
* function is provided it is invoked for `value` and each element of `array`
* function is provided it's invoked for `value` and each element of `array`
* to compute their sort ranking. The iteratee is bound to `thisArg` and
* invoked with one argument; (value).
*

View File

@@ -2,7 +2,7 @@ define(['../internal/baseFlatten', '../internal/baseUniq', '../function/restPara
/**
* Creates an array of unique values, in order, from all of the provided arrays
* using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* for equality comparisons.
*
* @static

View File

@@ -1,11 +1,14 @@
define(['../internal/baseCallback', '../internal/baseUniq', '../internal/isIterateeCall', '../internal/sortedUniq'], function(baseCallback, baseUniq, isIterateeCall, sortedUniq) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* Creates a duplicate-free version of an array, using
* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* for equality comparisons, in which only the first occurence of each element
* is kept. Providing `true` for `isSorted` performs a faster search algorithm
* for sorted arrays. If an iteratee function is provided it is invoked for
* for sorted arrays. If an iteratee function is provided it's invoked for
* each element in the array to generate the criterion by which uniqueness
* is computed. The `iteratee` is bound to `thisArg` and invoked with three
* arguments: (value, index, array).
@@ -56,7 +59,7 @@ define(['../internal/baseCallback', '../internal/baseUniq', '../internal/isItera
}
if (isSorted != null && typeof isSorted != 'boolean') {
thisArg = iteratee;
iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted;
iteratee = isIterateeCall(array, isSorted, thisArg) ? undefined : isSorted;
isSorted = false;
}
iteratee = iteratee == null ? iteratee : baseCallback(iteratee, thisArg, 3);

View File

@@ -2,7 +2,7 @@ define(['../internal/baseDifference', '../internal/isArrayLike', '../function/re
/**
* Creates an array excluding all provided values using
* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* for equality comparisons.
*
* @static

View File

@@ -1,4 +1,4 @@
define(['../internal/baseDifference', '../internal/baseUniq', '../internal/isArrayLike'], function(baseDifference, baseUniq, isArrayLike) {
define(['../internal/arrayPush', '../internal/baseDifference', '../internal/baseUniq', '../internal/isArrayLike'], function(arrayPush, baseDifference, baseUniq, isArrayLike) {
/**
* Creates an array of unique values that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
@@ -22,7 +22,7 @@ define(['../internal/baseDifference', '../internal/baseUniq', '../internal/isArr
var array = arguments[index];
if (isArrayLike(array)) {
var result = result
? baseDifference(result, array).concat(baseDifference(array, result))
? arrayPush(baseDifference(result, array), baseDifference(array, result))
: array;
}
}

View File

@@ -1,7 +1,8 @@
define(['./chain/chain', './chain/commit', './chain/lodash', './chain/plant', './chain/reverse', './chain/run', './chain/tap', './chain/thru', './chain/toJSON', './chain/toString', './chain/value', './chain/valueOf', './chain/wrapperChain'], function(chain, commit, lodash, plant, reverse, run, tap, thru, toJSON, toString, value, valueOf, wrapperChain) {
define(['./chain/chain', './chain/commit', './chain/concat', './chain/lodash', './chain/plant', './chain/reverse', './chain/run', './chain/tap', './chain/thru', './chain/toJSON', './chain/toString', './chain/value', './chain/valueOf', './chain/wrapperChain'], function(chain, commit, concat, lodash, plant, reverse, run, tap, thru, toJSON, toString, value, valueOf, wrapperChain) {
return {
'chain': chain,
'commit': commit,
'concat': concat,
'lodash': lodash,
'plant': plant,
'reverse': reverse,

3
chain/concat.js Normal file
View File

@@ -0,0 +1,3 @@
define(["./wrapperConcat"], function(wrapperConcat) {
return wrapperConcat;
});

View File

@@ -9,15 +9,16 @@ define(['../internal/LazyWrapper', '../internal/LodashWrapper', '../internal/bas
/**
* Creates a `lodash` object which wraps `value` to enable implicit chaining.
* Methods that operate on and return arrays, collections, and functions can
* be chained together. Methods that return a boolean or single value will
* automatically end the chain returning the unwrapped value. Explicit chaining
* may be enabled using `_.chain`. The execution of chained methods is lazy,
* that is, execution is deferred until `_#value` is implicitly or explicitly
* called.
* be chained together. Methods that retrieve a single value or may return a
* primitive value will automatically end the chain returning the unwrapped
* value. Explicit chaining may be enabled using `_.chain`. The execution of
* chained methods is lazy, that is, execution is deferred until `_#value`
* is implicitly or explicitly called.
*
* Lazy evaluation allows several methods to support shortcut fusion. Shortcut
* fusion is an optimization that merges iteratees to avoid creating intermediate
* arrays and reduce the number of iteratee executions.
* fusion is an optimization strategy which merge iteratee calls; this can help
* to avoid the creation of intermediate data structures and greatly reduce the
* number of iteratee executions.
*
* Chaining is supported in custom builds as long as the `_#value` method is
* directly or indirectly included in the build.
@@ -40,36 +41,37 @@ define(['../internal/LazyWrapper', '../internal/LodashWrapper', '../internal/bas
* The chainable wrapper methods are:
* `after`, `ary`, `assign`, `at`, `before`, `bind`, `bindAll`, `bindKey`,
* `callback`, `chain`, `chunk`, `commit`, `compact`, `concat`, `constant`,
* `countBy`, `create`, `curry`, `debounce`, `defaults`, `defer`, `delay`,
* `difference`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `fill`,
* `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, `forEach`,
* `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `functions`,
* `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`,
* `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
* `memoize`, `merge`, `method`, `methodOf`, `mixin`, `negate`, `omit`, `once`,
* `pairs`, `partial`, `partialRight`, `partition`, `pick`, `plant`, `pluck`,
* `property`, `propertyOf`, `pull`, `pullAt`, `push`, `range`, `rearg`,
* `reject`, `remove`, `rest`, `restParam`, `reverse`, `set`, `shuffle`,
* `slice`, `sort`, `sortBy`, `sortByAll`, `sortByOrder`, `splice`, `spread`,
* `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`,
* `thru`, `times`, `toArray`, `toPlainObject`, `transform`, `union`, `uniq`,
* `unshift`, `unzip`, `unzipWith`, `values`, `valuesIn`, `where`, `without`,
* `wrap`, `xor`, `zip`, `zipObject`, `zipWith`
* `countBy`, `create`, `curry`, `debounce`, `defaults`, `defaultsDeep`,
* `defer`, `delay`, `difference`, `drop`, `dropRight`, `dropRightWhile`,
* `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`,
* `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`,
* `functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`,
* `invoke`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`,
* `matchesProperty`, `memoize`, `merge`, `method`, `methodOf`, `mixin`,
* `modArgs`, `negate`, `omit`, `once`, `pairs`, `partial`, `partialRight`,
* `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`,
* `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `restParam`,
* `reverse`, `set`, `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`,
* `sortByOrder`, `splice`, `spread`, `take`, `takeRight`, `takeRightWhile`,
* `takeWhile`, `tap`, `throttle`, `thru`, `times`, `toArray`, `toPlainObject`,
* `transform`, `union`, `uniq`, `unshift`, `unzip`, `unzipWith`, `values`,
* `valuesIn`, `where`, `without`, `wrap`, `xor`, `zip`, `zipObject`, `zipWith`
*
* The wrapper methods that are **not** chainable by default are:
* `add`, `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`,
* `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`,
* `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `get`,
* `gt`, `gte`, `has`, `identity`, `includes`, `indexOf`, `inRange`, `isArguments`,
* `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`,
* `isFinite` `isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`,
* `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`,
* `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `lt`, `lte`,
* `max`, `min`, `noConflict`, `noop`, `now`, `pad`, `padLeft`, `padRight`,
* `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`,
* `runInContext`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`,
* `sortedLastIndex`, `startCase`, `startsWith`, `sum`, `template`, `trim`,
* `trimLeft`, `trimRight`, `trunc`, `unescape`, `uniqueId`, `value`, and `words`
* `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clone`, `cloneDeep`,
* `deburr`, `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`,
* `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`,
* `floor`, `get`, `gt`, `gte`, `has`, `identity`, `includes`, `indexOf`,
* `inRange`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`,
* `isEmpty`, `isEqual`, `isError`, `isFinite` `isFunction`, `isMatch`,
* `isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`,
* `isRegExp`, `isString`, `isUndefined`, `isTypedArray`, `join`, `kebabCase`,
* `last`, `lastIndexOf`, `lt`, `lte`, `max`, `min`, `noConflict`, `noop`,
* `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`, `random`, `reduce`,
* `reduceRight`, `repeat`, `result`, `round`, `runInContext`, `shift`, `size`,
* `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`, `startCase`,
* `startsWith`, `sum`, `template`, `trim`, `trimLeft`, `trimRight`, `trunc`,
* `unescape`, `uniqueId`, `value`, and `words`
*
* The wrapper method `sample` will return a wrapped value when `n` is provided,
* otherwise an unwrapped value is returned.

View File

@@ -10,16 +10,16 @@ define(['../internal/LodashWrapper'], function(LodashWrapper) {
* @example
*
* var array = [1, 2];
* var wrapper = _(array).push(3);
* var wrapped = _(array).push(3);
*
* console.log(array);
* // => [1, 2]
*
* wrapper = wrapper.commit();
* wrapped = wrapped.commit();
* console.log(array);
* // => [1, 2, 3]
*
* wrapper.last();
* wrapped.last();
* // => 3
*
* console.log(array);

31
chain/wrapperConcat.js Normal file
View File

@@ -0,0 +1,31 @@
define(['../internal/arrayConcat', '../internal/baseFlatten', '../lang/isArray', '../function/restParam', '../internal/toObject'], function(arrayConcat, baseFlatten, isArray, restParam, toObject) {
/**
* Creates a new array joining a wrapped array with any additional arrays
* and/or values.
*
* @name concat
* @memberOf _
* @category Chain
* @param {...*} [values] The values to concatenate.
* @returns {Array} Returns the new concatenated array.
* @example
*
* var array = [1];
* var wrapped = _(array).concat(2, [3], [[4]]);
*
* console.log(wrapped.value());
* // => [1, 2, 3, [4]]
*
* console.log(array);
* // => [1]
*/
var wrapperConcat = restParam(function(values) {
values = baseFlatten(values);
return this.thru(function(array) {
return arrayConcat(isArray(array) ? array : [toObject(array)], values);
});
});
return wrapperConcat;
});

View File

@@ -10,17 +10,17 @@ define(['../internal/baseLodash', '../internal/wrapperClone'], function(baseLoda
* @example
*
* var array = [1, 2];
* var wrapper = _(array).map(function(value) {
* var wrapped = _(array).map(function(value) {
* return Math.pow(value, 2);
* });
*
* var other = [3, 4];
* var otherWrapper = wrapper.plant(other);
* var otherWrapped = wrapped.plant(other);
*
* otherWrapper.value();
* otherWrapped.value();
* // => [9, 16]
*
* wrapper.value();
* wrapped.value();
* // => [1, 4]
*/
function wrapperPlant(value) {

View File

@@ -1,5 +1,8 @@
define(['../internal/LazyWrapper', '../internal/LodashWrapper', './thru'], function(LazyWrapper, LodashWrapper, thru) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* Reverses the wrapped array so the first element becomes the last, the
* second element becomes the second to last, and so on.
@@ -22,15 +25,20 @@ define(['../internal/LazyWrapper', '../internal/LodashWrapper', './thru'], funct
*/
function wrapperReverse() {
var value = this.__wrapped__;
if (value instanceof LazyWrapper) {
if (this.__actions__.length) {
value = new LazyWrapper(this);
}
return new LodashWrapper(value.reverse(), this.__chain__);
}
return this.thru(function(value) {
var interceptor = function(value) {
return value.reverse();
});
};
if (value instanceof LazyWrapper) {
var wrapped = value;
if (this.__actions__.length) {
wrapped = new LazyWrapper(this);
}
wrapped = wrapped.reverse();
wrapped.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
return new LodashWrapper(wrapped, this.__chain__);
}
return this.thru(interceptor);
}
return wrapperReverse;

View File

@@ -54,7 +54,7 @@ define(['../internal/arrayEvery', '../internal/baseCallback', '../internal/baseE
function every(collection, predicate, thisArg) {
var func = isArray(collection) ? arrayEvery : baseEvery;
if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
predicate = null;
predicate = undefined;
}
if (typeof predicate != 'function' || thisArg !== undefined) {
predicate = baseCallback(predicate, thisArg, 3);

View File

@@ -4,9 +4,9 @@ define(['../internal/baseIndexOf', '../internal/getLength', '../lang/isArray', '
var nativeMax = Math.max;
/**
* Checks if `value` is in `collection` using
* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* for equality comparisons. If `fromIndex` is negative, it is used as the offset
* Checks if `target` is in `collection` using
* [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* for equality comparisons. If `fromIndex` is negative, it's used as the offset
* from the end of `collection`.
*
* @static
@@ -38,17 +38,14 @@ define(['../internal/baseIndexOf', '../internal/getLength', '../lang/isArray', '
collection = values(collection);
length = collection.length;
}
if (!length) {
return false;
}
if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) {
fromIndex = 0;
} else {
fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
}
return (typeof collection == 'string' || !isArray(collection) && isString(collection))
? (fromIndex < length && collection.indexOf(target, fromIndex) > -1)
: (baseIndexOf(collection, target, fromIndex) > -1);
? (fromIndex <= length && collection.indexOf(target, fromIndex) > -1)
: (!!length && baseIndexOf(collection, target, fromIndex) > -1);
}
return includes;

View File

@@ -1,9 +1,12 @@
define(['../internal/baseEach', '../internal/invokePath', '../internal/isArrayLike', '../internal/isKey', '../function/restParam'], function(baseEach, invokePath, isArrayLike, isKey, restParam) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* Invokes the method at `path` of each element in `collection`, returning
* an array of the results of each invoked method. Any additional arguments
* are provided to each invoked method. If `methodName` is a function it is
* are provided to each invoked method. If `methodName` is a function it's
* invoked for, and `this` bound to, each element in `collection`.
*
* @static
@@ -29,7 +32,7 @@ define(['../internal/baseEach', '../internal/invokePath', '../internal/isArrayLi
result = isArrayLike(collection) ? Array(collection.length) : [];
baseEach(collection, function(value) {
var func = isFunc ? path : ((isProp && value != null) ? value[path] : null);
var func = isFunc ? path : ((isProp && value != null) ? value[path] : undefined);
result[++index] = func ? func.apply(value, args) : invokePath(value, path, args);
});
return result;

View File

@@ -12,7 +12,8 @@ define(['../internal/arrayReduce', '../internal/baseEach', '../internal/createRe
* `_.reduce`, `_.reduceRight`, and `_.transform`.
*
* The guarded methods are:
* `assign`, `defaults`, `includes`, `merge`, `sortByAll`, and `sortByOrder`
* `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `sortByAll`,
* and `sortByOrder`
*
* @static
* @memberOf _

View File

@@ -55,7 +55,7 @@ define(['../internal/arraySome', '../internal/baseCallback', '../internal/baseSo
function some(collection, predicate, thisArg) {
var func = isArray(collection) ? arraySome : baseSome;
if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
predicate = null;
predicate = undefined;
}
if (typeof predicate != 'function' || thisArg !== undefined) {
predicate = baseCallback(predicate, thisArg, 3);

View File

@@ -1,5 +1,8 @@
define(['../internal/baseCallback', '../internal/baseMap', '../internal/baseSortBy', '../internal/compareAscending', '../internal/isIterateeCall'], function(baseCallback, baseMap, baseSortBy, compareAscending, isIterateeCall) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* Creates an array of elements, sorted in ascending order by the results of
* running each element in a collection through `iteratee`. This method performs
@@ -53,7 +56,7 @@ define(['../internal/baseCallback', '../internal/baseMap', '../internal/baseSort
return [];
}
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
iteratee = null;
iteratee = undefined;
}
var index = -1;
iteratee = baseCallback(iteratee, thisArg, 3);

View File

@@ -1,10 +1,13 @@
define(['../internal/baseSortByOrder', '../lang/isArray', '../internal/isIterateeCall'], function(baseSortByOrder, isArray, isIterateeCall) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* This method is like `_.sortByAll` except that it allows specifying the
* sort orders of the iteratees to sort by. A truthy value in `orders` will
* sort the corresponding property name in ascending order while a falsey
* value will sort it in descending order.
* sort orders of the iteratees to sort by. If `orders` is unspecified, all
* values are sorted in ascending order. Otherwise, a value is sorted in
* ascending order if its corresponding order is "asc", and descending if "desc".
*
* If a property name is provided for an iteratee the created `_.property`
* style callback returns the property value of the given element.
@@ -18,7 +21,7 @@ define(['../internal/baseSortByOrder', '../lang/isArray', '../internal/isIterate
* @category Collection
* @param {Array|Object|string} collection The collection to iterate over.
* @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
* @param {boolean[]} orders The sort orders of `iteratees`.
* @param {boolean[]} [orders] The sort orders of `iteratees`.
* @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`.
* @returns {Array} Returns the new sorted array.
* @example
@@ -31,7 +34,7 @@ define(['../internal/baseSortByOrder', '../lang/isArray', '../internal/isIterate
* ];
*
* // sort by `user` in ascending order and by `age` in descending order
* _.map(_.sortByOrder(users, ['user', 'age'], [true, false]), _.values);
* _.map(_.sortByOrder(users, ['user', 'age'], ['asc', 'desc']), _.values);
* // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]
*/
function sortByOrder(collection, iteratees, orders, guard) {
@@ -39,7 +42,7 @@ define(['../internal/baseSortByOrder', '../lang/isArray', '../internal/isIterate
return [];
}
if (guard && isIterateeCall(iteratees, orders, guard)) {
orders = null;
orders = undefined;
}
if (!isArray(iteratees)) {
iteratees = iteratees == null ? [] : [iteratees];

View File

@@ -1,4 +1,4 @@
define(['./function/after', './function/ary', './function/backflow', './function/before', './function/bind', './function/bindAll', './function/bindKey', './function/compose', './function/curry', './function/curryRight', './function/debounce', './function/defer', './function/delay', './function/flow', './function/flowRight', './function/memoize', './function/negate', './function/once', './function/partial', './function/partialRight', './function/rearg', './function/restParam', './function/spread', './function/throttle', './function/wrap'], function(after, ary, backflow, before, bind, bindAll, bindKey, compose, curry, curryRight, debounce, defer, delay, flow, flowRight, memoize, negate, once, partial, partialRight, rearg, restParam, spread, throttle, wrap) {
define(['./function/after', './function/ary', './function/backflow', './function/before', './function/bind', './function/bindAll', './function/bindKey', './function/compose', './function/curry', './function/curryRight', './function/debounce', './function/defer', './function/delay', './function/flow', './function/flowRight', './function/memoize', './function/modArgs', './function/negate', './function/once', './function/partial', './function/partialRight', './function/rearg', './function/restParam', './function/spread', './function/throttle', './function/wrap'], function(after, ary, backflow, before, bind, bindAll, bindKey, compose, curry, curryRight, debounce, defer, delay, flow, flowRight, memoize, modArgs, negate, once, partial, partialRight, rearg, restParam, spread, throttle, wrap) {
return {
'after': after,
'ary': ary,
@@ -16,6 +16,7 @@ define(['./function/after', './function/ary', './function/backflow', './function
'flow': flow,
'flowRight': flowRight,
'memoize': memoize,
'modArgs': modArgs,
'negate': negate,
'once': once,
'partial': partial,

View File

@@ -8,7 +8,7 @@ define(['../internal/root'], function(root) {
/**
* The opposite of `_.before`; this method creates a function that invokes
* `func` once it is called `n` or more times.
* `func` once it's called `n` or more times.
*
* @static
* @memberOf _

View File

@@ -1,5 +1,8 @@
define(['../internal/createWrapper', '../internal/isIterateeCall'], function(createWrapper, isIterateeCall) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used to compose bitmasks for wrapper metadata. */
var ARY_FLAG = 128;
@@ -24,10 +27,10 @@ define(['../internal/createWrapper', '../internal/isIterateeCall'], function(cre
*/
function ary(func, n, guard) {
if (guard && isIterateeCall(func, n, guard)) {
n = null;
n = undefined;
}
n = (func && n == null) ? func.length : nativeMax(+n || 0, 0);
return createWrapper(func, ARY_FLAG, null, null, null, null, n);
return createWrapper(func, ARY_FLAG, undefined, undefined, undefined, undefined, n);
}
return ary;

View File

@@ -1,11 +1,14 @@
define([], function() {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**
* Creates a function that invokes `func`, with the `this` binding and arguments
* of the created function, while it is called less than `n` times. Subsequent
* of the created function, while it's called less than `n` times. Subsequent
* calls to the created function return the result of the last `func` invocation.
*
* @static
@@ -35,7 +38,7 @@ define([], function() {
result = func.apply(this, arguments);
}
if (n <= 1) {
func = null;
func = undefined;
}
return result;
};

View File

@@ -34,7 +34,7 @@ define(['../lang/isObject', '../date/now'], function(isObject, now) {
* @param {boolean} [options.leading=false] Specify invoking on the leading
* edge of the timeout.
* @param {number} [options.maxWait] The maximum time `func` is allowed to be
* delayed before it is invoked.
* delayed before it's invoked.
* @param {boolean} [options.trailing=true] Specify invoking on the trailing
* edge of the timeout.
* @returns {Function} Returns the new debounced function.
@@ -92,9 +92,9 @@ define(['../lang/isObject', '../date/now'], function(isObject, now) {
var leading = true;
trailing = false;
} else if (isObject(options)) {
leading = options.leading;
leading = !!options.leading;
maxWait = 'maxWait' in options && nativeMax(+options.maxWait || 0, wait);
trailing = 'trailing' in options ? options.trailing : trailing;
trailing = 'trailing' in options ? !!options.trailing : trailing;
}
function cancel() {
@@ -104,41 +104,35 @@ define(['../lang/isObject', '../date/now'], function(isObject, now) {
if (maxTimeoutId) {
clearTimeout(maxTimeoutId);
}
lastCalled = 0;
maxTimeoutId = timeoutId = trailingCall = undefined;
}
function complete(isCalled, id) {
if (id) {
clearTimeout(id);
}
maxTimeoutId = timeoutId = trailingCall = undefined;
if (isCalled) {
lastCalled = now();
result = func.apply(thisArg, args);
if (!timeoutId && !maxTimeoutId) {
args = thisArg = undefined;
}
}
}
function delayed() {
var remaining = wait - (now() - stamp);
if (remaining <= 0 || remaining > wait) {
if (maxTimeoutId) {
clearTimeout(maxTimeoutId);
}
var isCalled = trailingCall;
maxTimeoutId = timeoutId = trailingCall = undefined;
if (isCalled) {
lastCalled = now();
result = func.apply(thisArg, args);
if (!timeoutId && !maxTimeoutId) {
args = thisArg = null;
}
}
complete(trailingCall, maxTimeoutId);
} else {
timeoutId = setTimeout(delayed, remaining);
}
}
function maxDelayed() {
if (timeoutId) {
clearTimeout(timeoutId);
}
maxTimeoutId = timeoutId = trailingCall = undefined;
if (trailing || (maxWait !== wait)) {
lastCalled = now();
result = func.apply(thisArg, args);
if (!timeoutId && !maxTimeoutId) {
args = thisArg = null;
}
}
complete(trailing, timeoutId);
}
function debounced() {
@@ -178,7 +172,7 @@ define(['../lang/isObject', '../date/now'], function(isObject, now) {
result = func.apply(thisArg, args);
}
if (isCalled && !timeoutId && !maxTimeoutId) {
args = thisArg = null;
args = thisArg = undefined;
}
return result;
}

View File

@@ -2,7 +2,7 @@ define(['../internal/baseDelay', './restParam'], function(baseDelay, restParam)
/**
* Defers invoking the `func` until the current call stack has cleared. Any
* additional arguments are provided to `func` when it is invoked.
* additional arguments are provided to `func` when it's invoked.
*
* @static
* @memberOf _

View File

@@ -2,7 +2,7 @@ define(['../internal/baseDelay', './restParam'], function(baseDelay, restParam)
/**
* Invokes `func` after `wait` milliseconds. Any additional arguments are
* provided to `func` when it is invoked.
* provided to `func` when it's invoked.
*
* @static
* @memberOf _

View File

@@ -13,7 +13,7 @@ define(['../internal/MapCache'], function(MapCache) {
*
* **Note:** The cache is exposed as the `cache` property on the memoized
* function. Its creation may be customized by replacing the `_.memoize.Cache`
* constructor with one whose instances implement the [`Map`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-properties-of-the-map-prototype-object)
* constructor with one whose instances implement the [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object)
* method interface of `get`, `has`, and `set`.
*
* @static

56
function/modArgs.js Normal file
View File

@@ -0,0 +1,56 @@
define(['../internal/arrayEvery', '../internal/baseFlatten', '../internal/baseIsFunction', './restParam'], function(arrayEvery, baseFlatten, baseIsFunction, restParam) {
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/* Native method references for those with the same name as other `lodash` methods. */
var nativeMin = Math.min;
/**
* Creates a function that runs each argument through a corresponding
* transform function.
*
* @static
* @memberOf _
* @category Function
* @param {Function} func The function to wrap.
* @param {...(Function|Function[])} [transforms] The functions to transform
* arguments, specified as individual functions or arrays of functions.
* @returns {Function} Returns the new function.
* @example
*
* function doubled(n) {
* return n * 2;
* }
*
* function square(n) {
* return n * n;
* }
*
* var modded = _.modArgs(function(x, y) {
* return [x, y];
* }, square, doubled);
*
* modded(1, 2);
* // => [1, 4]
*
* modded(5, 10);
* // => [25, 20]
*/
var modArgs = restParam(function(func, transforms) {
transforms = baseFlatten(transforms);
if (typeof func != 'function' || !arrayEvery(transforms, baseIsFunction)) {
throw new TypeError(FUNC_ERROR_TEXT);
}
var length = transforms.length;
return restParam(function(args) {
var index = nativeMin(args.length, length);
while (index--) {
args[index] = transforms[index](args[index]);
}
return func.apply(this, args);
});
});
return modArgs;
});

View File

@@ -1,5 +1,8 @@
define(['../internal/baseFlatten', '../internal/createWrapper', './restParam'], function(baseFlatten, createWrapper, restParam) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used to compose bitmasks for wrapper metadata. */
var REARG_FLAG = 256;
@@ -32,7 +35,7 @@ define(['../internal/baseFlatten', '../internal/createWrapper', './restParam'],
* // => [3, 6, 9]
*/
var rearg = restParam(function(func, indexes) {
return createWrapper(func, REARG_FLAG, null, null, null, baseFlatten(indexes));
return createWrapper(func, REARG_FLAG, undefined, undefined, undefined, baseFlatten(indexes));
});
return rearg;

View File

@@ -13,7 +13,7 @@ define([], function() {
* Creates a function that invokes `func` with the `this` binding of the
* created function and arguments from `start` and beyond provided as an array.
*
* **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters).
* **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/Web/JavaScript/Reference/Functions/rest_parameters).
*
* @static
* @memberOf _

View File

@@ -7,7 +7,7 @@ define([], function() {
* Creates a function that invokes `func` with the `this` binding of the created
* function and an array of arguments much like [`Function#apply`](https://es5.github.io/#x15.3.4.3).
*
* **Note:** This method is based on the [spread operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator).
* **Note:** This method is based on the [spread operator](https://developer.mozilla.org/Web/JavaScript/Reference/Operators/Spread_operator).
*
* @static
* @memberOf _

View File

@@ -3,13 +3,6 @@ define(['./debounce', '../lang/isObject'], function(debounce, isObject) {
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/** Used as an internal `_.debounce` options object by `_.throttle`. */
var debounceOptions = {
'leading': false,
'maxWait': 0,
'trailing': false
};
/**
* Creates a throttled function that only invokes `func` at most once per
* every `wait` milliseconds. The throttled function comes with a `cancel`
@@ -62,10 +55,7 @@ define(['./debounce', '../lang/isObject'], function(debounce, isObject) {
leading = 'leading' in options ? !!options.leading : leading;
trailing = 'trailing' in options ? !!options.trailing : trailing;
}
debounceOptions.leading = leading;
debounceOptions.maxWait = +wait;
debounceOptions.trailing = trailing;
return debounce(func, wait, debounceOptions);
return debounce(func, wait, { 'leading': leading, 'maxWait': +wait, 'trailing': trailing });
}
return throttle;

View File

@@ -1,5 +1,8 @@
define(['../internal/createWrapper', '../utility/identity'], function(createWrapper, identity) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used to compose bitmasks for wrapper metadata. */
var PARTIAL_FLAG = 32;
@@ -26,7 +29,7 @@ define(['../internal/createWrapper', '../utility/identity'], function(createWrap
*/
function wrap(value, wrapper) {
wrapper = wrapper == null ? identity : wrapper;
return createWrapper(wrapper, PARTIAL_FLAG, null, [value], []);
return createWrapper(wrapper, PARTIAL_FLAG, undefined, [value], []);
}
return wrap;

View File

@@ -11,13 +11,12 @@ define(['./baseCreate', './baseLodash'], function(baseCreate, baseLodash) {
*/
function LazyWrapper(value) {
this.__wrapped__ = value;
this.__actions__ = null;
this.__actions__ = [];
this.__dir__ = 1;
this.__dropCount__ = 0;
this.__filtered__ = false;
this.__iteratees__ = null;
this.__iteratees__ = [];
this.__takeCount__ = POSITIVE_INFINITY;
this.__views__ = null;
this.__views__ = [];
}
LazyWrapper.prototype = baseCreate(baseLodash.prototype);

28
internal/arrayConcat.js Normal file
View File

@@ -0,0 +1,28 @@
define([], function() {
/**
* Creates a new array joining `array` with `other`.
*
* @private
* @param {Array} array The array to join.
* @param {Array} other The other array to join.
* @returns {Array} Returns the new concatenated array.
*/
function arrayConcat(array, other) {
var index = -1,
length = array.length,
othIndex = -1,
othLength = other.length,
result = Array(length + othLength);
while (++index < length) {
result[index] = array[index];
}
while (++othIndex < othLength) {
result[index++] = other[othIndex];
}
return result;
}
return arrayConcat;
});

23
internal/arrayPush.js Normal file
View File

@@ -0,0 +1,23 @@
define([], function() {
/**
* Appends the elements of `values` to `array`.
*
* @private
* @param {Array} array The array to modify.
* @param {Array} values The values to append.
* @returns {Array} Returns `array`.
*/
function arrayPush(array, values) {
var index = -1,
length = values.length,
offset = array.length;
while (++index < length) {
array[offset + index] = values[index];
}
return array;
}
return arrayPush;
});

View File

@@ -1,18 +1,20 @@
define([], function() {
/**
* A specialized version of `_.sum` for arrays without support for iteratees.
* A specialized version of `_.sum` for arrays without support for callback
* shorthands and `this` binding..
*
* @private
* @param {Array} array The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {number} Returns the sum.
*/
function arraySum(array) {
function arraySum(array, iteratee) {
var length = array.length,
result = 0;
while (length--) {
result += +array[length] || 0;
result += +iteratee(array[length]) || 0;
}
return result;
}

View File

@@ -48,7 +48,7 @@ define(['./arrayCopy', './arrayEach', './baseAssign', './baseForOwn', './initClo
var objectProto = Object.prototype;
/**
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
* of values.
*/
var objToString = objectProto.toString;
@@ -99,7 +99,7 @@ define(['./arrayCopy', './arrayEach', './baseAssign', './baseForOwn', './initClo
: (object ? value : {});
}
}
// Check for circular references and return corresponding clone.
// Check for circular references and return its corresponding clone.
stackA || (stackA = []);
stackB || (stackB = []);

View File

@@ -1,5 +1,8 @@
define(['../lang/isObject'], function(isObject) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* The base implementation of `_.create` without support for assigning
* properties to the created object.
@@ -14,7 +17,7 @@ define(['../lang/isObject'], function(isObject) {
if (isObject(prototype)) {
object.prototype = prototype;
var result = new object;
object.prototype = null;
object.prototype = undefined;
}
return result || {};
};

View File

@@ -1,5 +1,8 @@
define(['./baseIndexOf', './cacheIndexOf', './createCache'], function(baseIndexOf, cacheIndexOf, createCache) {
/** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200;
/**
* The base implementation of `_.difference` which accepts a single array
* of values to exclude.
@@ -19,7 +22,7 @@ define(['./baseIndexOf', './cacheIndexOf', './createCache'], function(baseIndexO
var index = -1,
indexOf = baseIndexOf,
isCommon = true,
cache = (isCommon && values.length >= 200) ? createCache(values) : null,
cache = (isCommon && values.length >= LARGE_ARRAY_SIZE) ? createCache(values) : null,
valuesLength = values.length;
if (cache) {

View File

@@ -1,4 +1,4 @@
define(['../lang/isArguments', '../lang/isArray', './isArrayLike', './isObjectLike'], function(isArguments, isArray, isArrayLike, isObjectLike) {
define(['./arrayPush', '../lang/isArguments', '../lang/isArray', './isArrayLike', './isObjectLike'], function(arrayPush, isArguments, isArray, isArrayLike, isObjectLike) {
/**
* The base implementation of `_.flatten` with added support for restricting
@@ -8,13 +8,14 @@ define(['../lang/isArguments', '../lang/isArray', './isArrayLike', './isObjectLi
* @param {Array} array The array to flatten.
* @param {boolean} [isDeep] Specify a deep flatten.
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
* @param {Array} [result=[]] The initial result value.
* @returns {Array} Returns the new flattened array.
*/
function baseFlatten(array, isDeep, isStrict) {
function baseFlatten(array, isDeep, isStrict, result) {
result || (result = []);
var index = -1,
length = array.length,
resIndex = -1,
result = [];
length = array.length;
while (++index < length) {
var value = array[index];
@@ -22,16 +23,12 @@ define(['../lang/isArguments', '../lang/isArray', './isArrayLike', './isObjectLi
(isStrict || isArray(value) || isArguments(value))) {
if (isDeep) {
// Recursively flatten arrays (susceptible to call stack limits).
value = baseFlatten(value, isDeep, isStrict);
}
var valIndex = -1,
valLength = value.length;
while (++valIndex < valLength) {
result[++resIndex] = value[valIndex];
baseFlatten(value, isDeep, isStrict, result);
} else {
arrayPush(result, value);
}
} else if (!isStrict) {
result[++resIndex] = value;
result[result.length] = value;
}
}
return result;

View File

@@ -12,7 +12,7 @@ define(['./equalArrays', './equalByTag', './equalObjects', '../lang/isArray', '.
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
* of values.
*/
var objToString = objectProto.toString;

View File

@@ -10,7 +10,7 @@ define(['./arrayEach', './baseMergeDeep', '../lang/isArray', './isArrayLike', '.
* @private
* @param {Object} object The destination object.
* @param {Object} source The source object.
* @param {Function} [customizer] The function to customize merging properties.
* @param {Function} [customizer] The function to customize merged values.
* @param {Array} [stackA=[]] Tracks traversed source objects.
* @param {Array} [stackB=[]] Associates values with source counterparts.
* @returns {Object} Returns `object`.
@@ -20,7 +20,7 @@ define(['./arrayEach', './baseMergeDeep', '../lang/isArray', './isArrayLike', '.
return object;
}
var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)),
props = isSrcArr ? null : keys(source);
props = isSrcArr ? undefined : keys(source);
arrayEach(props || source, function(srcValue, key) {
if (props) {

View File

@@ -13,7 +13,7 @@ define(['./arrayCopy', '../lang/isArguments', '../lang/isArray', './isArrayLike'
* @param {Object} source The source object.
* @param {string} key The key of the value to merge.
* @param {Function} mergeFunc The function to merge values.
* @param {Function} [customizer] The function to customize merging properties.
* @param {Function} [customizer] The function to customize merged values.
* @param {Array} [stackA=[]] Tracks traversed source objects.
* @param {Array} [stackB=[]] Associates values with source counterparts.
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.

View File

@@ -1,10 +1,8 @@
define([], function() {
/** Native method references. */
var floor = Math.floor;
/* Native method references for those with the same name as other `lodash` methods. */
var nativeRandom = Math.random;
var nativeFloor = Math.floor,
nativeRandom = Math.random;
/**
* The base implementation of `_.random` without support for argument juggling
@@ -16,7 +14,7 @@ define([], function() {
* @returns {number} Returns the random number.
*/
function baseRandom(min, max) {
return min + floor(nativeRandom() * (max - min + 1));
return min + nativeFloor(nativeRandom() * (max - min + 1));
}
return baseRandom;

View File

@@ -9,9 +9,6 @@ define([], function() {
* @returns {string} Returns the string.
*/
function baseToString(value) {
if (typeof value == 'string') {
return value;
}
return value == null ? '' : (value + '');
}

View File

@@ -1,5 +1,8 @@
define(['./baseIndexOf', './cacheIndexOf', './createCache'], function(baseIndexOf, cacheIndexOf, createCache) {
/** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200;
/**
* The base implementation of `_.uniq` without support for callback shorthands
* and `this` binding.
@@ -7,14 +10,14 @@ define(['./baseIndexOf', './cacheIndexOf', './createCache'], function(baseIndexO
* @private
* @param {Array} array The array to inspect.
* @param {Function} [iteratee] The function invoked per iteration.
* @returns {Array} Returns the new duplicate-value-free array.
* @returns {Array} Returns the new duplicate free array.
*/
function baseUniq(array, iteratee) {
var index = -1,
indexOf = baseIndexOf,
length = array.length,
isCommon = true,
isLarge = isCommon && length >= 200,
isLarge = isCommon && length >= LARGE_ARRAY_SIZE,
seen = isLarge ? createCache() : null,
result = [];

View File

@@ -1,10 +1,4 @@
define(['./LazyWrapper'], function(LazyWrapper) {
/** Used for native method references. */
var arrayProto = Array.prototype;
/** Native method references. */
var push = arrayProto.push;
define(['./LazyWrapper', './arrayPush'], function(LazyWrapper, arrayPush) {
/**
* The base implementation of `wrapperValue` which returns the result of
@@ -25,11 +19,8 @@ define(['./LazyWrapper'], function(LazyWrapper) {
length = actions.length;
while (++index < length) {
var args = [result],
action = actions[index];
push.apply(args, action.args);
result = action.func.apply(action.thisArg, args);
var action = actions[index];
result = action.func.apply(action.thisArg, arrayPush([result], action.args));
}
return result;
}

View File

@@ -3,11 +3,9 @@ define([], function() {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Native method references. */
var floor = Math.floor;
/* Native method references for those with the same name as other `lodash` methods. */
var nativeMin = Math.min;
var nativeFloor = Math.floor,
nativeMin = Math.min;
/** Used as references for the maximum length and index of an array. */
var MAX_ARRAY_LENGTH = 4294967295,
@@ -36,7 +34,7 @@ define([], function() {
valIsUndef = value === undefined;
while (low < high) {
var mid = floor((low + high) / 2),
var mid = nativeFloor((low + high) / 2),
computed = iteratee(array[mid]),
isDef = computed !== undefined,
isReflexive = computed === computed;

View File

@@ -1,25 +1,8 @@
define(['../utility/constant', './getNative', './root'], function(constant, getNative, root) {
define(['./root'], function(root) {
/** Native method references. */
var ArrayBuffer = getNative(root, 'ArrayBuffer'),
bufferSlice = getNative(ArrayBuffer && new ArrayBuffer(0), 'slice'),
floor = Math.floor,
Uint8Array = getNative(root, 'Uint8Array');
/** Used to clone array buffers. */
var Float64Array = (function() {
// Safari 5 errors when using an array buffer to initialize a typed array
// where the array buffer's `byteLength` is not a multiple of the typed
// array's `BYTES_PER_ELEMENT`.
try {
var func = getNative(root, 'Float64Array'),
result = new func(new ArrayBuffer(10), 0, 1) && func;
} catch(e) {}
return result || null;
}());
/** Used as the size, in bytes, of each `Float64Array` element. */
var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0;
var ArrayBuffer = root.ArrayBuffer,
Uint8Array = root.Uint8Array;
/**
* Creates a clone of the given array buffer.
@@ -29,26 +12,11 @@ define(['../utility/constant', './getNative', './root'], function(constant, getN
* @returns {ArrayBuffer} Returns the cloned array buffer.
*/
function bufferClone(buffer) {
return bufferSlice.call(buffer, 0);
}
if (!bufferSlice) {
// PhantomJS has `ArrayBuffer` and `Uint8Array` but not `Float64Array`.
bufferClone = !(ArrayBuffer && Uint8Array) ? constant(null) : function(buffer) {
var byteLength = buffer.byteLength,
floatLength = Float64Array ? floor(byteLength / FLOAT64_BYTES_PER_ELEMENT) : 0,
offset = floatLength * FLOAT64_BYTES_PER_ELEMENT,
result = new ArrayBuffer(byteLength);
var result = new ArrayBuffer(buffer.byteLength),
view = new Uint8Array(result);
if (floatLength) {
var view = new Float64Array(result, 0, floatLength);
view.set(new Float64Array(buffer, 0, floatLength));
}
if (byteLength != offset) {
view = new Uint8Array(result, offset);
view.set(new Uint8Array(buffer, offset));
}
return result;
};
view.set(new Uint8Array(buffer));
return result;
}
return bufferClone;

View File

@@ -5,8 +5,8 @@ define(['./baseCompareAscending'], function(baseCompareAscending) {
* sort them in ascending order.
*
* @private
* @param {Object} object The object to compare to `other`.
* @param {Object} other The object to compare to `object`.
* @param {Object} object The object to compare.
* @param {Object} other The other object to compare.
* @returns {number} Returns the sort order indicator for `object`.
*/
function compareAscending(object, other) {

View File

@@ -1,16 +1,16 @@
define(['./baseCompareAscending'], function(baseCompareAscending) {
/**
* Used by `_.sortByOrder` to compare multiple properties of each element
* in a collection and stable sort them in the following order:
* Used by `_.sortByOrder` to compare multiple properties of a value to another
* and stable sort them.
*
* If `orders` is unspecified, sort in ascending order for all properties.
* Otherwise, for each property, sort in ascending order if its corresponding value in
* orders is true, and descending order if false.
* If `orders` is unspecified, all valuess are sorted in ascending order. Otherwise,
* a value is sorted in ascending order if its corresponding order is "asc", and
* descending if "desc".
*
* @private
* @param {Object} object The object to compare to `other`.
* @param {Object} other The object to compare to `object`.
* @param {Object} object The object to compare.
* @param {Object} other The other object to compare.
* @param {boolean[]} orders The order to sort by for each property.
* @returns {number} Returns the sort order indicator for `object`.
*/
@@ -27,7 +27,8 @@ define(['./baseCompareAscending'], function(baseCompareAscending) {
if (index >= ordersLength) {
return result;
}
return result * (orders[index] ? 1 : -1);
var order = orders[index];
return result * ((order === 'asc' || order === true) ? 1 : -1);
}
}
// Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications

View File

@@ -19,7 +19,7 @@ define([], function() {
argsLength = nativeMax(args.length - holdersLength, 0),
leftIndex = -1,
leftLength = partials.length,
result = Array(argsLength + leftLength);
result = Array(leftLength + argsLength);
while (++leftIndex < leftLength) {
result[leftIndex] = partials[leftIndex];

View File

@@ -1,12 +1,7 @@
define(['./baseCallback', './baseEach', '../lang/isArray'], function(baseCallback, baseEach, isArray) {
/**
* Creates a function that aggregates a collection, creating an accumulator
* object composed from the results of running each element in the collection
* through an iteratee.
*
* **Note:** This function is used to create `_.countBy`, `_.groupBy`, `_.indexBy`,
* and `_.partition`.
* Creates a `_.countBy`, `_.groupBy`, `_.indexBy`, or `_.partition` function.
*
* @private
* @param {Function} setter The function to set keys and values of the accumulator object.

View File

@@ -4,10 +4,7 @@ define(['./bindCallback', './isIterateeCall', '../function/restParam'], function
var undefined;
/**
* Creates a function that assigns properties of source object(s) to a given
* destination object.
*
* **Note:** This function is used to create `_.assign`, `_.defaults`, and `_.merge`.
* Creates a `_.assign`, `_.defaults`, or `_.merge` function.
*
* @private
* @param {Function} assigner The function to assign values.

View File

@@ -1,4 +1,4 @@
define(['./SetCache', '../utility/constant', './getNative', './root'], function(SetCache, constant, getNative, root) {
define(['./SetCache', './getNative', './root'], function(SetCache, getNative, root) {
/** Native method references. */
var Set = getNative(root, 'Set');
@@ -13,9 +13,9 @@ define(['./SetCache', '../utility/constant', './getNative', './root'], function(
* @param {Array} [values] The values to cache.
* @returns {null|Object} Returns the new cache object if `Set` is supported, else `null`.
*/
var createCache = !(nativeCreate && Set) ? constant(null) : function(values) {
return new SetCache(values);
};
function createCache(values) {
return (nativeCreate && Set) ? new SetCache(values) : null;
}
return createCache;
});

View File

@@ -11,7 +11,7 @@ define(['./baseCreate', '../lang/isObject'], function(baseCreate, isObject) {
function createCtorWrapper(Ctor) {
return function() {
// Use a `switch` statement to work with class constructors.
// See https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-function-objects-call-thisargument-argumentslist
// See http://ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
// for more details.
var args = arguments;
switch (args.length) {
@@ -21,6 +21,8 @@ define(['./baseCreate', '../lang/isObject'], function(baseCreate, isObject) {
case 3: return new Ctor(args[0], args[1], args[2]);
case 4: return new Ctor(args[0], args[1], args[2], args[3]);
case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
}
var thisBinding = baseCreate(Ctor.prototype),
result = Ctor.apply(thisBinding, args);

View File

@@ -1,5 +1,8 @@
define(['./createWrapper', './isIterateeCall'], function(createWrapper, isIterateeCall) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* Creates a `_.curry` or `_.curryRight` function.
*
@@ -10,9 +13,9 @@ define(['./createWrapper', './isIterateeCall'], function(createWrapper, isIterat
function createCurry(flag) {
function curryFunc(func, arity, guard) {
if (guard && isIterateeCall(func, arity, guard)) {
arity = null;
arity = undefined;
}
var result = createWrapper(func, flag, null, null, null, null, null, arity);
var result = createWrapper(func, flag, undefined, undefined, undefined, undefined, undefined, arity);
result.placeholder = curryFunc.placeholder;
return result;
}

View File

@@ -0,0 +1,26 @@
define(['../function/restParam'], function(restParam) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* Creates a `_.defaults` or `_.defaultsDeep` function.
*
* @private
* @param {Function} assigner The function to assign values.
* @param {Function} customizer The function to customize assigned values.
* @returns {Function} Returns the new defaults function.
*/
function createDefaults(assigner, customizer) {
return restParam(function(args) {
var object = args[0];
if (object == null) {
return object;
}
args.push(customizer);
return assigner.apply(undefined, args);
});
}
return createDefaults;
});

View File

@@ -1,4 +1,7 @@
define(['./arrayExtremum', './baseCallback', './baseExtremum', './isIterateeCall', './toIterable'], function(arrayExtremum, baseCallback, baseExtremum, isIterateeCall, toIterable) {
define(['./arrayExtremum', './baseCallback', './baseExtremum', '../lang/isArray', './isIterateeCall', './toIterable'], function(arrayExtremum, baseCallback, baseExtremum, isArray, isIterateeCall, toIterable) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* Creates a `_.max` or `_.min` function.
@@ -11,11 +14,11 @@ define(['./arrayExtremum', './baseCallback', './baseExtremum', './isIterateeCall
function createExtremum(comparator, exValue) {
return function(collection, iteratee, thisArg) {
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
iteratee = null;
iteratee = undefined;
}
iteratee = baseCallback(iteratee, thisArg, 3);
if (iteratee.length == 1) {
collection = toIterable(collection);
collection = isArray(collection) ? collection : toIterable(collection);
var result = arrayExtremum(collection, iteratee, comparator, exValue);
if (!(collection.length && result === exValue)) {
return result;

View File

@@ -1,11 +1,17 @@
define(['./LodashWrapper', './getData', './getFuncName', '../lang/isArray', './isLaziable'], function(LodashWrapper, getData, getFuncName, isArray, isLaziable) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used to compose bitmasks for wrapper metadata. */
var CURRY_FLAG = 8,
PARTIAL_FLAG = 32,
ARY_FLAG = 128,
REARG_FLAG = 256;
/** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200;
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
@@ -30,7 +36,7 @@ define(['./LodashWrapper', './getData', './getFuncName', '../lang/isArray', './i
throw new TypeError(FUNC_ERROR_TEXT);
}
if (!wrapper && LodashWrapper.prototype.thru && getFuncName(func) == 'wrapper') {
wrapper = new LodashWrapper([]);
wrapper = new LodashWrapper([], true);
}
}
index = wrapper ? -1 : length;
@@ -38,7 +44,7 @@ define(['./LodashWrapper', './getData', './getFuncName', '../lang/isArray', './i
func = funcs[index];
var funcName = getFuncName(func),
data = funcName == 'wrapper' ? getData(func) : null;
data = funcName == 'wrapper' ? getData(func) : undefined;
if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) {
wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
@@ -47,12 +53,14 @@ define(['./LodashWrapper', './getData', './getFuncName', '../lang/isArray', './i
}
}
return function() {
var args = arguments;
if (wrapper && args.length == 1 && isArray(args[0])) {
return wrapper.plant(args[0]).value();
var args = arguments,
value = args[0];
if (wrapper && args.length == 1 && isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
return wrapper.plant(value).value();
}
var index = 0,
result = length ? funcs[index].apply(this, args) : args[0];
result = length ? funcs[index].apply(this, args) : value;
while (++index < length) {
result = funcs[index].call(this, result);

View File

@@ -40,7 +40,7 @@ define(['./arrayCopy', './composeArgs', './composeArgsRight', './createCtorWrapp
isCurry = bitmask & CURRY_FLAG,
isCurryBound = bitmask & CURRY_BOUND_FLAG,
isCurryRight = bitmask & CURRY_RIGHT_FLAG,
Ctor = isBindKey ? null : createCtorWrapper(func);
Ctor = isBindKey ? undefined : createCtorWrapper(func);
function wrapper() {
// Avoid `arguments` object use disqualifying optimizations by
@@ -64,12 +64,12 @@ define(['./arrayCopy', './composeArgs', './composeArgsRight', './createCtorWrapp
length -= argsHolders.length;
if (length < arity) {
var newArgPos = argPos ? arrayCopy(argPos) : null,
var newArgPos = argPos ? arrayCopy(argPos) : undefined,
newArity = nativeMax(arity - length, 0),
newsHolders = isCurry ? argsHolders : null,
newHoldersRight = isCurry ? null : argsHolders,
newPartials = isCurry ? args : null,
newPartialsRight = isCurry ? null : args;
newsHolders = isCurry ? argsHolders : undefined,
newHoldersRight = isCurry ? undefined : argsHolders,
newPartials = isCurry ? args : undefined,
newPartialsRight = isCurry ? undefined : args;
bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG);
bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG);

View File

@@ -1,10 +1,8 @@
define(['../string/repeat', './root'], function(repeat, root) {
/** Native method references. */
var ceil = Math.ceil;
/* Native method references for those with the same name as other `lodash` methods. */
var nativeIsFinite = root.isFinite;
var nativeCeil = Math.ceil,
nativeIsFinite = root.isFinite;
/**
* Creates the padding required for `string` based on the given `length`.
@@ -25,7 +23,7 @@ define(['../string/repeat', './root'], function(repeat, root) {
}
var padLength = length - strLength;
chars = chars == null ? ' ' : (chars + '');
return repeat(chars, ceil(padLength / chars.length)).slice(0, padLength);
return repeat(chars, nativeCeil(padLength / chars.length)).slice(0, padLength);
}
return createPadding;

View File

@@ -1,5 +1,8 @@
define(['./createWrapper', './replaceHolders', '../function/restParam'], function(createWrapper, replaceHolders, restParam) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* Creates a `_.partial` or `_.partialRight` function.
*
@@ -10,7 +13,7 @@ define(['./createWrapper', './replaceHolders', '../function/restParam'], functio
function createPartial(flag) {
var partialFunc = restParam(function(func, partials) {
var holders = replaceHolders(partials, partialFunc.placeholder);
return createWrapper(func, flag, null, partials, holders);
return createWrapper(func, flag, undefined, partials, holders);
});
return partialFunc;
}

View File

@@ -26,7 +26,7 @@ define(['./createCtorWrapper', './root'], function(createCtorWrapper, root) {
argsLength = arguments.length,
leftIndex = -1,
leftLength = partials.length,
args = Array(argsLength + leftLength);
args = Array(leftLength + argsLength);
while (++leftIndex < leftLength) {
args[leftIndex] = partials[leftIndex];

29
internal/createRound.js Normal file
View File

@@ -0,0 +1,29 @@
define([], function() {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Native method references. */
var pow = Math.pow;
/**
* Creates a `_.ceil`, `_.floor`, or `_.round` function.
*
* @private
* @param {string} methodName The name of the `Math` method to use when rounding.
* @returns {Function} Returns the new round function.
*/
function createRound(methodName) {
var func = Math[methodName];
return function(number, precision) {
precision = precision === undefined ? 0 : (+precision || 0);
if (precision) {
precision = pow(10, precision);
return func(number * precision) / precision;
}
return func(number);
};
}
return createRound;
});

View File

@@ -48,16 +48,16 @@ define(['./baseSetData', './createBindWrapper', './createHybridWrapper', './crea
var length = partials ? partials.length : 0;
if (!length) {
bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG);
partials = holders = null;
partials = holders = undefined;
}
length -= (holders ? holders.length : 0);
if (bitmask & PARTIAL_RIGHT_FLAG) {
var partialsRight = partials,
holdersRight = holders;
partials = holders = null;
partials = holders = undefined;
}
var data = isBindKey ? null : getData(func),
var data = isBindKey ? undefined : getData(func),
newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];
if (data) {

View File

@@ -16,7 +16,7 @@ define([], function() {
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
*
* @private
* @param {Object} value The object to compare.
* @param {Object} object The object to compare.
* @param {Object} other The other object to compare.
* @param {string} tag The `toStringTag` of the objects to compare.
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.

View File

@@ -0,0 +1,41 @@
define([], function() {
/** Used to escape characters for inclusion in compiled regexes. */
var regexpEscapes = {
'0': 'x30', '1': 'x31', '2': 'x32', '3': 'x33', '4': 'x34',
'5': 'x35', '6': 'x36', '7': 'x37', '8': 'x38', '9': 'x39',
'A': 'x41', 'B': 'x42', 'C': 'x43', 'D': 'x44', 'E': 'x45', 'F': 'x46',
'a': 'x61', 'b': 'x62', 'c': 'x63', 'd': 'x64', 'e': 'x65', 'f': 'x66',
'n': 'x6e', 'r': 'x72', 't': 'x74', 'u': 'x75', 'v': 'x76', 'x': 'x78'
};
/** Used to escape characters for inclusion in compiled string literals. */
var stringEscapes = {
'\\': '\\',
"'": "'",
'\n': 'n',
'\r': 'r',
'\u2028': 'u2028',
'\u2029': 'u2029'
};
/**
* Used by `_.escapeRegExp` to escape characters for inclusion in compiled regexes.
*
* @private
* @param {string} chr The matched character to escape.
* @param {string} leadingChar The capture group for a leading character.
* @param {string} whitespaceChar The capture group for a whitespace character.
* @returns {string} Returns the escaped character.
*/
function escapeRegExpChar(chr, leadingChar, whitespaceChar) {
if (leadingChar) {
chr = regexpEscapes[chr];
} else if (whitespaceChar) {
chr = stringEscapes[chr];
}
return '\\' + chr;
}
return escapeRegExpChar;
});

View File

@@ -11,8 +11,7 @@ define([], function() {
};
/**
* Used by `_.template` to escape characters for inclusion in compiled
* string literals.
* Used by `_.template` to escape characters for inclusion in compiled string literals.
*
* @private
* @param {string} chr The matched character to escape.

View File

@@ -8,7 +8,7 @@ define(['./realNames'], function(realNames) {
* @returns {string} Returns the function name.
*/
function getFuncName(func) {
var result = func.name,
var result = (func.name + ''),
array = realNames[result],
length = array ? array.length : 0;

View File

@@ -10,13 +10,13 @@ define([], function() {
* @private
* @param {number} start The start of the view.
* @param {number} end The end of the view.
* @param {Array} [transforms] The transformations to apply to the view.
* @param {Array} transforms The transformations to apply to the view.
* @returns {Object} Returns an object containing the `start` and `end`
* positions of the view.
*/
function getView(start, end, transforms) {
var index = -1,
length = transforms ? transforms.length : 0;
length = transforms.length;
while (++index < length) {
var data = transforms[index],

View File

@@ -1,7 +1,10 @@
define([], function() {
/** Used to detect unsigned integer values. */
var reIsUint = /^\d+$/;
/**
* Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
* Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
* of an array-like value.
*/
var MAX_SAFE_INTEGER = 9007199254740991;
@@ -15,7 +18,7 @@ define([], function() {
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
*/
function isIndex(value, length) {
value = typeof value == 'number' ? value : parseFloat(value);
value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
length = length == null ? MAX_SAFE_INTEGER : length;
return value > -1 && value % 1 == 0 && value < length;
}

View File

@@ -8,11 +8,12 @@ define(['./LazyWrapper', './getData', './getFuncName', '../chain/lodash'], funct
* @returns {boolean} Returns `true` if `func` has a lazy counterpart, else `false`.
*/
function isLaziable(func) {
var funcName = getFuncName(func);
if (!(funcName in LazyWrapper.prototype)) {
var funcName = getFuncName(func),
other = lodash[funcName];
if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
return false;
}
var other = lodash[funcName];
if (func === other) {
return true;
}

View File

@@ -1,7 +1,7 @@
define([], function() {
/**
* Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
* Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
* of an array-like value.
*/
var MAX_SAFE_INTEGER = 9007199254740991;
@@ -9,7 +9,7 @@ define([], function() {
/**
* Checks if `value` is a valid array-like length.
*
* **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength).
* **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
*
* @private
* @param {*} value The value to check.

View File

@@ -9,17 +9,13 @@ define(['./LazyWrapper', './arrayCopy'], function(LazyWrapper, arrayCopy) {
* @returns {Object} Returns the cloned `LazyWrapper` object.
*/
function lazyClone() {
var actions = this.__actions__,
iteratees = this.__iteratees__,
views = this.__views__,
result = new LazyWrapper(this.__wrapped__);
result.__actions__ = actions ? arrayCopy(actions) : null;
var result = new LazyWrapper(this.__wrapped__);
result.__actions__ = arrayCopy(this.__actions__);
result.__dir__ = this.__dir__;
result.__filtered__ = this.__filtered__;
result.__iteratees__ = iteratees ? arrayCopy(iteratees) : null;
result.__iteratees__ = arrayCopy(this.__iteratees__);
result.__takeCount__ = this.__takeCount__;
result.__views__ = views ? arrayCopy(views) : null;
result.__views__ = arrayCopy(this.__views__);
return result;
}

View File

@@ -1,8 +1,10 @@
define(['./baseWrapperValue', './getView', '../lang/isArray'], function(baseWrapperValue, getView, isArray) {
/** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200;
/** Used to indicate the type of lazy iteratees. */
var LAZY_DROP_WHILE_FLAG = 0,
LAZY_FILTER_FLAG = 1,
var LAZY_FILTER_FLAG = 1,
LAZY_MAP_FLAG = 2;
/* Native method references for those with the same name as other `lodash` methods. */
@@ -17,22 +19,25 @@ define(['./baseWrapperValue', './getView', '../lang/isArray'], function(baseWrap
* @returns {*} Returns the unwrapped value.
*/
function lazyValue() {
var array = this.__wrapped__.value();
if (!isArray(array)) {
return baseWrapperValue(array, this.__actions__);
}
var dir = this.__dir__,
var array = this.__wrapped__.value(),
dir = this.__dir__,
isArr = isArray(array),
isRight = dir < 0,
view = getView(0, array.length, this.__views__),
arrLength = isArr ? array.length : 0,
view = getView(0, arrLength, this.__views__),
start = view.start,
end = view.end,
length = end - start,
index = isRight ? end : (start - 1),
takeCount = nativeMin(length, this.__takeCount__),
iteratees = this.__iteratees__,
iterLength = iteratees ? iteratees.length : 0,
iterLength = iteratees.length,
resIndex = 0,
result = [];
takeCount = nativeMin(length, this.__takeCount__);
if (!isArr || arrLength < LARGE_ARRAY_SIZE || (arrLength == length && takeCount == length)) {
return baseWrapperValue(array, this.__actions__);
}
var result = [];
outer:
while (length-- && resIndex < takeCount) {
@@ -44,30 +49,16 @@ define(['./baseWrapperValue', './getView', '../lang/isArray'], function(baseWrap
while (++iterIndex < iterLength) {
var data = iteratees[iterIndex],
iteratee = data.iteratee,
type = data.type;
type = data.type,
computed = iteratee(value);
if (type == LAZY_DROP_WHILE_FLAG) {
if (data.done && (isRight ? (index > data.index) : (index < data.index))) {
data.count = 0;
data.done = false;
}
data.index = index;
if (!data.done) {
var limit = data.limit;
if (!(data.done = limit > -1 ? (data.count++ >= limit) : !iteratee(value))) {
continue outer;
}
}
} else {
var computed = iteratee(value);
if (type == LAZY_MAP_FLAG) {
value = computed;
} else if (!computed) {
if (type == LAZY_FILTER_FLAG) {
continue outer;
} else {
break outer;
}
if (type == LAZY_MAP_FLAG) {
value = computed;
} else if (!computed) {
if (type == LAZY_FILTER_FLAG) {
continue outer;
} else {
break outer;
}
}
}

19
internal/mergeDefaults.js Normal file
View File

@@ -0,0 +1,19 @@
define(['../object/merge'], function(merge) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* Used by `_.defaultsDeep` to customize its `_.merge` use.
*
* @private
* @param {*} objectValue The destination object property value.
* @param {*} sourceValue The source object property value.
* @returns {*} Returns the value to assign to the destination object.
*/
function mergeDefaults(objectValue, sourceValue) {
return objectValue === undefined ? sourceValue : merge(objectValue, sourceValue, mergeDefaults);
}
return mergeDefaults;
});

View File

@@ -1,53 +0,0 @@
define(['./baseForIn', './isObjectLike'], function(baseForIn, isObjectLike) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** `Object#toString` result references. */
var objectTag = '[object Object]';
/** Used for native method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
* of values.
*/
var objToString = objectProto.toString;
/**
* A fallback implementation of `_.isPlainObject` which checks if `value`
* is an object created by the `Object` constructor or has a `[[Prototype]]`
* of `null`.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
*/
function shimIsPlainObject(value) {
var Ctor;
// Exit early for non `Object` objects.
if (!(isObjectLike(value) && objToString.call(value) == objectTag) ||
(!hasOwnProperty.call(value, 'constructor') &&
(Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
return false;
}
// IE < 9 iterates inherited properties before own properties. If the first
// iterated property is an object's own property then there are no inherited
// enumerable properties.
var result;
// In most environments an object's own properties are iterated before
// its inherited properties. If the last iterated property is an object's
// own property then there are no inherited enumerable properties.
baseForIn(value, function(subValue, key) {
result = key;
});
return result === undefined || hasOwnProperty.call(value, result);
}
return shimIsPlainObject;
});

View File

@@ -7,7 +7,7 @@ define([], function() {
* @private
* @param {Array} array The array to inspect.
* @param {Function} [iteratee] The function invoked per iteration.
* @returns {Array} Returns the new duplicate-value-free array.
* @returns {Array} Returns the new duplicate free array.
*/
function sortedUniq(array, iteratee) {
var seen,

View File

@@ -2,10 +2,10 @@ define(['../internal/baseClone', '../internal/bindCallback', '../internal/isIter
/**
* Creates a clone of `value`. If `isDeep` is `true` nested objects are cloned,
* otherwise they are assigned by reference. If `customizer` is provided it is
* otherwise they are assigned by reference. If `customizer` is provided it's
* invoked to produce the cloned values. If `customizer` returns `undefined`
* cloning is handled by the method instead. The `customizer` is bound to
* `thisArg` and invoked with two argument; (value [, index|key, object]).
* `thisArg` and invoked with up to three argument; (value [, index|key, object]).
*
* **Note:** This method is loosely based on the
* [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm).
@@ -61,7 +61,7 @@ define(['../internal/baseClone', '../internal/bindCallback', '../internal/isIter
isDeep = false;
}
return typeof customizer == 'function'
? baseClone(value, isDeep, bindCallback(customizer, thisArg, 1))
? baseClone(value, isDeep, bindCallback(customizer, thisArg, 3))
: baseClone(value, isDeep);
}

View File

@@ -1,10 +1,10 @@
define(['../internal/baseClone', '../internal/bindCallback'], function(baseClone, bindCallback) {
/**
* Creates a deep clone of `value`. If `customizer` is provided it is invoked
* Creates a deep clone of `value`. If `customizer` is provided it's invoked
* to produce the cloned values. If `customizer` returns `undefined` cloning
* is handled by the method instead. The `customizer` is bound to `thisArg`
* and invoked with two argument; (value [, index|key, object]).
* and invoked with up to three argument; (value [, index|key, object]).
*
* **Note:** This method is loosely based on the
* [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm).
@@ -47,7 +47,7 @@ define(['../internal/baseClone', '../internal/bindCallback'], function(baseClone
*/
function cloneDeep(value, customizer, thisArg) {
return typeof customizer == 'function'
? baseClone(value, true, bindCallback(customizer, thisArg, 1))
? baseClone(value, true, bindCallback(customizer, thisArg, 3))
: baseClone(value, true);
}

View File

@@ -1,16 +1,13 @@
define(['../internal/isArrayLike', '../internal/isObjectLike'], function(isArrayLike, isObjectLike) {
/** `Object#toString` result references. */
var argsTag = '[object Arguments]';
/** Used for native method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
* of values.
*/
var objToString = objectProto.toString;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/** Native method references. */
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
/**
* Checks if `value` is classified as an `arguments` object.
@@ -29,7 +26,8 @@ define(['../internal/isArrayLike', '../internal/isObjectLike'], function(isArray
* // => false
*/
function isArguments(value) {
return isObjectLike(value) && isArrayLike(value) && objToString.call(value) == argsTag;
return isObjectLike(value) && isArrayLike(value) &&
hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
}
return isArguments;

View File

@@ -7,7 +7,7 @@ define(['../internal/getNative', '../internal/isLength', '../internal/isObjectLi
var objectProto = Object.prototype;
/**
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
* of values.
*/
var objToString = objectProto.toString;

View File

@@ -7,7 +7,7 @@ define(['../internal/isObjectLike'], function(isObjectLike) {
var objectProto = Object.prototype;
/**
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
* of values.
*/
var objToString = objectProto.toString;

View File

@@ -7,7 +7,7 @@ define(['../internal/isObjectLike'], function(isObjectLike) {
var objectProto = Object.prototype;
/**
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
* of values.
*/
var objToString = objectProto.toString;

View File

@@ -1,13 +1,4 @@
define(['../internal/isObjectLike', './isPlainObject', '../support'], function(isObjectLike, isPlainObject, support) {
/** Used for native method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
* of values.
*/
var objToString = objectProto.toString;
define(['../internal/isObjectLike', './isPlainObject'], function(isObjectLike, isPlainObject) {
/**
* Checks if `value` is a DOM element.
@@ -26,14 +17,7 @@ define(['../internal/isObjectLike', './isPlainObject', '../support'], function(i
* // => false
*/
function isElement(value) {
return !!value && value.nodeType === 1 && isObjectLike(value) &&
(objToString.call(value).indexOf('Element') > -1);
}
// Fallback for environments without DOM support.
if (!support.dom) {
isElement = function(value) {
return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value);
};
return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value);
}
return isElement;

View File

@@ -1,7 +1,7 @@
define(['./isArguments', './isArray', '../internal/isArrayLike', './isFunction', '../internal/isObjectLike', './isString', '../object/keys'], function(isArguments, isArray, isArrayLike, isFunction, isObjectLike, isString, keys) {
/**
* Checks if `value` is empty. A value is considered empty unless it is an
* Checks if `value` is empty. A value is considered empty unless it's an
* `arguments` object, array, string, or jQuery-like collection with a length
* greater than `0` or an object with own enumerable properties.
*

View File

@@ -5,10 +5,10 @@ define(['../internal/baseIsEqual', '../internal/bindCallback'], function(baseIsE
/**
* Performs a deep comparison between two values to determine if they are
* equivalent. If `customizer` is provided it is invoked to compare values.
* equivalent. If `customizer` is provided it's invoked to compare values.
* If `customizer` returns `undefined` comparisons are handled by the method
* instead. The `customizer` is bound to `thisArg` and invoked with three
* arguments: (value, other [, index|key]).
* instead. The `customizer` is bound to `thisArg` and invoked with up to
* three arguments: (value, other [, index|key]).
*
* **Note:** This method supports comparing arrays, booleans, `Date` objects,
* numbers, `Object` objects, regexes, and strings. Objects are compared by

View File

@@ -7,7 +7,7 @@ define(['../internal/isObjectLike'], function(isObjectLike) {
var objectProto = Object.prototype;
/**
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
* of values.
*/
var objToString = objectProto.toString;

View File

@@ -1,13 +1,12 @@
define(['../internal/getNative', '../internal/root'], function(getNative, root) {
define(['../internal/root'], function(root) {
/* Native method references for those with the same name as other `lodash` methods. */
var nativeIsFinite = root.isFinite,
nativeNumIsFinite = getNative(Number, 'isFinite');
var nativeIsFinite = root.isFinite;
/**
* Checks if `value` is a finite primitive number.
*
* **Note:** This method is based on [`Number.isFinite`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite).
* **Note:** This method is based on [`Number.isFinite`](http://ecma-international.org/ecma-262/6.0/#sec-number.isfinite).
*
* @static
* @memberOf _
@@ -31,9 +30,9 @@ define(['../internal/getNative', '../internal/root'], function(getNative, root)
* _.isFinite(Infinity);
* // => false
*/
var isFinite = nativeNumIsFinite || function(value) {
function isFinite(value) {
return typeof value == 'number' && nativeIsFinite(value);
};
}
return isFinite;
});

View File

@@ -1,4 +1,4 @@
define(['../internal/baseIsFunction', '../internal/getNative', '../internal/root'], function(baseIsFunction, getNative, root) {
define(['./isObject'], function(isObject) {
/** `Object#toString` result references. */
var funcTag = '[object Function]';
@@ -7,14 +7,11 @@ define(['../internal/baseIsFunction', '../internal/getNative', '../internal/root
var objectProto = Object.prototype;
/**
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
* of values.
*/
var objToString = objectProto.toString;
/** Native method references. */
var Uint8Array = getNative(root, 'Uint8Array');
/**
* Checks if `value` is classified as a `Function` object.
*
@@ -31,12 +28,12 @@ define(['../internal/baseIsFunction', '../internal/getNative', '../internal/root
* _.isFunction(/abc/);
* // => false
*/
var isFunction = !(baseIsFunction(/x/) || (Uint8Array && !baseIsFunction(Uint8Array))) ? baseIsFunction : function(value) {
function isFunction(value) {
// The use of `Object#toString` avoids issues with the `typeof` operator
// in older versions of Chrome and Safari which return 'function' for regexes
// and Safari 8 equivalents which return 'object' for typed array constructors.
return objToString.call(value) == funcTag;
};
// and Safari 8 which returns 'object' for typed array constructors.
return isObject(value) && objToString.call(value) == funcTag;
}
return isFunction;
});

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