diff --git a/README.md b/README.md
index 24f94e53f..b44492ce3 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# lodash v3.4.0
+# lodash v3.5.0
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) exported as [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) modules.
@@ -28,7 +28,7 @@ var array = require('lodash/array');
var chunk = require('lodash/array/chunk');
```
-See the [package source](https://github.com/lodash/lodash/tree/3.4.0-npm) for more details.
+See the [package source](https://github.com/lodash/lodash/tree/3.5.0-npm) for more details.
**Note:**
Don’t assign values to the [special variable](http://nodejs.org/api/repl.html#repl_repl_features) `_` when in the REPL.
@@ -39,8 +39,8 @@ Install [n_](https://www.npmjs.com/package/n_) for a REPL that includes lodash b
lodash is also available in a variety of other builds & module formats.
* npm packages for [modern](https://www.npmjs.com/package/lodash), [compatibility](https://www.npmjs.com/package/lodash-compat), & [per method](https://www.npmjs.com/browse/keyword/lodash-modularized) builds
- * AMD modules for [modern](https://github.com/lodash/lodash/tree/3.4.0-amd) & [compatibility](https://github.com/lodash/lodash-compat/tree/3.4.0-amd) builds
- * ES modules for the [modern](https://github.com/lodash/lodash/tree/3.4.0-es) build
+ * AMD modules for [modern](https://github.com/lodash/lodash/tree/3.5.0-amd) & [compatibility](https://github.com/lodash/lodash-compat/tree/3.5.0-amd) builds
+ * ES modules for the [modern](https://github.com/lodash/lodash/tree/3.5.0-es) build
## Further Reading
@@ -112,5 +112,5 @@ lodash is also available in a variety of other builds & module formats.
## Support
-Tested in Chrome 40-41, Firefox 35-36, IE 6-11, Opera 26-27, Safari 5-8, io.js 1.4.3, Node.js 0.8.28, 0.10.36, & 0.12.0, PhantomJS 1.9.8, RingoJS 0.11, & Rhino 1.7RC5.
+Tested in Chrome 40-41, Firefox 35-36, IE 6-11, Opera 26-27, Safari 5-8, io.js 1.5.0, Node.js 0.8.28, 0.10.36, & 0.12.0, PhantomJS 1.9.8, RingoJS 0.11, & Rhino 1.7RC5.
Automated [browser](https://saucelabs.com/u/lodash) & [CI](https://travis-ci.org/lodash/lodash/) test runs are available. Special thanks to [Sauce Labs](https://saucelabs.com/) for providing automated browser testing.
diff --git a/array/indexOf.js b/array/indexOf.js
index d0155a733..b6d2a7d0a 100644
--- a/array/indexOf.js
+++ b/array/indexOf.js
@@ -47,7 +47,10 @@ function indexOf(array, value, fromIndex) {
var index = binaryIndex(array, value),
other = array[index];
- return (value === value ? value === other : other !== other) ? index : -1;
+ if (value === value ? (value === other) : (other !== other)) {
+ return index;
+ }
+ return -1;
}
return baseIndexOf(array, value, fromIndex || 0);
}
diff --git a/array/lastIndexOf.js b/array/lastIndexOf.js
index 8d6650b08..02b806269 100644
--- a/array/lastIndexOf.js
+++ b/array/lastIndexOf.js
@@ -41,7 +41,10 @@ function lastIndexOf(array, value, fromIndex) {
} else if (fromIndex) {
index = binaryIndex(array, value, true) - 1;
var other = array[index];
- return (value === value ? value === other : other !== other) ? index : -1;
+ if (value === value ? (value === other) : (other !== other)) {
+ return index;
+ }
+ return -1;
}
if (value !== value) {
return indexOfNaN(array, index, true);
diff --git a/chain/lodash.js b/chain/lodash.js
index 41e3e6f91..8ac40aeec 100644
--- a/chain/lodash.js
+++ b/chain/lodash.js
@@ -27,9 +27,14 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* Chaining is supported in custom builds as long as the `_#value` method is
* directly or indirectly included in the build.
*
- * In addition to lodash methods, wrappers also have the following `Array` methods:
- * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`,
- * and `unshift`
+ * In addition to lodash methods, wrappers have `Array` and `String` methods.
+ *
+ * The wrapper `Array` methods are:
+ * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`,
+ * `splice`, and `unshift`
+ *
+ * The wrapper `String` methods are:
+ * `replace` and `split`
*
* The wrapper methods that support shortcut fusion are:
* `compact`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`,
diff --git a/collection/sortByOrder.js b/collection/sortByOrder.js
index be035257d..4528e6db9 100644
--- a/collection/sortByOrder.js
+++ b/collection/sortByOrder.js
@@ -14,13 +14,14 @@ var baseSortByOrder = require('../internal/baseSortByOrder'),
* @param {Array|Object|string} collection The collection to iterate over.
* @param {string[]} props The property names to sort by.
* @param {boolean[]} orders The sort orders of `props`.
+ * @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`.
* @returns {Array} Returns the new sorted array.
* @example
*
* var users = [
- * { 'user': 'barney', 'age': 36 },
- * { 'user': 'fred', 'age': 40 },
* { 'user': 'barney', 'age': 26 },
+ * { 'user': 'fred', 'age': 40 },
+ * { 'user': 'barney', 'age': 36 },
* { 'user': 'fred', 'age': 30 }
* ];
*
diff --git a/index.js b/index.js
index 88eabdae8..52b19d79b 100644
--- a/index.js
+++ b/index.js
@@ -1,6 +1,6 @@
/**
* @license
- * lodash 3.4.0 (Custom Build)
+ * lodash 3.5.0 (Custom Build)
* Build: `lodash modern -d -o ./index.js`
* Copyright 2012-2015 The Dojo Foundation
* Based on Underscore.js 1.8.2
@@ -13,7 +13,7 @@
var undefined;
/** Used as the semantic version number. */
- var VERSION = '3.4.0';
+ var VERSION = '3.5.0';
/** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1,
@@ -36,8 +36,8 @@
/** Used to indicate the type of lazy iteratees. */
var LAZY_DROP_WHILE_FLAG = 0,
- LAZY_MAP_FLAG = 2,
- LAZY_TAKE_WHILE_FLAG = 3;
+ LAZY_FILTER_FLAG = 1,
+ LAZY_MAP_FLAG = 2;
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
@@ -438,9 +438,8 @@
if (result) {
if (index >= ordersLength) {
return result;
- } else {
- return orders[index] ? result : result * -1;
}
+ return result * (orders[index] ? 1 : -1);
}
}
// Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
@@ -686,7 +685,8 @@
/** Used for native method references. */
var arrayProto = Array.prototype,
- objectProto = Object.prototype;
+ objectProto = Object.prototype,
+ stringProto = String.prototype;
/** Used to detect DOM support. */
var document = (document = context.window) && document.document;
@@ -798,9 +798,14 @@
* Chaining is supported in custom builds as long as the `_#value` method is
* directly or indirectly included in the build.
*
- * In addition to lodash methods, wrappers also have the following `Array` methods:
- * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`,
- * and `unshift`
+ * In addition to lodash methods, wrappers have `Array` and `String` methods.
+ *
+ * The wrapper `Array` methods are:
+ * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`,
+ * `splice`, and `unshift`
+ *
+ * The wrapper `String` methods are:
+ * `replace` and `split`
*
* The wrapper methods that support shortcut fusion are:
* `compact`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`,
@@ -1061,7 +1066,6 @@
result.__actions__ = actions ? arrayCopy(actions) : null;
result.__dir__ = this.__dir__;
- result.__dropCount__ = this.__dropCount__;
result.__filtered__ = this.__filtered__;
result.__iteratees__ = iteratees ? arrayCopy(iteratees) : null;
result.__takeCount__ = this.__takeCount__;
@@ -1108,9 +1112,8 @@
start = view.start,
end = view.end,
length = end - start,
- dropCount = this.__dropCount__,
+ index = isRight ? end : (start - 1),
takeCount = nativeMin(length, this.__takeCount__),
- index = isRight ? end : start - 1,
iteratees = this.__iteratees__,
iterLength = iteratees ? iteratees.length : 0,
resIndex = 0,
@@ -1128,28 +1131,32 @@
iteratee = data.iteratee,
type = data.type;
- if (type != LAZY_DROP_WHILE_FLAG) {
- var computed = iteratee(value);
- } else {
- data.done = data.done && (isRight ? index < data.index : index > data.index);
+ 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;
- computed = data.done || (data.done = !iteratee(value));
- }
- if (type == LAZY_MAP_FLAG) {
- value = computed;
- } else if (!computed) {
- if (type == LAZY_TAKE_WHILE_FLAG) {
- break outer;
- } else {
- continue outer;
+ 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 (dropCount) {
- dropCount--;
- } else {
- result[resIndex++] = value;
- }
+ result[resIndex++] = value;
}
return result;
}
@@ -1569,7 +1576,7 @@
value = object[key],
result = customizer(value, source[key], key, object, source);
- if ((result === result ? result !== value : value === value) ||
+ if ((result === result ? (result !== value) : (value === value)) ||
(typeof value == 'undefined' && !(key in object))) {
object[key] = result;
}
@@ -1916,7 +1923,7 @@
if (end < 0) {
end += length;
}
- length = start > end ? 0 : end >>> 0;
+ length = start > end ? 0 : (end >>> 0);
start >>>= 0;
while (start < length) {
@@ -2403,7 +2410,7 @@
result = srcValue;
}
if ((isSrcArr || typeof result != 'undefined') &&
- (isCommon || (result === result ? result !== value : value === value))) {
+ (isCommon || (result === result ? (result !== value) : (value === value)))) {
object[key] = result;
}
});
@@ -2463,7 +2470,7 @@
if (isCommon) {
// Recursively merge objects and arrays (susceptible to call stack limits).
object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);
- } else if (result === result ? result !== value : value === value) {
+ } else if (result === result ? (result !== value) : (value === value)) {
object[key] = result;
}
}
@@ -2575,7 +2582,7 @@
if (end < 0) {
end += length;
}
- length = start > end ? 0 : (end - start) >>> 0;
+ length = start > end ? 0 : ((end - start) >>> 0);
start >>>= 0;
var result = Array(length);
@@ -3046,7 +3053,8 @@
var Ctor = createCtorWrapper(func);
function wrapper() {
- return (this instanceof wrapper ? Ctor : func).apply(thisArg, arguments);
+ var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
+ return fn.apply(thisArg, arguments);
}
return wrapper;
}
@@ -3073,7 +3081,7 @@
return function() {
var length = arguments.length,
index = length,
- fromIndex = fromRight ? length - 1 : 0;
+ fromIndex = fromRight ? (length - 1) : 0;
if (!length) {
return function() { return arguments[0]; };
@@ -3249,7 +3257,8 @@
if (isAry && ary < args.length) {
args.length = ary;
}
- return (this instanceof wrapper ? (Ctor || createCtorWrapper(func)) : func).apply(thisBinding, args);
+ var fn = (this && this !== root && this instanceof wrapper) ? (Ctor || createCtorWrapper(func)) : func;
+ return fn.apply(thisBinding, args);
}
return wrapper;
}
@@ -3308,7 +3317,8 @@
while (argsLength--) {
args[leftIndex++] = arguments[++argsIndex];
}
- return (this instanceof wrapper ? Ctor : func).apply(isBind ? thisArg : this, args);
+ var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
+ return fn.apply(isBind ? thisArg : this, args);
}
return wrapper;
}
@@ -3526,8 +3536,10 @@
othCtor = other.constructor;
// Non `Object` object instances with different constructors are not equal.
- if (objCtor != othCtor && ('constructor' in object && 'constructor' in other) &&
- !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) {
+ if (objCtor != othCtor &&
+ ('constructor' in object && 'constructor' in other) &&
+ !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
+ typeof othCtor == 'function' && othCtor instanceof othCtor)) {
return false;
}
}
@@ -3553,7 +3565,8 @@
baseEach(collection, function(value, index, collection) {
var current = iteratee(value, index, collection);
- if ((isMin ? current < computed : current > computed) || (current === exValue && current === result)) {
+ if ((isMin ? (current < computed) : (current > computed)) ||
+ (current === exValue && current === result)) {
computed = current;
result = value;
}
@@ -3765,7 +3778,7 @@
}
if (prereq) {
var other = object[index];
- return value === value ? value === other : other !== other;
+ return value === value ? (value === other) : (other !== other);
}
return false;
}
@@ -4626,7 +4639,10 @@
var index = binaryIndex(array, value),
other = array[index];
- return (value === value ? value === other : other !== other) ? index : -1;
+ if (value === value ? (value === other) : (other !== other)) {
+ return index;
+ }
+ return -1;
}
return baseIndexOf(array, value, fromIndex || 0);
}
@@ -4762,7 +4778,10 @@
} else if (fromIndex) {
index = binaryIndex(array, value, true) - 1;
var other = array[index];
- return (value === value ? value === other : other !== other) ? index : -1;
+ if (value === value ? (value === other) : (other !== other)) {
+ return index;
+ }
+ return -1;
}
if (value !== value) {
return indexOfNaN(array, index, true);
@@ -6784,13 +6803,14 @@
* @param {Array|Object|string} collection The collection to iterate over.
* @param {string[]} props The property names to sort by.
* @param {boolean[]} orders The sort orders of `props`.
+ * @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`.
* @returns {Array} Returns the new sorted array.
* @example
*
* var users = [
- * { 'user': 'barney', 'age': 36 },
- * { 'user': 'fred', 'age': 40 },
* { 'user': 'barney', 'age': 26 },
+ * { 'user': 'fred', 'age': 40 },
+ * { 'user': 'barney', 'age': 36 },
* { 'user': 'fred', 'age': 30 }
* ];
*
@@ -8036,7 +8056,7 @@
*/
function isElement(value) {
return (value && value.nodeType === 1 && isObjectLike(value) &&
- objToString.call(value).indexOf('Element') > -1) || false;
+ (objToString.call(value).indexOf('Element') > -1)) || false;
}
// Fallback for environments without DOM support.
if (!support.dom) {
@@ -9040,7 +9060,7 @@
length = object.length;
}
if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
- (typeof object != 'function' && (length && isLength(length)))) {
+ (typeof object != 'function' && (length && isLength(length)))) {
return shimKeys(object);
}
return isObject(object) ? nativeKeys(object) : [];
@@ -9644,7 +9664,11 @@
target = (target + '');
var length = string.length;
- position = (typeof position == 'undefined' ? length : nativeMin(position < 0 ? 0 : (+position || 0), length)) - target.length;
+ position = typeof position == 'undefined'
+ ? length
+ : nativeMin(position < 0 ? 0 : (+position || 0), length);
+
+ position -= target.length;
return position >= 0 && string.indexOf(target, position) == position;
}
@@ -9986,7 +10010,10 @@
*/
function startsWith(string, target, position) {
string = baseToString(string);
- position = position == null ? 0 : nativeMin(position < 0 ? 0 : (+position || 0), string.length);
+ position = position == null
+ ? 0
+ : nativeMin(position < 0 ? 0 : (+position || 0), string.length);
+
return string.lastIndexOf(target, position) == position;
}
@@ -10336,7 +10363,7 @@
if (options != null) {
if (isObject(options)) {
var separator = 'separator' in options ? options.separator : separator;
- length = 'length' in options ? +options.length || 0 : length;
+ length = 'length' in options ? (+options.length || 0) : length;
omission = 'omission' in options ? baseToString(options.omission) : omission;
} else {
length = +options || 0;
@@ -10454,7 +10481,7 @@
function attempt() {
var func = arguments[0],
length = arguments.length,
- args = Array(length ? length - 1 : 0);
+ args = Array(length ? (length - 1) : 0);
while (--length > 0) {
args[length - 1] = arguments[length];
@@ -10685,7 +10712,11 @@
var chainAll = this.__chain__;
if (chain || chainAll) {
var result = object(this.__wrapped__);
- (result.__actions__ = arrayCopy(this.__actions__)).push({ 'func': func, 'args': arguments, 'thisArg': object });
+ (result.__actions__ = arrayCopy(this.__actions__)).push({
+ 'func': func,
+ 'args': arguments,
+ 'thisArg': object
+ });
result.__chain__ = chainAll;
return result;
}
@@ -11348,24 +11379,35 @@
result = (filtered && isDropWhile) ? new LazyWrapper(this) : this.clone(),
iteratees = result.__iteratees__ || (result.__iteratees__ = []);
+ iteratees.push({
+ 'done': false,
+ 'count': 0,
+ 'index': 0,
+ 'iteratee': getCallback(iteratee, thisArg, 1),
+ 'limit': -1,
+ 'type': type
+ });
+
result.__filtered__ = filtered || isFilter;
- iteratees.push({ 'done': false, 'index': 0, 'iteratee': getCallback(iteratee, thisArg, 1), 'type': type });
return result;
};
});
// Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
arrayEach(['drop', 'take'], function(methodName, index) {
- var countName = '__' + methodName + 'Count__',
- whileName = methodName + 'While';
+ var whileName = methodName + 'While';
LazyWrapper.prototype[methodName] = function(n) {
- n = n == null ? 1 : nativeMax(floor(n) || 0, 0);
+ var filtered = this.__filtered__,
+ result = (filtered && !index) ? this.dropWhile() : this.clone();
- var result = this.clone();
- if (result.__filtered__) {
- var value = result[countName];
- result[countName] = index ? nativeMin(value, n) : (value + n);
+ n = n == null ? 1 : nativeMax(floor(n) || 0, 0);
+ if (filtered) {
+ if (index) {
+ result.__takeCount__ = nativeMin(result.__takeCount__, n);
+ } else {
+ last(result.__iteratees__).limit = n;
+ }
} else {
var views = result.__views__ || (result.__views__ = []);
views.push({ 'size': n, 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') });
@@ -11481,11 +11523,11 @@
};
});
- // Add `Array.prototype` functions to `lodash.prototype`.
- arrayEach(['concat', 'join', 'pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
- var func = arrayProto[methodName],
+ // Add `Array` and `String` methods to `lodash.prototype`.
+ arrayEach(['concat', '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|shift)$/.test(methodName);
+ retUnwrapped = /^(?:join|pop|replace|shift)$/.test(methodName);
lodash.prototype[methodName] = function() {
var args = arguments;
diff --git a/internal/baseAssign.js b/internal/baseAssign.js
index 3626c2e30..53532d8d5 100644
--- a/internal/baseAssign.js
+++ b/internal/baseAssign.js
@@ -24,7 +24,7 @@ function baseAssign(object, source, customizer) {
value = object[key],
result = customizer(value, source[key], key, object, source);
- if ((result === result ? result !== value : value === value) ||
+ if ((result === result ? (result !== value) : (value === value)) ||
(typeof value == 'undefined' && !(key in object))) {
object[key] = result;
}
diff --git a/internal/baseFill.js b/internal/baseFill.js
index 3b90582ff..26621d808 100644
--- a/internal/baseFill.js
+++ b/internal/baseFill.js
@@ -19,7 +19,7 @@ function baseFill(array, value, start, end) {
if (end < 0) {
end += length;
}
- length = start > end ? 0 : end >>> 0;
+ length = start > end ? 0 : (end >>> 0);
start >>>= 0;
while (start < length) {
diff --git a/internal/baseMerge.js b/internal/baseMerge.js
index 22f19b70a..b37e78495 100644
--- a/internal/baseMerge.js
+++ b/internal/baseMerge.js
@@ -38,7 +38,7 @@ function baseMerge(object, source, customizer, stackA, stackB) {
result = srcValue;
}
if ((isSrcArr || typeof result != 'undefined') &&
- (isCommon || (result === result ? result !== value : value === value))) {
+ (isCommon || (result === result ? (result !== value) : (value === value)))) {
object[key] = result;
}
});
diff --git a/internal/baseMergeDeep.js b/internal/baseMergeDeep.js
index 2595dd796..825e1ea37 100644
--- a/internal/baseMergeDeep.js
+++ b/internal/baseMergeDeep.js
@@ -59,7 +59,7 @@ function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stack
if (isCommon) {
// Recursively merge objects and arrays (susceptible to call stack limits).
object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);
- } else if (result === result ? result !== value : value === value) {
+ } else if (result === result ? (result !== value) : (value === value)) {
object[key] = result;
}
}
diff --git a/internal/baseSlice.js b/internal/baseSlice.js
index 78001a8f4..dc42be0cc 100644
--- a/internal/baseSlice.js
+++ b/internal/baseSlice.js
@@ -19,7 +19,7 @@ function baseSlice(array, start, end) {
if (end < 0) {
end += length;
}
- length = start > end ? 0 : (end - start) >>> 0;
+ length = start > end ? 0 : ((end - start) >>> 0);
start >>>= 0;
var result = Array(length);
diff --git a/internal/compareMultiple.js b/internal/compareMultiple.js
index 8a0ea97f2..da8f01743 100644
--- a/internal/compareMultiple.js
+++ b/internal/compareMultiple.js
@@ -26,9 +26,8 @@ function compareMultiple(object, other, orders) {
if (result) {
if (index >= ordersLength) {
return result;
- } else {
- return orders[index] ? result : result * -1;
}
+ return result * (orders[index] ? 1 : -1);
}
}
// Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
diff --git a/internal/createBindWrapper.js b/internal/createBindWrapper.js
index 990262d91..54086ee88 100644
--- a/internal/createBindWrapper.js
+++ b/internal/createBindWrapper.js
@@ -13,7 +13,8 @@ function createBindWrapper(func, thisArg) {
var Ctor = createCtorWrapper(func);
function wrapper() {
- return (this instanceof wrapper ? Ctor : func).apply(thisArg, arguments);
+ var fn = (this && this !== global && this instanceof wrapper) ? Ctor : func;
+ return fn.apply(thisArg, arguments);
}
return wrapper;
}
diff --git a/internal/createComposer.js b/internal/createComposer.js
index cc593e0c7..cb817593d 100644
--- a/internal/createComposer.js
+++ b/internal/createComposer.js
@@ -12,7 +12,7 @@ function createComposer(fromRight) {
return function() {
var length = arguments.length,
index = length,
- fromIndex = fromRight ? length - 1 : 0;
+ fromIndex = fromRight ? (length - 1) : 0;
if (!length) {
return function() { return arguments[0]; };
diff --git a/internal/createHybridWrapper.js b/internal/createHybridWrapper.js
index f065fa4f0..edd25c7d8 100644
--- a/internal/createHybridWrapper.js
+++ b/internal/createHybridWrapper.js
@@ -96,7 +96,8 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials
if (isAry && ary < args.length) {
args.length = ary;
}
- return (this instanceof wrapper ? (Ctor || createCtorWrapper(func)) : func).apply(thisBinding, args);
+ var fn = (this && this !== global && this instanceof wrapper) ? (Ctor || createCtorWrapper(func)) : func;
+ return fn.apply(thisBinding, args);
}
return wrapper;
}
diff --git a/internal/createPartialWrapper.js b/internal/createPartialWrapper.js
index 060391d71..10af97cbd 100644
--- a/internal/createPartialWrapper.js
+++ b/internal/createPartialWrapper.js
@@ -34,7 +34,8 @@ function createPartialWrapper(func, bitmask, thisArg, partials) {
while (argsLength--) {
args[leftIndex++] = arguments[++argsIndex];
}
- return (this instanceof wrapper ? Ctor : func).apply(isBind ? thisArg : this, args);
+ var fn = (this && this !== global && this instanceof wrapper) ? Ctor : func;
+ return fn.apply(isBind ? thisArg : this, args);
}
return wrapper;
}
diff --git a/internal/equalObjects.js b/internal/equalObjects.js
index 3d0577ec3..a9c6656a8 100644
--- a/internal/equalObjects.js
+++ b/internal/equalObjects.js
@@ -61,8 +61,10 @@ function equalObjects(object, other, equalFunc, customizer, isWhere, stackA, sta
othCtor = other.constructor;
// Non `Object` object instances with different constructors are not equal.
- if (objCtor != othCtor && ('constructor' in object && 'constructor' in other) &&
- !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) {
+ if (objCtor != othCtor &&
+ ('constructor' in object && 'constructor' in other) &&
+ !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
+ typeof othCtor == 'function' && othCtor instanceof othCtor)) {
return false;
}
}
diff --git a/internal/extremumBy.js b/internal/extremumBy.js
index 87b78324b..9fed607e6 100644
--- a/internal/extremumBy.js
+++ b/internal/extremumBy.js
@@ -23,7 +23,8 @@ function extremumBy(collection, iteratee, isMin) {
baseEach(collection, function(value, index, collection) {
var current = iteratee(value, index, collection);
- if ((isMin ? current < computed : current > computed) || (current === exValue && current === result)) {
+ if ((isMin ? (current < computed) : (current > computed)) ||
+ (current === exValue && current === result)) {
computed = current;
result = value;
}
diff --git a/internal/isIterateeCall.js b/internal/isIterateeCall.js
index 05c2acf60..59b901ce7 100644
--- a/internal/isIterateeCall.js
+++ b/internal/isIterateeCall.js
@@ -24,7 +24,7 @@ function isIterateeCall(value, index, object) {
}
if (prereq) {
var other = object[index];
- return value === value ? value === other : other !== other;
+ return value === value ? (value === other) : (other !== other);
}
return false;
}
diff --git a/internal/lazyClone.js b/internal/lazyClone.js
index cccfa7136..20cc8edd2 100644
--- a/internal/lazyClone.js
+++ b/internal/lazyClone.js
@@ -17,7 +17,6 @@ function lazyClone() {
result.__actions__ = actions ? arrayCopy(actions) : null;
result.__dir__ = this.__dir__;
- result.__dropCount__ = this.__dropCount__;
result.__filtered__ = this.__filtered__;
result.__iteratees__ = iteratees ? arrayCopy(iteratees) : null;
result.__takeCount__ = this.__takeCount__;
diff --git a/internal/lazyValue.js b/internal/lazyValue.js
index b5d6ed064..f0e342519 100644
--- a/internal/lazyValue.js
+++ b/internal/lazyValue.js
@@ -4,8 +4,8 @@ var baseWrapperValue = require('./baseWrapperValue'),
/** Used to indicate the type of lazy iteratees. */
var LAZY_DROP_WHILE_FLAG = 0,
- LAZY_MAP_FLAG = 2,
- LAZY_TAKE_WHILE_FLAG = 3;
+ LAZY_FILTER_FLAG = 1,
+ LAZY_MAP_FLAG = 2;
/* Native method references for those with the same name as other `lodash` methods. */
var nativeMin = Math.min;
@@ -29,9 +29,8 @@ function lazyValue() {
start = view.start,
end = view.end,
length = end - start,
- dropCount = this.__dropCount__,
+ index = isRight ? end : (start - 1),
takeCount = nativeMin(length, this.__takeCount__),
- index = isRight ? end : start - 1,
iteratees = this.__iteratees__,
iterLength = iteratees ? iteratees.length : 0,
resIndex = 0,
@@ -49,28 +48,32 @@ function lazyValue() {
iteratee = data.iteratee,
type = data.type;
- if (type != LAZY_DROP_WHILE_FLAG) {
- var computed = iteratee(value);
- } else {
- data.done = data.done && (isRight ? index < data.index : index > data.index);
+ 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;
- computed = data.done || (data.done = !iteratee(value));
- }
- if (type == LAZY_MAP_FLAG) {
- value = computed;
- } else if (!computed) {
- if (type == LAZY_TAKE_WHILE_FLAG) {
- break outer;
- } else {
- continue outer;
+ 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 (dropCount) {
- dropCount--;
- } else {
- result[resIndex++] = value;
- }
+ result[resIndex++] = value;
}
return result;
}
diff --git a/lang/isElement.js b/lang/isElement.js
index e1de713c8..a517ff5ac 100644
--- a/lang/isElement.js
+++ b/lang/isElement.js
@@ -30,7 +30,7 @@ var objToString = objectProto.toString;
*/
function isElement(value) {
return (value && value.nodeType === 1 && isObjectLike(value) &&
- objToString.call(value).indexOf('Element') > -1) || false;
+ (objToString.call(value).indexOf('Element') > -1)) || false;
}
// Fallback for environments without DOM support.
if (!support.dom) {
diff --git a/object/keys.js b/object/keys.js
index 32c06d4ca..2fa42707e 100644
--- a/object/keys.js
+++ b/object/keys.js
@@ -39,7 +39,7 @@ var keys = !nativeKeys ? shimKeys : function(object) {
length = object.length;
}
if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
- (typeof object != 'function' && (length && isLength(length)))) {
+ (typeof object != 'function' && (length && isLength(length)))) {
return shimKeys(object);
}
return isObject(object) ? nativeKeys(object) : [];
diff --git a/package.json b/package.json
index ecbc5d913..6f6b8403a 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "lodash",
- "version": "3.4.0",
+ "version": "3.5.0",
"description": "The modern build of lodash modular utilities.",
"homepage": "https://lodash.com/",
"icon": "https://lodash.com/icon.svg",
diff --git a/string/endsWith.js b/string/endsWith.js
index 32863b19a..aa74b9e63 100644
--- a/string/endsWith.js
+++ b/string/endsWith.js
@@ -29,7 +29,11 @@ function endsWith(string, target, position) {
target = (target + '');
var length = string.length;
- position = (typeof position == 'undefined' ? length : nativeMin(position < 0 ? 0 : (+position || 0), length)) - target.length;
+ position = typeof position == 'undefined'
+ ? length
+ : nativeMin(position < 0 ? 0 : (+position || 0), length);
+
+ position -= target.length;
return position >= 0 && string.indexOf(target, position) == position;
}
diff --git a/string/startsWith.js b/string/startsWith.js
index b849a0164..65fae2a46 100644
--- a/string/startsWith.js
+++ b/string/startsWith.js
@@ -26,7 +26,10 @@ var nativeMin = Math.min;
*/
function startsWith(string, target, position) {
string = baseToString(string);
- position = position == null ? 0 : nativeMin(position < 0 ? 0 : (+position || 0), string.length);
+ position = position == null
+ ? 0
+ : nativeMin(position < 0 ? 0 : (+position || 0), string.length);
+
return string.lastIndexOf(target, position) == position;
}
diff --git a/string/trunc.js b/string/trunc.js
index 4a2afe8bb..ac8549b00 100644
--- a/string/trunc.js
+++ b/string/trunc.js
@@ -60,7 +60,7 @@ function trunc(string, options, guard) {
if (options != null) {
if (isObject(options)) {
var separator = 'separator' in options ? options.separator : separator;
- length = 'length' in options ? +options.length || 0 : length;
+ length = 'length' in options ? (+options.length || 0) : length;
omission = 'omission' in options ? baseToString(options.omission) : omission;
} else {
length = +options || 0;
diff --git a/utility/attempt.js b/utility/attempt.js
index 13f9ae7f9..82b1f1794 100644
--- a/utility/attempt.js
+++ b/utility/attempt.js
@@ -23,7 +23,7 @@ var isError = require('../lang/isError');
function attempt() {
var func = arguments[0],
length = arguments.length,
- args = Array(length ? length - 1 : 0);
+ args = Array(length ? (length - 1) : 0);
while (--length > 0) {
args[length - 1] = arguments[length];
diff --git a/utility/mixin.js b/utility/mixin.js
index 09b578970..8fb09585f 100644
--- a/utility/mixin.js
+++ b/utility/mixin.js
@@ -70,7 +70,11 @@ function mixin(object, source, options) {
var chainAll = this.__chain__;
if (chain || chainAll) {
var result = object(this.__wrapped__);
- (result.__actions__ = arrayCopy(this.__actions__)).push({ 'func': func, 'args': arguments, 'thisArg': object });
+ (result.__actions__ = arrayCopy(this.__actions__)).push({
+ 'func': func,
+ 'args': arguments,
+ 'thisArg': object
+ });
result.__chain__ = chainAll;
return result;
}