From 7a82a3d77bfe644b1e0592cd887eb4ffdc705ef3 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 16 Dec 2015 17:47:30 -0800 Subject: [PATCH] Bump to v3.3.1. --- README.md | 2 +- array/findLastIndex.js | 2 +- array/indexOf.js | 2 +- array/intersection.js | 2 +- collection/some.js | 2 +- function/debounce.js | 4 +-- function/throttle.js | 2 +- internal/baseDifference.js | 2 +- internal/baseUniq.js | 2 +- internal/isIterateeCall.js | 7 +++-- main.js | 52 +++++++++++++++++++++----------------- package.json | 2 +- string/template.js | 8 +++--- 13 files changed, 49 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 448f953f3..ca6ba6c36 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# lodash v3.3.0 +# lodash v3.3.1 The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules. diff --git a/array/findLastIndex.js b/array/findLastIndex.js index 22dc8c661..dea9d8a95 100644 --- a/array/findLastIndex.js +++ b/array/findLastIndex.js @@ -37,7 +37,7 @@ define(['../internal/baseCallback'], function(baseCallback) { * // => 2 * * // using the `_.matches` callback shorthand - * _.findLastIndex(users, { user': 'barney', 'active': true }); + * _.findLastIndex(users, { 'user': 'barney', 'active': true }); * // => 0 * * // using the `_.matchesProperty` callback shorthand diff --git a/array/indexOf.js b/array/indexOf.js index 547abc4b8..99ec1499b 100644 --- a/array/indexOf.js +++ b/array/indexOf.js @@ -25,7 +25,7 @@ define(['../internal/baseIndexOf', '../internal/binaryIndex'], function(baseInde * @example * * _.indexOf([1, 2, 1, 2], 2); - * // => 2 + * // => 1 * * // using `fromIndex` * _.indexOf([1, 2, 1, 2], 2, 2); diff --git a/array/intersection.js b/array/intersection.js index 31d19e671..657a45501 100644 --- a/array/intersection.js +++ b/array/intersection.js @@ -30,7 +30,7 @@ define(['../internal/baseIndexOf', '../internal/cacheIndexOf', '../internal/crea var value = arguments[argsIndex]; if (isArray(value) || isArguments(value)) { args.push(value); - caches.push(isCommon && value.length >= 120 && createCache(argsIndex && value)); + caches.push((isCommon && value.length >= 120) ? createCache(argsIndex && value) : null); } } argsLength = args.length; diff --git a/collection/some.js b/collection/some.js index 1a076b343..0b69fac4c 100644 --- a/collection/some.js +++ b/collection/some.js @@ -38,7 +38,7 @@ define(['../internal/arraySome', '../internal/baseCallback', '../internal/baseSo * ]; * * // using the `_.matches` callback shorthand - * _.some(users, { user': 'barney', 'active': false }); + * _.some(users, { 'user': 'barney', 'active': false }); * // => false * * // using the `_.matchesProperty` callback shorthand diff --git a/function/debounce.js b/function/debounce.js index b545ed3db..d3e1a268d 100644 --- a/function/debounce.js +++ b/function/debounce.js @@ -28,7 +28,7 @@ define(['../lang/isObject', '../date/now'], function(isObject, now) { * @memberOf _ * @category Function * @param {Function} func The function to debounce. - * @param {number} wait The number of milliseconds to delay. + * @param {number} [wait=0] The number of milliseconds to delay. * @param {Object} [options] The options object. * @param {boolean} [options.leading=false] Specify invoking on the leading * edge of the timeout. @@ -86,7 +86,7 @@ define(['../lang/isObject', '../date/now'], function(isObject, now) { if (typeof func != 'function') { throw new TypeError(FUNC_ERROR_TEXT); } - wait = wait < 0 ? 0 : wait; + wait = wait < 0 ? 0 : (+wait || 0); if (options === true) { var leading = true; trailing = false; diff --git a/function/throttle.js b/function/throttle.js index 97ac15e83..21e1288ea 100644 --- a/function/throttle.js +++ b/function/throttle.js @@ -29,7 +29,7 @@ define(['./debounce', '../lang/isObject'], function(debounce, isObject) { * @memberOf _ * @category Function * @param {Function} func The function to throttle. - * @param {number} wait The number of milliseconds to throttle invocations to. + * @param {number} [wait=0] The number of milliseconds to throttle invocations to. * @param {Object} [options] The options object. * @param {boolean} [options.leading=true] Specify invoking on the leading * edge of the timeout. diff --git a/internal/baseDifference.js b/internal/baseDifference.js index c3c60374a..30aae0d17 100644 --- a/internal/baseDifference.js +++ b/internal/baseDifference.js @@ -19,7 +19,7 @@ define(['./baseIndexOf', './cacheIndexOf', './createCache'], function(baseIndexO var index = -1, indexOf = baseIndexOf, isCommon = true, - cache = isCommon && values.length >= 200 && createCache(values), + cache = (isCommon && values.length >= 200) ? createCache(values) : null, valuesLength = values.length; if (cache) { diff --git a/internal/baseUniq.js b/internal/baseUniq.js index f9b4b17b1..1307e96d3 100644 --- a/internal/baseUniq.js +++ b/internal/baseUniq.js @@ -15,7 +15,7 @@ define(['./baseIndexOf', './cacheIndexOf', './createCache'], function(baseIndexO length = array.length, isCommon = true, isLarge = isCommon && length >= 200, - seen = isLarge && createCache(), + seen = isLarge ? createCache() : null, result = []; if (seen) { diff --git a/internal/isIterateeCall.js b/internal/isIterateeCall.js index f6eafd974..1b8ae75d5 100644 --- a/internal/isIterateeCall.js +++ b/internal/isIterateeCall.js @@ -20,8 +20,11 @@ define(['./isIndex', './isLength', '../lang/isObject'], function(isIndex, isLeng } else { prereq = type == 'string' && index in object; } - var other = object[index]; - return prereq && (value === value ? value === other : other !== other); + if (prereq) { + var other = object[index]; + return value === value ? value === other : other !== other; + } + return false; } return isIterateeCall; diff --git a/main.js b/main.js index 7e269edfa..6bfacf856 100644 --- a/main.js +++ b/main.js @@ -1,9 +1,9 @@ /** * @license - * lodash 3.3.0 (Custom Build) + * lodash 3.3.1 (Custom Build) * Build: `lodash modern exports="amd" -d -o ./main.js` * Copyright 2012-2015 The Dojo Foundation - * Based on Underscore.js 1.7.0 + * Based on Underscore.js 1.8.2 * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors * Available under MIT license */ @@ -13,7 +13,7 @@ var undefined; /** Used as the semantic version number. */ - var VERSION = '3.3.0'; + var VERSION = '3.3.1'; /** Used to compose bitmasks for wrapper metadata. */ var BIND_FLAG = 1, @@ -1801,7 +1801,7 @@ var index = -1, indexOf = getIndexOf(), isCommon = indexOf == baseIndexOf, - cache = isCommon && values.length >= 200 && createCache(values), + cache = (isCommon && values.length >= 200) ? createCache(values) : null, valuesLength = values.length; if (cache) { @@ -2621,7 +2621,7 @@ length = array.length, isCommon = indexOf == baseIndexOf, isLarge = isCommon && length >= 200, - seen = isLarge && createCache(), + seen = isLarge ? createCache() : null, result = []; if (seen) { @@ -3673,8 +3673,11 @@ } else { prereq = type == 'string' && index in object; } - var other = object[index]; - return prereq && (value === value ? value === other : other !== other); + if (prereq) { + var other = object[index]; + return value === value ? value === other : other !== other; + } + return false; } /** @@ -4400,7 +4403,7 @@ * // => 2 * * // using the `_.matches` callback shorthand - * _.findLastIndex(users, { user': 'barney', 'active': true }); + * _.findLastIndex(users, { 'user': 'barney', 'active': true }); * // => 0 * * // using the `_.matchesProperty` callback shorthand @@ -4511,7 +4514,7 @@ * @example * * _.indexOf([1, 2, 1, 2], 2); - * // => 2 + * // => 1 * * // using `fromIndex` * _.indexOf([1, 2, 1, 2], 2, 2); @@ -4584,7 +4587,7 @@ var value = arguments[argsIndex]; if (isArray(value) || isArguments(value)) { args.push(value); - caches.push(isCommon && value.length >= 120 && createCache(argsIndex && value)); + caches.push((isCommon && value.length >= 120) ? createCache(argsIndex && value) : null); } } argsLength = args.length; @@ -6652,7 +6655,7 @@ * ]; * * // using the `_.matches` callback shorthand - * _.some(users, { user': 'barney', 'active': false }); + * _.some(users, { 'user': 'barney', 'active': false }); * // => false * * // using the `_.matchesProperty` callback shorthand @@ -7188,7 +7191,7 @@ * @memberOf _ * @category Function * @param {Function} func The function to debounce. - * @param {number} wait The number of milliseconds to delay. + * @param {number} [wait=0] The number of milliseconds to delay. * @param {Object} [options] The options object. * @param {boolean} [options.leading=false] Specify invoking on the leading * edge of the timeout. @@ -7246,7 +7249,7 @@ if (typeof func != 'function') { throw new TypeError(FUNC_ERROR_TEXT); } - wait = wait < 0 ? 0 : wait; + wait = wait < 0 ? 0 : (+wait || 0); if (options === true) { var leading = true; trailing = false; @@ -7767,7 +7770,7 @@ * @memberOf _ * @category Function * @param {Function} func The function to throttle. - * @param {number} wait The number of milliseconds to throttle invocations to. + * @param {number} [wait=0] The number of milliseconds to throttle invocations to. * @param {Object} [options] The options object. * @param {boolean} [options.leading=true] Specify invoking on the leading * edge of the timeout. @@ -10084,10 +10087,10 @@ * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' }); * compiled.source; * // => function(data) { - * var __t, __p = ''; - * __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!'; - * return __p; - * } + * // var __t, __p = ''; + * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!'; + * // return __p; + * // } * * // using the `source` property to inline compiled templates for meaningful * // line numbers in error messages and a stack trace @@ -11201,15 +11204,13 @@ // Add `LazyWrapper` methods that accept an `iteratee` value. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { - var isFilter = index == LAZY_FILTER_FLAG, - isWhile = index == LAZY_WHILE_FLAG; + var isFilter = index == LAZY_FILTER_FLAG || index == LAZY_WHILE_FLAG; LazyWrapper.prototype[methodName] = function(iteratee, thisArg) { var result = this.clone(), - filtered = result.__filtered__, iteratees = result.__iteratees__ || (result.__iteratees__ = []); - result.__filtered__ = filtered || isFilter || (isWhile && result.__dir__ < 0); + result.__filtered__ = result.__filtered__ || isFilter; iteratees.push({ 'iteratee': getCallback(iteratee, thisArg, 3), 'type': index }); return result; }; @@ -11276,9 +11277,14 @@ }; LazyWrapper.prototype.dropWhile = function(predicate, thisArg) { - var done; + var done, + lastIndex, + isRight = this.__dir__ < 0; + predicate = getCallback(predicate, thisArg, 3); return this.filter(function(value, index, array) { + done = done && (isRight ? index < lastIndex : index > lastIndex); + lastIndex = index; return done || (done = !predicate(value, index, array)); }); }; diff --git a/package.json b/package.json index f5aecb096..afefc135f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lodash", - "version": "3.3.0", + "version": "3.3.1", "main": "main.js", "private": true, "volo": { diff --git a/string/template.js b/string/template.js index 2c58fc58f..9e4a9dac8 100644 --- a/string/template.js +++ b/string/template.js @@ -104,10 +104,10 @@ define(['../internal/assignOwnDefaults', '../utility/attempt', '../internal/base * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' }); * compiled.source; * // => function(data) { - * var __t, __p = ''; - * __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!'; - * return __p; - * } + * // var __t, __p = ''; + * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!'; + * // return __p; + * // } * * // using the `source` property to inline compiled templates for meaningful * // line numbers in error messages and a stack trace