diff --git a/LICENSE.txt b/LICENSE
similarity index 100%
rename from LICENSE.txt
rename to LICENSE
diff --git a/README.md b/README.md
index ec24ba949..199090b24 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# lodash-es v3.9.3
+# lodash-es v3.10.0
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) exported as [ES](https://people.mozilla.org/~jorendorff/es6-draft.html) modules.
@@ -7,4 +7,4 @@ Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli):
$ lodash modularize modern exports=es -o ./
```
-See the [package source](https://github.com/lodash/lodash/tree/3.9.3-es) for more details.
+See the [package source](https://github.com/lodash/lodash/tree/3.10.0-es) for more details.
diff --git a/array/chunk.js b/array/chunk.js
index 0f46f5d4b..3bde8716f 100644
--- a/array/chunk.js
+++ b/array/chunk.js
@@ -1,11 +1,10 @@
import baseSlice from '../internal/baseSlice';
import isIterateeCall from '../internal/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`.
@@ -31,12 +30,12 @@ function chunk(array, size, guard) {
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));
diff --git a/array/difference.js b/array/difference.js
index 727962b5a..64a541bd7 100644
--- a/array/difference.js
+++ b/array/difference.js
@@ -1,11 +1,12 @@
import baseDifference from '../internal/baseDifference';
import baseFlatten from '../internal/baseFlatten';
import isArrayLike from '../internal/isArrayLike';
+import isObjectLike from '../internal/isObjectLike';
import restParam from '../function/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
@@ -20,7 +21,7 @@ import restParam from '../function/restParam';
* // => [1, 3]
*/
var difference = restParam(function(array, values) {
- return isArrayLike(array)
+ return (isObjectLike(array) && isArrayLike(array))
? baseDifference(array, baseFlatten(values, false, true))
: [];
});
diff --git a/array/indexOf.js b/array/indexOf.js
index dd500afb5..95a2cafdf 100644
--- a/array/indexOf.js
+++ b/array/indexOf.js
@@ -6,7 +6,7 @@ var nativeMax = Math.max;
/**
* 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)
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* for equality comparisons. If `fromIndex` is negative, it is used as the offset
* from the end of `array`. If `array` is sorted providing `true` for `fromIndex`
* performs a faster binary search.
@@ -40,10 +40,9 @@ function indexOf(array, value, fromIndex) {
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;
diff --git a/array/intersection.js b/array/intersection.js
index a188aba3d..9c883ecb0 100644
--- a/array/intersection.js
+++ b/array/intersection.js
@@ -6,7 +6,7 @@ import restParam from '../function/restParam';
/**
* 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
diff --git a/array/pull.js b/array/pull.js
index ed0036990..bbb8a1a11 100644
--- a/array/pull.js
+++ b/array/pull.js
@@ -8,7 +8,7 @@ var splice = arrayProto.splice;
/**
* 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`.
diff --git a/array/union.js b/array/union.js
index d3de0dfb0..226f956a2 100644
--- a/array/union.js
+++ b/array/union.js
@@ -4,7 +4,7 @@ import restParam from '../function/restParam';
/**
* 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
diff --git a/array/uniq.js b/array/uniq.js
index 06352075e..9beba9fb6 100644
--- a/array/uniq.js
+++ b/array/uniq.js
@@ -5,7 +5,7 @@ import sortedUniq from '../internal/sortedUniq';
/**
* 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
@@ -59,7 +59,7 @@ function uniq(array, isSorted, iteratee, thisArg) {
}
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);
diff --git a/array/without.js b/array/without.js
index 649daf516..e49135fa9 100644
--- a/array/without.js
+++ b/array/without.js
@@ -4,7 +4,7 @@ import restParam from '../function/restParam';
/**
* 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
diff --git a/array/xor.js b/array/xor.js
index 41bcb91ea..e1fdf86fe 100644
--- a/array/xor.js
+++ b/array/xor.js
@@ -1,3 +1,4 @@
+import arrayPush from '../internal/arrayPush';
import baseDifference from '../internal/baseDifference';
import baseUniq from '../internal/baseUniq';
import isArrayLike from '../internal/isArrayLike';
@@ -24,7 +25,7 @@ function xor() {
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;
}
}
diff --git a/chain.js b/chain.js
index b8e00af08..e029e2b8f 100644
--- a/chain.js
+++ b/chain.js
@@ -1,5 +1,6 @@
import chain from './chain/chain';
import commit from './chain/commit';
+import concat from './chain/concat';
import lodash from './chain/lodash';
import plant from './chain/plant';
import reverse from './chain/reverse';
@@ -15,6 +16,7 @@ import wrapperChain from './chain/wrapperChain';
export default {
'chain': chain,
'commit': commit,
+ 'concat': concat,
'lodash': lodash,
'plant': plant,
'reverse': reverse,
diff --git a/chain/concat.js b/chain/concat.js
new file mode 100644
index 000000000..2fabc0707
--- /dev/null
+++ b/chain/concat.js
@@ -0,0 +1,2 @@
+import wrapperConcat from './wrapperConcat'
+export default wrapperConcat;
diff --git a/chain/lodash.js b/chain/lodash.js
index 6988a29b9..958e64f85 100644
--- a/chain/lodash.js
+++ b/chain/lodash.js
@@ -14,15 +14,16 @@ var hasOwnProperty = objectProto.hasOwnProperty;
/**
* 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.
@@ -45,36 +46,37 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* 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.
diff --git a/chain/wrapperCommit.js b/chain/wrapperCommit.js
index 0ce1dd59f..9341c5ab2 100644
--- a/chain/wrapperCommit.js
+++ b/chain/wrapperCommit.js
@@ -10,16 +10,16 @@ import LodashWrapper from '../internal/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);
diff --git a/chain/wrapperConcat.js b/chain/wrapperConcat.js
new file mode 100644
index 000000000..944e2c96f
--- /dev/null
+++ b/chain/wrapperConcat.js
@@ -0,0 +1,34 @@
+import arrayConcat from '../internal/arrayConcat';
+import baseFlatten from '../internal/baseFlatten';
+import isArray from '../lang/isArray';
+import restParam from '../function/restParam';
+import toObject from '../internal/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);
+ });
+});
+
+export default wrapperConcat;
diff --git a/chain/wrapperPlant.js b/chain/wrapperPlant.js
index f3dd93fb8..d06874670 100644
--- a/chain/wrapperPlant.js
+++ b/chain/wrapperPlant.js
@@ -11,17 +11,17 @@ import wrapperClone from '../internal/wrapperClone';
* @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) {
diff --git a/chain/wrapperReverse.js b/chain/wrapperReverse.js
index a7e2063df..3ca7b8c49 100644
--- a/chain/wrapperReverse.js
+++ b/chain/wrapperReverse.js
@@ -24,15 +24,20 @@ import thru from './thru';
*/
function wrapperReverse() {
var value = this.__wrapped__;
+
+ var interceptor = function(value) {
+ return (wrapped && wrapped.__dir__ < 0) ? value : value.reverse();
+ };
if (value instanceof LazyWrapper) {
+ var wrapped = value;
if (this.__actions__.length) {
- value = new LazyWrapper(this);
+ wrapped = new LazyWrapper(this);
}
- return new LodashWrapper(value.reverse(), this.__chain__);
+ wrapped = wrapped.reverse();
+ wrapped.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
+ return new LodashWrapper(wrapped, this.__chain__);
}
- return this.thru(function(value) {
- return value.reverse();
- });
+ return this.thru(interceptor);
}
export default wrapperReverse;
diff --git a/collection/every.js b/collection/every.js
index 89fe06b6c..9d48de9af 100644
--- a/collection/every.js
+++ b/collection/every.js
@@ -55,7 +55,7 @@ import isIterateeCall from '../internal/isIterateeCall';
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);
diff --git a/collection/includes.js b/collection/includes.js
index 47becc215..7c87bb290 100644
--- a/collection/includes.js
+++ b/collection/includes.js
@@ -11,7 +11,7 @@ var nativeMax = Math.max;
/**
* Checks if `value` is in `collection` 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. If `fromIndex` is negative, it is used as the offset
* from the end of `collection`.
*
@@ -44,17 +44,14 @@ function includes(collection, target, fromIndex, guard) {
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);
}
export default includes;
diff --git a/collection/invoke.js b/collection/invoke.js
index b35e55789..231f01678 100644
--- a/collection/invoke.js
+++ b/collection/invoke.js
@@ -33,7 +33,7 @@ var invoke = restParam(function(collection, path, args) {
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;
diff --git a/collection/reduce.js b/collection/reduce.js
index 8c5750d6f..86d53b603 100644
--- a/collection/reduce.js
+++ b/collection/reduce.js
@@ -14,7 +14,8 @@ import createReduce from '../internal/createReduce';
* `_.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 _
diff --git a/collection/some.js b/collection/some.js
index 684f551a7..6cf382a53 100644
--- a/collection/some.js
+++ b/collection/some.js
@@ -56,7 +56,7 @@ import isIterateeCall from '../internal/isIterateeCall';
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);
diff --git a/collection/sortBy.js b/collection/sortBy.js
index 647756d08..717f03851 100644
--- a/collection/sortBy.js
+++ b/collection/sortBy.js
@@ -57,7 +57,7 @@ function sortBy(collection, iteratee, thisArg) {
return [];
}
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
- iteratee = null;
+ iteratee = undefined;
}
var index = -1;
iteratee = baseCallback(iteratee, thisArg, 3);
diff --git a/collection/sortByOrder.js b/collection/sortByOrder.js
index 510cf5daf..ac30330f5 100644
--- a/collection/sortByOrder.js
+++ b/collection/sortByOrder.js
@@ -4,9 +4,9 @@ import isIterateeCall from '../internal/isIterateeCall';
/**
* 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.
@@ -20,7 +20,7 @@ import isIterateeCall from '../internal/isIterateeCall';
* @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
@@ -33,7 +33,7 @@ import isIterateeCall from '../internal/isIterateeCall';
* ];
*
* // 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) {
@@ -41,7 +41,7 @@ function sortByOrder(collection, iteratees, orders, guard) {
return [];
}
if (guard && isIterateeCall(iteratees, orders, guard)) {
- orders = null;
+ orders = undefined;
}
if (!isArray(iteratees)) {
iteratees = iteratees == null ? [] : [iteratees];
diff --git a/function.js b/function.js
index 4ad274260..f0de61d6a 100644
--- a/function.js
+++ b/function.js
@@ -14,6 +14,7 @@ import delay from './function/delay';
import flow from './function/flow';
import flowRight from './function/flowRight';
import memoize from './function/memoize';
+import modArgs from './function/modArgs';
import negate from './function/negate';
import once from './function/once';
import partial from './function/partial';
@@ -41,6 +42,7 @@ export default {
'flow': flow,
'flowRight': flowRight,
'memoize': memoize,
+ 'modArgs': modArgs,
'negate': negate,
'once': once,
'partial': partial,
diff --git a/function/ary.js b/function/ary.js
index 27323a33b..f0f7ef209 100644
--- a/function/ary.js
+++ b/function/ary.js
@@ -25,10 +25,10 @@ var nativeMax = Math.max;
*/
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);
}
export default ary;
diff --git a/function/before.js b/function/before.js
index 7f2266ebb..0f21a3657 100644
--- a/function/before.js
+++ b/function/before.js
@@ -33,7 +33,7 @@ function before(n, func) {
result = func.apply(this, arguments);
}
if (n <= 1) {
- func = null;
+ func = undefined;
}
return result;
};
diff --git a/function/debounce.js b/function/debounce.js
index bbe23240a..d6be57b8f 100644
--- a/function/debounce.js
+++ b/function/debounce.js
@@ -90,9 +90,9 @@ function debounce(func, wait, options) {
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() {
@@ -102,41 +102,35 @@ function debounce(func, wait, options) {
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() {
@@ -176,7 +170,7 @@ function debounce(func, wait, options) {
result = func.apply(thisArg, args);
}
if (isCalled && !timeoutId && !maxTimeoutId) {
- args = thisArg = null;
+ args = thisArg = undefined;
}
return result;
}
diff --git a/function/memoize.js b/function/memoize.js
index 4744473e9..bb4eed49e 100644
--- a/function/memoize.js
+++ b/function/memoize.js
@@ -13,7 +13,7 @@ var FUNC_ERROR_TEXT = 'Expected a function';
*
* **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
diff --git a/function/modArgs.js b/function/modArgs.js
new file mode 100644
index 000000000..d52a58596
--- /dev/null
+++ b/function/modArgs.js
@@ -0,0 +1,58 @@
+import arrayEvery from '../internal/arrayEvery';
+import baseFlatten from '../internal/baseFlatten';
+import baseIsFunction from '../internal/baseIsFunction';
+import restParam from './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);
+ });
+});
+
+export default modArgs;
diff --git a/function/rearg.js b/function/rearg.js
index 5962b3471..f72d0c20e 100644
--- a/function/rearg.js
+++ b/function/rearg.js
@@ -34,7 +34,7 @@ var REARG_FLAG = 256;
* // => [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));
});
export default rearg;
diff --git a/function/throttle.js b/function/throttle.js
index cfbfa7fa1..cd38564fe 100644
--- a/function/throttle.js
+++ b/function/throttle.js
@@ -4,13 +4,6 @@ import isObject from '../lang/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`
@@ -63,10 +56,7 @@ function throttle(func, wait, options) {
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 });
}
export default throttle;
diff --git a/function/wrap.js b/function/wrap.js
index 35f490605..92a1b6237 100644
--- a/function/wrap.js
+++ b/function/wrap.js
@@ -27,7 +27,7 @@ var PARTIAL_FLAG = 32;
*/
function wrap(value, wrapper) {
wrapper = wrapper == null ? identity : wrapper;
- return createWrapper(wrapper, PARTIAL_FLAG, null, [value], []);
+ return createWrapper(wrapper, PARTIAL_FLAG, undefined, [value], []);
}
export default wrap;
diff --git a/internal/LazyWrapper.js b/internal/LazyWrapper.js
index 829f793bb..4c8e5b420 100644
--- a/internal/LazyWrapper.js
+++ b/internal/LazyWrapper.js
@@ -12,13 +12,12 @@ var POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
*/
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);
diff --git a/internal/arrayConcat.js b/internal/arrayConcat.js
new file mode 100644
index 000000000..9d5e23dd4
--- /dev/null
+++ b/internal/arrayConcat.js
@@ -0,0 +1,25 @@
+/**
+ * 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;
+}
+
+export default arrayConcat;
diff --git a/internal/arrayPush.js b/internal/arrayPush.js
new file mode 100644
index 000000000..3660a7dbc
--- /dev/null
+++ b/internal/arrayPush.js
@@ -0,0 +1,20 @@
+/**
+ * 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;
+}
+
+export default arrayPush;
diff --git a/internal/arraySum.js b/internal/arraySum.js
index bc0c22f3c..27ff80517 100644
--- a/internal/arraySum.js
+++ b/internal/arraySum.js
@@ -1,16 +1,18 @@
/**
- * 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;
}
diff --git a/internal/baseClone.js b/internal/baseClone.js
index 7d3765169..0679f34d5 100644
--- a/internal/baseClone.js
+++ b/internal/baseClone.js
@@ -53,7 +53,7 @@ cloneableTags[weakMapTag] = false;
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;
@@ -104,7 +104,7 @@ function baseClone(value, isDeep, customizer, key, object, stackA, stackB) {
: (object ? value : {});
}
}
- // Check for circular references and return corresponding clone.
+ // Check for circular references and return its corresponding clone.
stackA || (stackA = []);
stackB || (stackB = []);
diff --git a/internal/baseCreate.js b/internal/baseCreate.js
index 58e5bf32f..b95d4a016 100644
--- a/internal/baseCreate.js
+++ b/internal/baseCreate.js
@@ -14,7 +14,7 @@ var baseCreate = (function() {
if (isObject(prototype)) {
object.prototype = prototype;
var result = new object;
- object.prototype = null;
+ object.prototype = undefined;
}
return result || {};
};
diff --git a/internal/baseDifference.js b/internal/baseDifference.js
index 58028e7b9..967360ef3 100644
--- a/internal/baseDifference.js
+++ b/internal/baseDifference.js
@@ -2,6 +2,9 @@ import baseIndexOf from './baseIndexOf';
import cacheIndexOf from './cacheIndexOf';
import createCache from './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.
@@ -21,7 +24,7 @@ function baseDifference(array, values) {
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) {
diff --git a/internal/baseFlatten.js b/internal/baseFlatten.js
index 88b7dcddc..35025edde 100644
--- a/internal/baseFlatten.js
+++ b/internal/baseFlatten.js
@@ -1,3 +1,4 @@
+import arrayPush from './arrayPush';
import isArguments from '../lang/isArguments';
import isArray from '../lang/isArray';
import isArrayLike from './isArrayLike';
@@ -11,13 +12,14 @@ import isObjectLike from './isObjectLike';
* @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];
@@ -25,16 +27,12 @@ function baseFlatten(array, isDeep, isStrict) {
(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;
diff --git a/internal/baseIsEqualDeep.js b/internal/baseIsEqualDeep.js
index 27978627a..639f2a731 100644
--- a/internal/baseIsEqualDeep.js
+++ b/internal/baseIsEqualDeep.js
@@ -16,7 +16,7 @@ var objectProto = Object.prototype;
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;
diff --git a/internal/baseMerge.js b/internal/baseMerge.js
index 233fa16ef..703002da4 100644
--- a/internal/baseMerge.js
+++ b/internal/baseMerge.js
@@ -14,7 +14,7 @@ import keys from '../object/keys';
* @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`.
@@ -24,7 +24,7 @@ function baseMerge(object, source, customizer, stackA, stackB) {
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) {
diff --git a/internal/baseMergeDeep.js b/internal/baseMergeDeep.js
index 3f174c8ff..3545db5cb 100644
--- a/internal/baseMergeDeep.js
+++ b/internal/baseMergeDeep.js
@@ -16,7 +16,7 @@ import toPlainObject from '../lang/toPlainObject';
* @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`.
diff --git a/internal/baseRandom.js b/internal/baseRandom.js
index c474454ff..f4aa8b0a8 100644
--- a/internal/baseRandom.js
+++ b/internal/baseRandom.js
@@ -1,8 +1,6 @@
-/** 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
@@ -14,7 +12,7 @@ var nativeRandom = Math.random;
* @returns {number} Returns the random number.
*/
function baseRandom(min, max) {
- return min + floor(nativeRandom() * (max - min + 1));
+ return min + nativeFloor(nativeRandom() * (max - min + 1));
}
export default baseRandom;
diff --git a/internal/baseToString.js b/internal/baseToString.js
index 4d5e22628..c9d99b53d 100644
--- a/internal/baseToString.js
+++ b/internal/baseToString.js
@@ -7,9 +7,6 @@
* @returns {string} Returns the string.
*/
function baseToString(value) {
- if (typeof value == 'string') {
- return value;
- }
return value == null ? '' : (value + '');
}
diff --git a/internal/baseUniq.js b/internal/baseUniq.js
index 836ee68f0..802a28a18 100644
--- a/internal/baseUniq.js
+++ b/internal/baseUniq.js
@@ -2,6 +2,9 @@ import baseIndexOf from './baseIndexOf';
import cacheIndexOf from './cacheIndexOf';
import createCache from './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.
@@ -16,7 +19,7 @@ function baseUniq(array, iteratee) {
indexOf = baseIndexOf,
length = array.length,
isCommon = true,
- isLarge = isCommon && length >= 200,
+ isLarge = isCommon && length >= LARGE_ARRAY_SIZE,
seen = isLarge ? createCache() : null,
result = [];
diff --git a/internal/baseWrapperValue.js b/internal/baseWrapperValue.js
index 2b168f950..7c5c3dc83 100644
--- a/internal/baseWrapperValue.js
+++ b/internal/baseWrapperValue.js
@@ -1,10 +1,5 @@
import LazyWrapper from './LazyWrapper';
-
-/** Used for native method references. */
-var arrayProto = Array.prototype;
-
-/** Native method references. */
-var push = arrayProto.push;
+import arrayPush from './arrayPush';
/**
* The base implementation of `wrapperValue` which returns the result of
@@ -25,11 +20,8 @@ function baseWrapperValue(value, actions) {
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;
}
diff --git a/internal/binaryIndexBy.js b/internal/binaryIndexBy.js
index f97e923f2..1541a625f 100644
--- a/internal/binaryIndexBy.js
+++ b/internal/binaryIndexBy.js
@@ -1,8 +1,6 @@
-/** 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,
@@ -31,7 +29,7 @@ function binaryIndexBy(array, value, iteratee, retHighest) {
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;
diff --git a/internal/bufferClone.js b/internal/bufferClone.js
index 2f80240f8..acf2f60f1 100644
--- a/internal/bufferClone.js
+++ b/internal/bufferClone.js
@@ -1,27 +1,8 @@
-import constant from '../utility/constant';
-import getNative from './getNative';
import root from './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.
@@ -31,26 +12,11 @@ var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT :
* @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;
}
export default bufferClone;
diff --git a/internal/compareAscending.js b/internal/compareAscending.js
index c1ed56487..a908e8080 100644
--- a/internal/compareAscending.js
+++ b/internal/compareAscending.js
@@ -5,8 +5,8 @@ import baseCompareAscending from './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) {
diff --git a/internal/compareMultiple.js b/internal/compareMultiple.js
index da75ed3e0..ad3e1721e 100644
--- a/internal/compareMultiple.js
+++ b/internal/compareMultiple.js
@@ -1,16 +1,16 @@
import baseCompareAscending from './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 @@ function compareMultiple(object, other, orders) {
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
diff --git a/internal/composeArgs.js b/internal/composeArgs.js
index 8ec286f11..d89463f9a 100644
--- a/internal/composeArgs.js
+++ b/internal/composeArgs.js
@@ -17,7 +17,7 @@ function composeArgs(args, partials, holders) {
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];
diff --git a/internal/createAggregator.js b/internal/createAggregator.js
index 7fde08919..5aee6a0df 100644
--- a/internal/createAggregator.js
+++ b/internal/createAggregator.js
@@ -3,12 +3,7 @@ import baseEach from './baseEach';
import isArray from '../lang/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.
diff --git a/internal/createAssigner.js b/internal/createAssigner.js
index 07658047a..184c2a317 100644
--- a/internal/createAssigner.js
+++ b/internal/createAssigner.js
@@ -3,10 +3,7 @@ import isIterateeCall from './isIterateeCall';
import restParam from '../function/restParam';
/**
- * 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.
diff --git a/internal/createCache.js b/internal/createCache.js
index 2143b9106..f7606a1cf 100644
--- a/internal/createCache.js
+++ b/internal/createCache.js
@@ -1,5 +1,4 @@
import SetCache from './SetCache';
-import constant from '../utility/constant';
import getNative from './getNative';
import root from './root';
@@ -16,8 +15,8 @@ var nativeCreate = getNative(Object, 'create');
* @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;
+}
export default createCache;
diff --git a/internal/createCtorWrapper.js b/internal/createCtorWrapper.js
index 27d2bd132..b05cb162a 100644
--- a/internal/createCtorWrapper.js
+++ b/internal/createCtorWrapper.js
@@ -12,7 +12,7 @@ import isObject from '../lang/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) {
@@ -22,6 +22,8 @@ function createCtorWrapper(Ctor) {
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);
diff --git a/internal/createCurry.js b/internal/createCurry.js
index 19015dbb8..03c8c6cce 100644
--- a/internal/createCurry.js
+++ b/internal/createCurry.js
@@ -11,9 +11,9 @@ import isIterateeCall from './isIterateeCall';
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;
}
diff --git a/internal/createDefaults.js b/internal/createDefaults.js
new file mode 100644
index 000000000..5fa865d63
--- /dev/null
+++ b/internal/createDefaults.js
@@ -0,0 +1,22 @@
+import restParam from '../function/restParam';
+
+/**
+ * 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);
+ });
+}
+
+export default createDefaults;
diff --git a/internal/createExtremum.js b/internal/createExtremum.js
index 27bace9bc..82ad48d0f 100644
--- a/internal/createExtremum.js
+++ b/internal/createExtremum.js
@@ -1,6 +1,7 @@
import arrayExtremum from './arrayExtremum';
import baseCallback from './baseCallback';
import baseExtremum from './baseExtremum';
+import isArray from '../lang/isArray';
import isIterateeCall from './isIterateeCall';
import toIterable from './toIterable';
@@ -15,11 +16,11 @@ import toIterable from './toIterable';
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;
diff --git a/internal/createFlow.js b/internal/createFlow.js
index 78a4c9fb3..970415842 100644
--- a/internal/createFlow.js
+++ b/internal/createFlow.js
@@ -10,6 +10,9 @@ var CURRY_FLAG = 8,
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';
@@ -34,7 +37,7 @@ function createFlow(fromRight) {
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;
@@ -42,7 +45,7 @@ function createFlow(fromRight) {
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]);
@@ -51,12 +54,14 @@ function createFlow(fromRight) {
}
}
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);
diff --git a/internal/createHybridWrapper.js b/internal/createHybridWrapper.js
index d5e85a7d1..5ceed61aa 100644
--- a/internal/createHybridWrapper.js
+++ b/internal/createHybridWrapper.js
@@ -45,7 +45,7 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials
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
@@ -69,12 +69,12 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials
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);
diff --git a/internal/createPadding.js b/internal/createPadding.js
index b3f52a523..f7a0fbf4f 100644
--- a/internal/createPadding.js
+++ b/internal/createPadding.js
@@ -1,11 +1,9 @@
import repeat from '../string/repeat';
import root from './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`.
@@ -26,7 +24,7 @@ function createPadding(string, length, chars) {
}
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);
}
export default createPadding;
diff --git a/internal/createPartial.js b/internal/createPartial.js
index 5d0a598b1..fb268ade2 100644
--- a/internal/createPartial.js
+++ b/internal/createPartial.js
@@ -12,7 +12,7 @@ import restParam from '../function/restParam';
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;
}
diff --git a/internal/createPartialWrapper.js b/internal/createPartialWrapper.js
index 3bd7320c9..f9635fc02 100644
--- a/internal/createPartialWrapper.js
+++ b/internal/createPartialWrapper.js
@@ -27,7 +27,7 @@ function createPartialWrapper(func, bitmask, thisArg, partials) {
argsLength = arguments.length,
leftIndex = -1,
leftLength = partials.length,
- args = Array(argsLength + leftLength);
+ args = Array(leftLength + argsLength);
while (++leftIndex < leftLength) {
args[leftIndex] = partials[leftIndex];
diff --git a/internal/createRound.js b/internal/createRound.js
new file mode 100644
index 000000000..27a759f2a
--- /dev/null
+++ b/internal/createRound.js
@@ -0,0 +1,23 @@
+/** 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);
+ };
+}
+
+export default createRound;
diff --git a/internal/createWrapper.js b/internal/createWrapper.js
index 7f5f72eeb..bc4d6eacf 100644
--- a/internal/createWrapper.js
+++ b/internal/createWrapper.js
@@ -51,16 +51,16 @@ function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, a
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) {
diff --git a/internal/equalByTag.js b/internal/equalByTag.js
index a002b6fd0..8fa010411 100644
--- a/internal/equalByTag.js
+++ b/internal/equalByTag.js
@@ -14,7 +14,7 @@ var boolTag = '[object Boolean]',
* `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`.
diff --git a/internal/escapeRegExpChar.js b/internal/escapeRegExpChar.js
new file mode 100644
index 000000000..625ab38d0
--- /dev/null
+++ b/internal/escapeRegExpChar.js
@@ -0,0 +1,38 @@
+/** 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;
+}
+
+export default escapeRegExpChar;
diff --git a/internal/escapeStringChar.js b/internal/escapeStringChar.js
index 073f458cc..bec224996 100644
--- a/internal/escapeStringChar.js
+++ b/internal/escapeStringChar.js
@@ -9,8 +9,7 @@ var stringEscapes = {
};
/**
- * 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.
diff --git a/internal/getView.js b/internal/getView.js
index 14c5a2557..cf677bf13 100644
--- a/internal/getView.js
+++ b/internal/getView.js
@@ -8,13 +8,13 @@ var nativeMax = Math.max,
* @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],
diff --git a/internal/isIndex.js b/internal/isIndex.js
index cff7909e1..8bbc020d9 100644
--- a/internal/isIndex.js
+++ b/internal/isIndex.js
@@ -2,7 +2,7 @@
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;
diff --git a/internal/isLength.js b/internal/isLength.js
index 7ad9093f0..717da4e97 100644
--- a/internal/isLength.js
+++ b/internal/isLength.js
@@ -1,5 +1,5 @@
/**
- * 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;
@@ -7,7 +7,7 @@ var MAX_SAFE_INTEGER = 9007199254740991;
/**
* 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.
diff --git a/internal/lazyClone.js b/internal/lazyClone.js
index f941407d7..2169ceaf7 100644
--- a/internal/lazyClone.js
+++ b/internal/lazyClone.js
@@ -10,17 +10,13 @@ import arrayCopy from './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;
}
diff --git a/internal/lazyValue.js b/internal/lazyValue.js
index cbc123101..b76744cf0 100644
--- a/internal/lazyValue.js
+++ b/internal/lazyValue.js
@@ -2,9 +2,11 @@ import baseWrapperValue from './baseWrapperValue';
import getView from './getView';
import isArray from '../lang/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. */
@@ -19,22 +21,25 @@ var nativeMin = Math.min;
* @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((isRight && isArr) ? array.reverse() : array, this.__actions__);
+ }
+ var result = [];
outer:
while (length-- && resIndex < takeCount) {
@@ -46,30 +51,16 @@ function lazyValue() {
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;
}
}
}
diff --git a/internal/mergeDefaults.js b/internal/mergeDefaults.js
new file mode 100644
index 000000000..f9227ea86
--- /dev/null
+++ b/internal/mergeDefaults.js
@@ -0,0 +1,15 @@
+import merge from '../object/merge';
+
+/**
+ * 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);
+}
+
+export default mergeDefaults;
diff --git a/internal/shimIsPlainObject.js b/internal/shimIsPlainObject.js
deleted file mode 100644
index 98d61330f..000000000
--- a/internal/shimIsPlainObject.js
+++ /dev/null
@@ -1,50 +0,0 @@
-import baseForIn from './baseForIn';
-import isObjectLike from './isObjectLike';
-
-/** `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);
-}
-
-export default shimIsPlainObject;
diff --git a/lang/isArguments.js b/lang/isArguments.js
index 45a6a1468..22140d86c 100644
--- a/lang/isArguments.js
+++ b/lang/isArguments.js
@@ -1,17 +1,14 @@
import isArrayLike from '../internal/isArrayLike';
import isObjectLike from '../internal/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.
@@ -30,7 +27,8 @@ var objToString = objectProto.toString;
* // => 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');
}
export default isArguments;
diff --git a/lang/isArray.js b/lang/isArray.js
index ecccce6a2..9af0bf7bc 100644
--- a/lang/isArray.js
+++ b/lang/isArray.js
@@ -9,7 +9,7 @@ var arrayTag = '[object Array]';
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;
diff --git a/lang/isBoolean.js b/lang/isBoolean.js
index 85b23cb32..f6a6f8674 100644
--- a/lang/isBoolean.js
+++ b/lang/isBoolean.js
@@ -7,7 +7,7 @@ var boolTag = '[object Boolean]';
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;
diff --git a/lang/isDate.js b/lang/isDate.js
index 69b34ec70..7befa7271 100644
--- a/lang/isDate.js
+++ b/lang/isDate.js
@@ -7,7 +7,7 @@ var dateTag = '[object Date]';
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;
diff --git a/lang/isElement.js b/lang/isElement.js
index 8b263bab8..5bb92d4f2 100644
--- a/lang/isElement.js
+++ b/lang/isElement.js
@@ -1,15 +1,5 @@
import isObjectLike from '../internal/isObjectLike';
import isPlainObject from './isPlainObject';
-import support from '../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;
/**
* Checks if `value` is a DOM element.
@@ -28,14 +18,7 @@ var objToString = objectProto.toString;
* // => 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);
}
export default isElement;
diff --git a/lang/isError.js b/lang/isError.js
index 01ac6d275..9bbece9a1 100644
--- a/lang/isError.js
+++ b/lang/isError.js
@@ -7,7 +7,7 @@ var errorTag = '[object Error]';
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;
diff --git a/lang/isFinite.js b/lang/isFinite.js
index 88a0d9be1..4e59703c1 100644
--- a/lang/isFinite.js
+++ b/lang/isFinite.js
@@ -1,14 +1,12 @@
-import getNative from '../internal/getNative';
import root from '../internal/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 _
@@ -32,8 +30,8 @@ var nativeIsFinite = root.isFinite,
* _.isFinite(Infinity);
* // => false
*/
-var isFinite = nativeNumIsFinite || function(value) {
+function isFinite(value) {
return typeof value == 'number' && nativeIsFinite(value);
-};
+}
export default isFinite;
diff --git a/lang/isFunction.js b/lang/isFunction.js
index a2eac06b4..8caf13062 100644
--- a/lang/isFunction.js
+++ b/lang/isFunction.js
@@ -1,6 +1,4 @@
-import baseIsFunction from '../internal/baseIsFunction';
-import getNative from '../internal/getNative';
-import root from '../internal/root';
+import isObject from './isObject';
/** `Object#toString` result references. */
var funcTag = '[object Function]';
@@ -9,14 +7,11 @@ var funcTag = '[object Function]';
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.
*
@@ -33,11 +28,11 @@ var Uint8Array = getNative(root, 'Uint8Array');
* _.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;
-};
+ return isObject(value) && objToString.call(value) == funcTag;
+}
export default isFunction;
diff --git a/lang/isNative.js b/lang/isNative.js
index 65cc534bb..e037e95ee 100644
--- a/lang/isNative.js
+++ b/lang/isNative.js
@@ -1,9 +1,6 @@
-import escapeRegExp from '../string/escapeRegExp';
+import isFunction from './isFunction';
import isObjectLike from '../internal/isObjectLike';
-/** `Object#toString` result references. */
-var funcTag = '[object Function]';
-
/** Used to detect host constructors (Safari > 5). */
var reIsHostCtor = /^\[object .+?Constructor\]$/;
@@ -16,15 +13,9 @@ var fnToString = Function.prototype.toString;
/** 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;
-
/** Used to detect if a method is native. */
var reIsNative = RegExp('^' +
- escapeRegExp(fnToString.call(hasOwnProperty))
+ fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
);
@@ -48,7 +39,7 @@ function isNative(value) {
if (value == null) {
return false;
}
- if (objToString.call(value) == funcTag) {
+ if (isFunction(value)) {
return reIsNative.test(fnToString.call(value));
}
return isObjectLike(value) && reIsHostCtor.test(value);
diff --git a/lang/isNumber.js b/lang/isNumber.js
index d3aac7221..dcc8c3db8 100644
--- a/lang/isNumber.js
+++ b/lang/isNumber.js
@@ -7,7 +7,7 @@ var numberTag = '[object Number]';
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;
diff --git a/lang/isPlainObject.js b/lang/isPlainObject.js
index 5176145a4..8d1724cff 100644
--- a/lang/isPlainObject.js
+++ b/lang/isPlainObject.js
@@ -1,5 +1,6 @@
-import getNative from '../internal/getNative';
-import shimIsPlainObject from '../internal/shimIsPlainObject';
+import baseForIn from '../internal/baseForIn';
+import isArguments from './isArguments';
+import isObjectLike from '../internal/isObjectLike';
/** `Object#toString` result references. */
var objectTag = '[object Object]';
@@ -7,15 +8,15 @@ 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)
+ * 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 getPrototypeOf = getNative(Object, 'getPrototypeOf');
-
/**
* Checks if `value` is a plain object, that is, an object created by the
* `Object` constructor or one with a `[[Prototype]]` of `null`.
@@ -46,16 +47,25 @@ var getPrototypeOf = getNative(Object, 'getPrototypeOf');
* _.isPlainObject(Object.create(null));
* // => true
*/
-var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) {
- if (!(value && objToString.call(value) == objectTag)) {
+function isPlainObject(value) {
+ var Ctor;
+
+ // Exit early for non `Object` objects.
+ if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isArguments(value)) ||
+ (!hasOwnProperty.call(value, 'constructor') && (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
return false;
}
- var valueOf = getNative(value, 'valueOf'),
- objProto = valueOf && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto);
-
- return objProto
- ? (value == objProto || getPrototypeOf(value) == objProto)
- : shimIsPlainObject(value);
-};
+ // 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);
+}
export default isPlainObject;
diff --git a/lang/isRegExp.js b/lang/isRegExp.js
index da278a94b..6bc150988 100644
--- a/lang/isRegExp.js
+++ b/lang/isRegExp.js
@@ -1,4 +1,4 @@
-import isObjectLike from '../internal/isObjectLike';
+import isObject from './isObject';
/** `Object#toString` result references. */
var regexpTag = '[object RegExp]';
@@ -7,7 +7,7 @@ var regexpTag = '[object RegExp]';
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;
@@ -29,7 +29,7 @@ var objToString = objectProto.toString;
* // => false
*/
function isRegExp(value) {
- return isObjectLike(value) && objToString.call(value) == regexpTag;
+ return isObject(value) && objToString.call(value) == regexpTag;
}
export default isRegExp;
diff --git a/lang/isString.js b/lang/isString.js
index 1b7c43b74..f596442d5 100644
--- a/lang/isString.js
+++ b/lang/isString.js
@@ -7,7 +7,7 @@ var stringTag = '[object String]';
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;
diff --git a/lang/isTypedArray.js b/lang/isTypedArray.js
index 78ecd9b00..a8b1c9135 100644
--- a/lang/isTypedArray.js
+++ b/lang/isTypedArray.js
@@ -46,7 +46,7 @@ typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
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;
diff --git a/lodash.js b/lodash.js
index ed20942d3..8112e7ed9 100644
--- a/lodash.js
+++ b/lodash.js
@@ -1,6 +1,6 @@
/**
* @license
- * lodash 3.9.3 (Custom Build)
+ * lodash 3.10.0 (Custom Build)
* Build: `lodash modularize modern exports="es" -o ./`
* Copyright 2012-2015 The Dojo Foundation
* Based on Underscore.js 1.8.3
@@ -21,6 +21,7 @@ import utility from './utility';
import LazyWrapper from './internal/LazyWrapper';
import LodashWrapper from './internal/LodashWrapper';
import arrayEach from './internal/arrayEach';
+import arrayPush from './internal/arrayPush';
import baseCallback from './internal/baseCallback';
import baseForOwn from './internal/baseForOwn';
import baseFunctions from './internal/baseFunctions';
@@ -42,27 +43,26 @@ import support from './support';
import thru from './chain/thru';
/** Used as the semantic version number. */
-var VERSION = '3.9.3';
+var VERSION = '3.10.0';
/** Used to compose bitmasks for wrapper metadata. */
var BIND_KEY_FLAG = 2;
/** Used to indicate the type of lazy iteratees. */
-var LAZY_DROP_WHILE_FLAG = 0,
- LAZY_MAP_FLAG = 2;
+var LAZY_MAP_FLAG = 2;
/** Used for native method references. */
var arrayProto = Array.prototype,
stringProto = String.prototype;
-/** Native method references. */
-var floor = Math.floor,
- push = arrayProto.push;
-
/* Native method references for those with the same name as other `lodash` methods. */
-var nativeMax = Math.max,
+var nativeFloor = Math.floor,
+ nativeMax = Math.max,
nativeMin = Math.min;
+/** Used as references for `-Infinity` and `Infinity`. */
+var POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
+
// wrap `_.mixin` so it works when provided only one argument
var mixin = (function(func) {
return function(object, source, options) {
@@ -101,6 +101,7 @@ lodash.curry = func.curry;
lodash.curryRight = func.curryRight;
lodash.debounce = func.debounce;
lodash.defaults = object.defaults;
+lodash.defaultsDeep = object.defaultsDeep;
lodash.defer = func.defer;
lodash.delay = func.delay;
lodash.difference = array.difference;
@@ -139,6 +140,7 @@ lodash.merge = object.merge;
lodash.method = utility.method;
lodash.methodOf = utility.methodOf;
lodash.mixin = mixin;
+lodash.modArgs = func.modArgs;
lodash.negate = func.negate;
lodash.omit = object.omit;
lodash.once = func.once;
@@ -212,6 +214,7 @@ lodash.add = math.add;
lodash.attempt = utility.attempt;
lodash.camelCase = string.camelCase;
lodash.capitalize = string.capitalize;
+lodash.ceil = math.ceil;
lodash.clone = lang.clone;
lodash.cloneDeep = lang.cloneDeep;
lodash.deburr = string.deburr;
@@ -227,6 +230,7 @@ lodash.findLastIndex = array.findLastIndex;
lodash.findLastKey = object.findLastKey;
lodash.findWhere = collection.findWhere;
lodash.first = array.first;
+lodash.floor = math.floor;
lodash.get = object.get;
lodash.gt = lang.gt;
lodash.gte = lang.gte;
@@ -274,6 +278,7 @@ lodash.reduce = collection.reduce;
lodash.reduceRight = collection.reduceRight;
lodash.repeat = string.repeat;
lodash.result = object.result;
+lodash.round = math.round;
lodash.size = collection.size;
lodash.snakeCase = string.snakeCase;
lodash.some = collection.some;
@@ -342,48 +347,20 @@ arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'],
lodash[methodName].placeholder = lodash;
});
-// Add `LazyWrapper` methods that accept an `iteratee` value.
-arrayEach(['dropWhile', 'filter', 'map', 'takeWhile'], function(methodName, type) {
- var isFilter = type != LAZY_MAP_FLAG,
- isDropWhile = type == LAZY_DROP_WHILE_FLAG;
-
- LazyWrapper.prototype[methodName] = function(iteratee, thisArg) {
- var filtered = this.__filtered__,
- result = (filtered && isDropWhile) ? new LazyWrapper(this) : this.clone(),
- iteratees = result.__iteratees__ || (result.__iteratees__ = []);
-
- iteratees.push({
- 'done': false,
- 'count': 0,
- 'index': 0,
- 'iteratee': baseCallback(iteratee, thisArg, 1),
- 'limit': -1,
- 'type': type
- });
-
- result.__filtered__ = filtered || isFilter;
- return result;
- };
-});
-
// Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
arrayEach(['drop', 'take'], function(methodName, index) {
- var whileName = methodName + 'While';
-
LazyWrapper.prototype[methodName] = function(n) {
- var filtered = this.__filtered__,
- result = (filtered && !index) ? this.dropWhile() : this.clone();
+ var filtered = this.__filtered__;
+ if (filtered && !index) {
+ return new LazyWrapper(this);
+ }
+ n = n == null ? 1 : nativeMax(nativeFloor(n) || 0, 0);
- n = n == null ? 1 : nativeMax(floor(n) || 0, 0);
+ var result = this.clone();
if (filtered) {
- if (index) {
- result.__takeCount__ = nativeMin(result.__takeCount__, n);
- } else {
- last(result.__iteratees__).limit = n;
- }
+ result.__takeCount__ = nativeMin(result.__takeCount__, n);
} else {
- var views = result.__views__ || (result.__views__ = []);
- views.push({ 'size': n, 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') });
+ result.__views__.push({ 'size': n, 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') });
}
return result;
};
@@ -391,9 +368,18 @@ arrayEach(['drop', 'take'], function(methodName, index) {
LazyWrapper.prototype[methodName + 'Right'] = function(n) {
return this.reverse()[methodName](n).reverse();
};
+});
- LazyWrapper.prototype[methodName + 'RightWhile'] = function(predicate, thisArg) {
- return this.reverse()[whileName](predicate, thisArg).reverse();
+// Add `LazyWrapper` methods that accept an `iteratee` value.
+arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
+ var type = index + 1,
+ isFilter = type != LAZY_MAP_FLAG;
+
+ LazyWrapper.prototype[methodName] = function(iteratee, thisArg) {
+ var result = this.clone();
+ result.__iteratees__.push({ 'iteratee': baseCallback(iteratee, thisArg, 1), 'type': type });
+ result.__filtered__ = result.__filtered__ || isFilter;
+ return result;
};
});
@@ -411,7 +397,7 @@ arrayEach(['initial', 'rest'], function(methodName, index) {
var dropName = 'drop' + (index ? '' : 'Right');
LazyWrapper.prototype[methodName] = function() {
- return this[dropName](1);
+ return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
};
});
@@ -440,10 +426,13 @@ LazyWrapper.prototype.slice = function(start, end) {
start = start == null ? 0 : (+start || 0);
var result = this;
+ if (result.__filtered__ && (start > 0 || end < 0)) {
+ return new LazyWrapper(result);
+ }
if (start < 0) {
- result = this.takeRight(-start);
+ result = result.takeRight(-start);
} else if (start) {
- result = this.drop(start);
+ result = result.drop(start);
}
if (end !== undefined) {
end = (+end || 0);
@@ -452,21 +441,25 @@ LazyWrapper.prototype.slice = function(start, end) {
return result;
};
+LazyWrapper.prototype.takeRightWhile = function(predicate, thisArg) {
+ return this.reverse().takeWhile(predicate, thisArg).reverse();
+};
+
LazyWrapper.prototype.toArray = function() {
- return this.drop(0);
+ return this.take(POSITIVE_INFINITY);
};
// Add `LazyWrapper` methods to `lodash.prototype`.
baseForOwn(LazyWrapper.prototype, function(func, methodName) {
- var lodashFunc = lodash[methodName];
+ var checkIteratee = /^(?:filter|map|reject)|While$/.test(methodName),
+ retUnwrapped = /^(?:first|last)$/.test(methodName),
+ lodashFunc = lodash[retUnwrapped ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName];
+
if (!lodashFunc) {
return;
}
- var checkIteratee = /^(?:filter|map|reject)|While$/.test(methodName),
- retUnwrapped = /^(?:first|last)$/.test(methodName);
-
lodash.prototype[methodName] = function() {
- var args = arguments,
+ var args = retUnwrapped ? [1] : arguments,
chainAll = this.__chain__,
value = this.__wrapped__,
isHybrid = !!this.__actions__.length,
@@ -475,28 +468,30 @@ baseForOwn(LazyWrapper.prototype, function(func, methodName) {
useLazy = isLazy || isArray(value);
if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
- // avoid lazy use if the iteratee has a "length" value other than `1`
+ // Avoid lazy use if the iteratee has a "length" value other than `1`.
isLazy = useLazy = false;
}
- var onlyLazy = isLazy && !isHybrid;
- if (retUnwrapped && !chainAll) {
- return onlyLazy
- ? func.call(value)
- : lodashFunc.call(lodash, this.value());
- }
var interceptor = function(value) {
- var otherArgs = [value];
- push.apply(otherArgs, args);
- return lodashFunc.apply(lodash, otherArgs);
+ return (retUnwrapped && chainAll)
+ ? lodashFunc(value, 1)[0]
+ : lodashFunc.apply(undefined, arrayPush([value], args));
};
- if (useLazy) {
- var wrapper = onlyLazy ? value : new LazyWrapper(this),
- result = func.apply(wrapper, args);
- if (!retUnwrapped && (isHybrid || result.__actions__)) {
- var actions = result.__actions__ || (result.__actions__ = []);
- actions.push({ 'func': thru, 'args': [interceptor], 'thisArg': lodash });
+ var action = { 'func': thru, 'args': [interceptor], 'thisArg': undefined },
+ onlyLazy = isLazy && !isHybrid;
+
+ if (retUnwrapped && !chainAll) {
+ if (onlyLazy) {
+ value = value.clone();
+ value.__actions__.push(action);
+ return func.call(value);
}
+ return lodashFunc.call(undefined, this.value())[0];
+ }
+ if (!retUnwrapped && useLazy) {
+ value = onlyLazy ? value : new LazyWrapper(this);
+ var result = func.apply(value, args);
+ result.__actions__.push(action);
return new LodashWrapper(result, chainAll);
}
return this.thru(interceptor);
@@ -504,7 +499,7 @@ baseForOwn(LazyWrapper.prototype, function(func, methodName) {
});
// Add `Array` and `String` methods to `lodash.prototype`.
-arrayEach(['concat', 'join', 'pop', 'push', 'replace', 'shift', 'sort', 'splice', 'split', 'unshift'], function(methodName) {
+arrayEach(['join', 'pop', 'push', 'replace', 'shift', 'sort', 'splice', 'split', 'unshift'], function(methodName) {
var func = (/^(?:replace|split)$/.test(methodName) ? stringProto : arrayProto)[methodName],
chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
retUnwrapped = /^(?:join|pop|replace|shift)$/.test(methodName);
@@ -531,7 +526,7 @@ baseForOwn(LazyWrapper.prototype, function(func, methodName) {
}
});
-realNames[createHybridWrapper(null, BIND_KEY_FLAG).name] = [{ 'name': 'wrapper', 'func': null }];
+realNames[createHybridWrapper(undefined, BIND_KEY_FLAG).name] = [{ 'name': 'wrapper', 'func': undefined }];
// Add functions to the lazy wrapper.
LazyWrapper.prototype.clone = lazyClone;
@@ -541,6 +536,7 @@ LazyWrapper.prototype.value = lazyValue;
// Add chaining functions to the `lodash` wrapper.
lodash.prototype.chain = chain.wrapperChain;
lodash.prototype.commit = chain.commit;
+lodash.prototype.concat = chain.concat;
lodash.prototype.plant = chain.plant;
lodash.prototype.reverse = chain.reverse;
lodash.prototype.toString = chain.toString;
diff --git a/math.js b/math.js
index b91229c03..23272eedf 100644
--- a/math.js
+++ b/math.js
@@ -1,11 +1,17 @@
import add from './math/add';
+import ceil from './math/ceil';
+import floor from './math/floor';
import max from './math/max';
import min from './math/min';
+import round from './math/round';
import sum from './math/sum';
export default {
'add': add,
+ 'ceil': ceil,
+ 'floor': floor,
'max': max,
'min': min,
+ 'round': round,
'sum': sum
};
diff --git a/math/ceil.js b/math/ceil.js
new file mode 100644
index 000000000..7ffa2b423
--- /dev/null
+++ b/math/ceil.js
@@ -0,0 +1,25 @@
+import createRound from '../internal/createRound';
+
+/**
+ * Calculates `n` rounded up to `precision`.
+ *
+ * @static
+ * @memberOf _
+ * @category Math
+ * @param {number} n The number to round up.
+ * @param {number} [precision=0] The precision to round up to.
+ * @returns {number} Returns the rounded up number.
+ * @example
+ *
+ * _.ceil(4.006);
+ * // => 5
+ *
+ * _.ceil(6.004, 2);
+ * // => 6.01
+ *
+ * _.ceil(6040, -2);
+ * // => 6100
+ */
+var ceil = createRound('ceil');
+
+export default ceil;
diff --git a/math/floor.js b/math/floor.js
new file mode 100644
index 000000000..bfb24e660
--- /dev/null
+++ b/math/floor.js
@@ -0,0 +1,25 @@
+import createRound from '../internal/createRound';
+
+/**
+ * Calculates `n` rounded down to `precision`.
+ *
+ * @static
+ * @memberOf _
+ * @category Math
+ * @param {number} n The number to round down.
+ * @param {number} [precision=0] The precision to round down to.
+ * @returns {number} Returns the rounded down number.
+ * @example
+ *
+ * _.floor(4.006);
+ * // => 4
+ *
+ * _.floor(0.046, 2);
+ * // => 0.04
+ *
+ * _.floor(4060, -2);
+ * // => 4000
+ */
+var floor = createRound('floor');
+
+export default floor;
diff --git a/math/round.js b/math/round.js
new file mode 100644
index 000000000..9b2728893
--- /dev/null
+++ b/math/round.js
@@ -0,0 +1,25 @@
+import createRound from '../internal/createRound';
+
+/**
+ * Calculates `n` rounded to `precision`.
+ *
+ * @static
+ * @memberOf _
+ * @category Math
+ * @param {number} n The number to round.
+ * @param {number} [precision=0] The precision to round to.
+ * @returns {number} Returns the rounded number.
+ * @example
+ *
+ * _.round(4.006);
+ * // => 4
+ *
+ * _.round(4.006, 2);
+ * // => 4.01
+ *
+ * _.round(4060, -2);
+ * // => 4100
+ */
+var round = createRound('round');
+
+export default round;
diff --git a/math/sum.js b/math/sum.js
index a614d9b5b..536ec7c7c 100644
--- a/math/sum.js
+++ b/math/sum.js
@@ -39,13 +39,11 @@ import toIterable from '../internal/toIterable';
*/
function sum(collection, iteratee, thisArg) {
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
- iteratee = null;
+ iteratee = undefined;
}
- var noIteratee = iteratee == null;
-
- iteratee = noIteratee ? iteratee : baseCallback(iteratee, thisArg, 3);
- return noIteratee
- ? arraySum(isArray(collection) ? collection : toIterable(collection))
+ iteratee = baseCallback(iteratee, thisArg, 3);
+ return iteratee.length == 1
+ ? arraySum(isArray(collection) ? collection : toIterable(collection), iteratee)
: baseSum(collection, iteratee);
}
diff --git a/number/inRange.js b/number/inRange.js
index 35d688c55..030db7402 100644
--- a/number/inRange.js
+++ b/number/inRange.js
@@ -35,7 +35,7 @@ var nativeMax = Math.max,
*/
function inRange(value, start, end) {
start = +start || 0;
- if (typeof end === 'undefined') {
+ if (end === undefined) {
end = start;
start = 0;
} else {
diff --git a/number/random.js b/number/random.js
index dcc3ea9e2..7ac049bb5 100644
--- a/number/random.js
+++ b/number/random.js
@@ -34,7 +34,7 @@ var nativeMin = Math.min,
*/
function random(min, max, floating) {
if (floating && isIterateeCall(min, max, floating)) {
- max = floating = null;
+ max = floating = undefined;
}
var noMin = min == null,
noMax = max == null;
diff --git a/object.js b/object.js
index 4ff256800..87dddcc70 100644
--- a/object.js
+++ b/object.js
@@ -1,6 +1,7 @@
import assign from './object/assign';
import create from './object/create';
import defaults from './object/defaults';
+import defaultsDeep from './object/defaultsDeep';
import extend from './object/extend';
import findKey from './object/findKey';
import findLastKey from './object/findLastKey';
@@ -31,6 +32,7 @@ export default {
'assign': assign,
'create': create,
'defaults': defaults,
+ 'defaultsDeep': defaultsDeep,
'extend': extend,
'findKey': findKey,
'findLastKey': findLastKey,
diff --git a/object/assign.js b/object/assign.js
index b11601740..4c1c68c81 100644
--- a/object/assign.js
+++ b/object/assign.js
@@ -10,7 +10,7 @@ import createAssigner from '../internal/createAssigner';
* (objectValue, sourceValue, key, object, source).
*
* **Note:** This method mutates `object` and is based on
- * [`Object.assign`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign).
+ * [`Object.assign`](http://ecma-international.org/ecma-262/6.0/#sec-object.assign).
*
* @static
* @memberOf _
diff --git a/object/create.js b/object/create.js
index 1d4dcd49d..2cec13935 100644
--- a/object/create.js
+++ b/object/create.js
@@ -39,7 +39,7 @@ import isIterateeCall from '../internal/isIterateeCall';
function create(prototype, properties, guard) {
var result = baseCreate(prototype);
if (guard && isIterateeCall(prototype, properties, guard)) {
- properties = null;
+ properties = undefined;
}
return properties ? baseAssign(result, properties) : result;
}
diff --git a/object/defaults.js b/object/defaults.js
index eb1ff58d6..70a561dda 100644
--- a/object/defaults.js
+++ b/object/defaults.js
@@ -1,6 +1,6 @@
import assign from './assign';
import assignDefaults from '../internal/assignDefaults';
-import restParam from '../function/restParam';
+import createDefaults from '../internal/createDefaults';
/**
* Assigns own enumerable properties of source object(s) to the destination
@@ -20,13 +20,6 @@ import restParam from '../function/restParam';
* _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
* // => { 'user': 'barney', 'age': 36 }
*/
-var defaults = restParam(function(args) {
- var object = args[0];
- if (object == null) {
- return object;
- }
- args.push(assignDefaults);
- return assign.apply(undefined, args);
-});
+var defaults = createDefaults(assign, assignDefaults);
export default defaults;
diff --git a/object/defaultsDeep.js b/object/defaultsDeep.js
new file mode 100644
index 000000000..21c73b3b5
--- /dev/null
+++ b/object/defaultsDeep.js
@@ -0,0 +1,25 @@
+import createDefaults from '../internal/createDefaults';
+import merge from './merge';
+import mergeDefaults from '../internal/mergeDefaults';
+
+/**
+ * This method is like `_.defaults` except that it recursively assigns
+ * default properties.
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} [sources] The source objects.
+ * @returns {Object} Returns `object`.
+ * @example
+ *
+ * _.defaultsDeep({ 'user': { 'name': 'barney' } }, { 'user': { 'name': 'fred', 'age': 36 } });
+ * // => { 'user': { 'name': 'barney', 'age': 36 } }
+ *
+ */
+var defaultsDeep = createDefaults(merge, mergeDefaults);
+
+export default defaultsDeep;
diff --git a/object/invert.js b/object/invert.js
index 1d61598e0..6f1e499ef 100644
--- a/object/invert.js
+++ b/object/invert.js
@@ -32,7 +32,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
*/
function invert(object, multiValue, guard) {
if (guard && isIterateeCall(object, multiValue, guard)) {
- multiValue = null;
+ multiValue = undefined;
}
var index = -1,
props = keys(object),
diff --git a/object/keys.js b/object/keys.js
index f20a081ed..7ef34b37c 100644
--- a/object/keys.js
+++ b/object/keys.js
@@ -10,7 +10,7 @@ var nativeKeys = getNative(Object, 'keys');
* Creates an array of the own enumerable property names of `object`.
*
* **Note:** Non-object values are coerced to objects. See the
- * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.keys)
+ * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
* for more details.
*
* @static
@@ -34,7 +34,7 @@ var nativeKeys = getNative(Object, 'keys');
* // => ['0', '1']
*/
var keys = !nativeKeys ? shimKeys : function(object) {
- var Ctor = object == null ? null : object.constructor;
+ var Ctor = object == null ? undefined : object.constructor;
if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
(typeof object != 'function' && isArrayLike(object))) {
return shimKeys(object);
diff --git a/object/transform.js b/object/transform.js
index c350146d4..d2bee9b84 100644
--- a/object/transform.js
+++ b/object/transform.js
@@ -46,7 +46,7 @@ function transform(object, iteratee, accumulator, thisArg) {
if (isArr) {
accumulator = isArray(object) ? new Ctor : [];
} else {
- accumulator = baseCreate(isFunction(Ctor) ? Ctor.prototype : null);
+ accumulator = baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined);
}
} else {
accumulator = {};
diff --git a/package.json b/package.json
index c8b0fa245..a47ab4a23 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "lodash-es",
- "version": "3.9.3",
+ "version": "3.10.0",
"description": "The modern build of lodash exported as ES modules.",
"homepage": "https://lodash.com/custom-builds",
"license": "MIT",
diff --git a/string/escapeRegExp.js b/string/escapeRegExp.js
index 6008c257b..407635428 100644
--- a/string/escapeRegExp.js
+++ b/string/escapeRegExp.js
@@ -1,11 +1,11 @@
import baseToString from '../internal/baseToString';
+import escapeRegExpChar from '../internal/escapeRegExpChar';
/**
- * Used to match `RegExp` [special characters](http://www.regular-expressions.info/characters.html#special).
- * In addition to special characters the forward slash is escaped to allow for
- * easier `eval` use and `Function` compilation.
+ * Used to match `RegExp` [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns)
+ * and those outlined by [`EscapeRegExpPattern`](http://ecma-international.org/ecma-262/6.0/#sec-escaperegexppattern).
*/
-var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g,
+var reRegExpChars = /^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g,
reHasRegExpChars = RegExp(reRegExpChars.source);
/**
@@ -25,8 +25,8 @@ var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g,
function escapeRegExp(string) {
string = baseToString(string);
return (string && reHasRegExpChars.test(string))
- ? string.replace(reRegExpChars, '\\$&')
- : string;
+ ? string.replace(reRegExpChars, escapeRegExpChar)
+ : (string || '(?:)');
}
export default escapeRegExp;
diff --git a/string/pad.js b/string/pad.js
index 6e9f05315..ce8f2707e 100644
--- a/string/pad.js
+++ b/string/pad.js
@@ -2,12 +2,10 @@ import baseToString from '../internal/baseToString';
import createPadding from '../internal/createPadding';
import root from '../internal/root';
-/** Native method references. */
-var ceil = Math.ceil,
- floor = Math.floor;
-
/* Native method references for those with the same name as other `lodash` methods. */
-var nativeIsFinite = root.isFinite;
+var nativeCeil = Math.ceil,
+ nativeFloor = Math.floor,
+ nativeIsFinite = root.isFinite;
/**
* Pads `string` on the left and right sides if it's shorter than `length`.
@@ -40,8 +38,8 @@ function pad(string, length, chars) {
return string;
}
var mid = (length - strLength) / 2,
- leftLength = floor(mid),
- rightLength = ceil(mid);
+ leftLength = nativeFloor(mid),
+ rightLength = nativeCeil(mid);
chars = createPadding('', rightLength, chars);
return chars.slice(0, leftLength) + string + chars;
diff --git a/string/parseInt.js b/string/parseInt.js
index 6fcf6e966..1267b9d34 100644
--- a/string/parseInt.js
+++ b/string/parseInt.js
@@ -5,18 +5,6 @@ import trim from './trim';
/** Used to detect hexadecimal string values. */
var reHasHexPrefix = /^0[xX]/;
-/** Used to detect and test for whitespace. */
-var whitespace = (
- // Basic whitespace characters.
- ' \t\x0b\f\xa0\ufeff' +
-
- // Line terminators.
- '\n\r\u2028\u2029' +
-
- // Unicode category "Zs" space separators.
- '\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000'
-);
-
/* Native method references for those with the same name as other `lodash` methods. */
var nativeParseInt = root.parseInt;
@@ -44,25 +32,16 @@ var nativeParseInt = root.parseInt;
* // => [6, 8, 10]
*/
function parseInt(string, radix, guard) {
- if (guard && isIterateeCall(string, radix, guard)) {
+ // Firefox < 21 and Opera < 15 follow ES3 for `parseInt`.
+ // Chrome fails to trim leading whitespace characters.
+ // See https://code.google.com/p/v8/issues/detail?id=3109 for more details.
+ if (guard ? isIterateeCall(string, radix, guard) : radix == null) {
radix = 0;
+ } else if (radix) {
+ radix = +radix;
}
- return nativeParseInt(string, radix);
-}
-// Fallback for environments with pre-ES5 implementations.
-if (nativeParseInt(whitespace + '08') != 8) {
- parseInt = function(string, radix, guard) {
- // Firefox < 21 and Opera < 15 follow ES3 for `parseInt`.
- // Chrome fails to trim leading whitespace characters.
- // See https://code.google.com/p/v8/issues/detail?id=3109 for more details.
- if (guard ? isIterateeCall(string, radix, guard) : radix == null) {
- radix = 0;
- } else if (radix) {
- radix = +radix;
- }
- string = trim(string);
- return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10));
- };
+ string = trim(string);
+ return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10));
}
export default parseInt;
diff --git a/string/repeat.js b/string/repeat.js
index 600415f55..7be5b0400 100644
--- a/string/repeat.js
+++ b/string/repeat.js
@@ -1,11 +1,9 @@
import baseToString from '../internal/baseToString';
import root from '../internal/root';
-/** Native method references. */
-var floor = Math.floor;
-
/* Native method references for those with the same name as other `lodash` methods. */
-var nativeIsFinite = root.isFinite;
+var nativeFloor = Math.floor,
+ nativeIsFinite = root.isFinite;
/**
* Repeats the given string `n` times.
@@ -40,7 +38,7 @@ function repeat(string, n) {
if (n % 2) {
result += string;
}
- n = floor(n / 2);
+ n = nativeFloor(n / 2);
string += string;
} while (n);
diff --git a/string/template.js b/string/template.js
index 1c9b82f92..43802125e 100644
--- a/string/template.js
+++ b/string/template.js
@@ -16,7 +16,7 @@ var reEmptyStringLeading = /\b__p \+= '';/g,
reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
-/** Used to match [ES template delimiters](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-template-literal-lexical-components). */
+/** Used to match [ES template delimiters](http://ecma-international.org/ecma-262/6.0/#sec-template-literal-lexical-components). */
var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
/** Used to ensure capturing order of template delimiters. */
@@ -127,7 +127,7 @@ function template(string, options, otherOptions) {
var settings = templateSettings.imports._.templateSettings || templateSettings;
if (otherOptions && isIterateeCall(string, options, otherOptions)) {
- options = otherOptions = null;
+ options = otherOptions = undefined;
}
string = baseToString(string);
options = assignWith(baseAssign({}, otherOptions || options), settings, assignOwnDefaults);
diff --git a/string/trunc.js b/string/trunc.js
index c1dda1074..2e7dcfde4 100644
--- a/string/trunc.js
+++ b/string/trunc.js
@@ -52,7 +52,7 @@ var reFlags = /\w*$/;
*/
function trunc(string, options, guard) {
if (guard && isIterateeCall(string, options, guard)) {
- options = null;
+ options = undefined;
}
var length = DEFAULT_TRUNC_LENGTH,
omission = DEFAULT_TRUNC_OMISSION;
diff --git a/string/words.js b/string/words.js
index be3fba9ce..7a898b7a0 100644
--- a/string/words.js
+++ b/string/words.js
@@ -29,7 +29,7 @@ var reWords = (function() {
*/
function words(string, pattern, guard) {
if (guard && isIterateeCall(string, pattern, guard)) {
- pattern = null;
+ pattern = undefined;
}
string = baseToString(string);
return string.match(pattern || reWords) || [];
diff --git a/support.js b/support.js
index 181f6a1b9..18f6803ee 100644
--- a/support.js
+++ b/support.js
@@ -1,8 +1,3 @@
-import root from './internal/root';
-
-/** Used to detect DOM support. */
-var document = (document = root.window) ? document.document : null;
-
/**
* An object environment feature flags.
*
@@ -12,25 +7,4 @@ var document = (document = root.window) ? document.document : null;
*/
var support = {};
-(function(x) {
- var Ctor = function() { this.x = x; },
- object = { '0': x, 'length': x },
- props = [];
-
- Ctor.prototype = { 'valueOf': x, 'y': x };
- for (var key in new Ctor) { props.push(key); }
-
- /**
- * Detect if the DOM is supported.
- *
- * @memberOf _.support
- * @type boolean
- */
- try {
- support.dom = document.createDocumentFragment().nodeType === 11;
- } catch(e) {
- support.dom = false;
- }
-}(1, 0));
-
export default support;
diff --git a/utility/callback.js b/utility/callback.js
index 48834cb46..bd5d9c60a 100644
--- a/utility/callback.js
+++ b/utility/callback.js
@@ -43,7 +43,7 @@ import matches from './matches';
*/
function callback(func, thisArg, guard) {
if (guard && isIterateeCall(func, thisArg, guard)) {
- thisArg = null;
+ thisArg = undefined;
}
return isObjectLike(func)
? matches(func)
diff --git a/utility/mixin.js b/utility/mixin.js
index a4231b497..d4eb600f4 100644
--- a/utility/mixin.js
+++ b/utility/mixin.js
@@ -1,15 +1,10 @@
import arrayCopy from '../internal/arrayCopy';
+import arrayPush from '../internal/arrayPush';
import baseFunctions from '../internal/baseFunctions';
import isFunction from '../lang/isFunction';
import isObject from '../lang/isObject';
import keys from '../object/keys';
-/** Used for native method references. */
-var arrayProto = Array.prototype;
-
-/** Native method references. */
-var push = arrayProto.push;
-
/**
* Adds all own enumerable function properties of a source object to the
* destination object. If `object` is a function then methods are added to
@@ -76,9 +71,7 @@ function mixin(object, source, options) {
result.__chain__ = chainAll;
return result;
}
- var args = [this.value()];
- push.apply(args, arguments);
- return func.apply(object, args);
+ return func.apply(object, arrayPush([this.value()], arguments));
};
}(func));
}
diff --git a/utility/range.js b/utility/range.js
index 211c2b42a..1955ce6bd 100644
--- a/utility/range.js
+++ b/utility/range.js
@@ -1,10 +1,8 @@
import isIterateeCall from '../internal/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,
+ nativeMax = Math.max;
/**
* Creates an array of numbers (positive and/or negative) progressing from
@@ -41,7 +39,7 @@ var nativeMax = Math.max;
*/
function range(start, end, step) {
if (step && isIterateeCall(start, end, step)) {
- end = step = null;
+ end = step = undefined;
}
start = +start || 0;
step = step == null ? 1 : (+step || 0);
@@ -55,7 +53,7 @@ function range(start, end, step) {
// Use `Array(length)` so engines like Chakra and V8 avoid slower modes.
// See https://youtu.be/XAqIpGU8ZZk#t=17m25s for more details.
var index = -1,
- length = nativeMax(ceil((end - start) / (step || 1)), 0),
+ length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
result = Array(length);
while (++index < length) {
diff --git a/utility/times.js b/utility/times.js
index 33de2e08e..c4a2c2cde 100644
--- a/utility/times.js
+++ b/utility/times.js
@@ -1,11 +1,9 @@
import bindCallback from '../internal/bindCallback';
import root from '../internal/root';
-/** Native method references. */
-var floor = Math.floor;
-
/* Native method references for those with the same name as other `lodash` methods. */
-var nativeIsFinite = root.isFinite,
+var nativeFloor = Math.floor,
+ nativeIsFinite = root.isFinite,
nativeMin = Math.min;
/** Used as references for the maximum length and index of an array. */
@@ -39,7 +37,7 @@ var MAX_ARRAY_LENGTH = 4294967295;
* // => also invokes `mage.castSpell(n)` three times
*/
function times(n, iteratee, thisArg) {
- n = floor(n);
+ n = nativeFloor(n);
// Exit early to avoid a JSC JIT bug in Safari 8
// where `Array(0)` is treated as `Array(1)`.