...**/!(*.map|*.min.js)Size
Gzip
Dependencies
Publish
Install
Publish
Install
@@ -1,12 +1,12 @@ | ||
| 1 | # lodash v4.15.0 | |
| 1 | # lodash v4.16.0 | |
| 2 | 2 | |
| 3 | 3 | The [Lodash](https://lodash.com/) library exported as [Node.js](https://nodejs.org/) modules. |
| 4 | 4 | |
| 5 | 5 | ## Installation |
| 6 | 6 | |
| 7 | 7 | Using npm: |
| 8 | ```bash | |
| 9 | $ {sudo -H} npm i -g npm | |
| 8 | ```shell | |
| 9 | $ npm i -g npm | |
| 10 | 10 | $ npm i --save lodash |
| 11 | 11 | ``` |
| 12 | 12 | |
@@ -16,25 +16,24 @@ | ||
| 16 | 16 | var _ = require('lodash'); |
| 17 | 17 | // Load the core build. |
| 18 | 18 | var _ = require('lodash/core'); |
| 19 | // Load the fp build for immutable auto-curried iteratee-first data-last methods. | |
| 19 | // Load the FP build for immutable auto-curried iteratee-first data-last methods. | |
| 20 | 20 | var fp = require('lodash/fp'); |
| 21 | 21 | |
| 22 | // Load a method category. | |
| 22 | // Load method categories. | |
| 23 | 23 | var array = require('lodash/array'); |
| 24 | 24 | var object = require('lodash/fp/object'); |
| 25 | 25 | |
| 26 | // Load a single method for smaller builds with browserify/rollup/webpack. | |
| 26 | // Cherry-pick methods for smaller browserify/rollup/webpack bundles. | |
| 27 | 27 | var chunk = require('lodash/chunk'); |
| 28 | 28 | var extend = require('lodash/fp/extend'); |
| 29 | 29 | ``` |
| 30 | 30 | |
| 31 | See the [package source](https://github.com/lodash/lodash/tree/4.15.0-npm) for more details. | |
| 31 | See the [package source](https://github.com/lodash/lodash/tree/4.16.0-npm) for more details. | |
| 32 | 32 | |
| 33 | 33 | **Note:**<br> |
| 34 | Don’t assign values to the [special variable](http://nodejs.org/api/repl.html#repl_repl_features) `_` in the Node.js < 6 REPL.<br> | |
| 35 | Install [n_](https://www.npmjs.com/package/n_) for a REPL that includes `lodash` by default. | |
| 34 | Install [n_](https://www.npmjs.com/package/n_) for Lodash use in the Node.js < 6 REPL. | |
| 36 | 35 | |
| 37 | 36 | ## Support |
| 38 | 37 | |
| 39 | Tested in Chrome 51-52, Firefox 47-48, IE 9-11, Edge 14, Safari 8-9, Node.js 0.10-6, & PhantomJS 2.1.1.<br> | |
| 38 | Tested in Chrome 52-53, Firefox 47-48, IE 11, Edge 14, Safari 8-9, Node.js 4-6, & PhantomJS 2.1.1.<br> | |
| 40 | 39 | Automated [browser](https://saucelabs.com/u/lodash) & [CI](https://travis-ci.org/lodash/lodash/) test runs are available. |
@@ -1,4 +1,5 @@ | ||
| 1 | var createAggregator = require('./_createAggregator'); | |
| 1 | var baseAssignValue = require('./_baseAssignValue'), | |
| 2 | createAggregator = require('./_createAggregator'); | |
| 2 | 3 | |
| 3 | 4 | /** Used for built-in method references. */ |
| 4 | 5 | var objectProto = Object.prototype; |
@@ -30,7 +31,11 @@ | ||
| 30 | 31 | * // => { '3': 2, '5': 1 } |
| 31 | 32 | */ |
| 32 | 33 | var countBy = createAggregator(function(result, value, key) { |
| 33 | hasOwnProperty.call(result, key) ? ++result[key] : (result[key] = 1); | |
| 34 | if (hasOwnProperty.call(result, key)) { | |
| 35 | ++result[key]; | |
| 36 | } else { | |
| 37 | baseAssignValue(result, key, 1); | |
| 38 | } | |
| 34 | 39 | }); |
| 35 | 40 | |
| 36 | 41 | module.exports = countBy; |
@@ -1,7 +1,7 @@ | ||
| 1 | 1 | var arrayEach = require('./_arrayEach'), |
| 2 | baseFlatten = require('./_baseFlatten'), | |
| 3 | baseRest = require('./_baseRest'), | |
| 2 | baseAssignValue = require('./_baseAssignValue'), | |
| 4 | 3 | bind = require('./bind'), |
| 4 | flatRest = require('./_flatRest'), | |
| 5 | 5 | toKey = require('./_toKey'); |
| 6 | 6 | |
| 7 | 7 | /** |
@@ -30,10 +30,10 @@ | ||
| 30 | 30 | * jQuery(element).on('click', view.click); |
| 31 | 31 | * // => Logs 'clicked docs' when clicked. |
| 32 | 32 | */ |
| 33 | var bindAll = baseRest(function(object, methodNames) { | |
| 34 | arrayEach(baseFlatten(methodNames, 1), function(key) { | |
| 33 | var bindAll = flatRest(function(object, methodNames) { | |
| 34 | arrayEach(methodNames, function(key) { | |
| 35 | 35 | key = toKey(key); |
| 36 | object[key] = bind(object[key], object); | |
| 36 | baseAssignValue(object, key, bind(object[key], object)); | |
| 37 | 37 | }); |
| 38 | 38 | return object; |
| 39 | 39 | }); |
@@ -6,8 +6,8 @@ | ||
| 6 | 6 | /** |
| 7 | 7 | * Creates an array of `array` values not included in the other given arrays |
| 8 | 8 | * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) |
| 9 | * for equality comparisons. The order of result values is determined by the | |
| 10 | * order they occur in the first array. | |
| 9 | * for equality comparisons. The order and references of result values are | |
| 10 | * determined by the first array. | |
| 11 | 11 | * |
| 12 | 12 | * **Note:** Unlike `_.pullAll`, this method returns a new array. |
| 13 | 13 | * |
@@ -1,6 +1,5 @@ | ||
| 1 | 1 | var baseAt = require('./_baseAt'), |
| 2 | baseFlatten = require('./_baseFlatten'), | |
| 3 | baseRest = require('./_baseRest'); | |
| 2 | flatRest = require('./_flatRest'); | |
| 4 | 3 | |
| 5 | 4 | /** |
| 6 | 5 | * Creates an array of values corresponding to `paths` of `object`. |
@@ -19,8 +18,6 @@ | ||
| 19 | 18 | * _.at(object, ['a[0].b.c', 'a[1]']); |
| 20 | 19 | * // => [3, 4] |
| 21 | 20 | */ |
| 22 | var at = baseRest(function(object, paths) { | |
| 23 | return baseAt(object, baseFlatten(paths, 1)); | |
| 24 | }); | |
| 21 | var at = flatRest(baseAt); | |
| 25 | 22 | |
| 26 | 23 | module.exports = at; |
@@ -8,8 +8,9 @@ | ||
| 8 | 8 | /** |
| 9 | 9 | * This method is like `_.difference` except that it accepts `iteratee` which |
| 10 | 10 | * is invoked for each element of `array` and `values` to generate the criterion |
| 11 | * by which they're compared. Result values are chosen from the first array. | |
| 12 | * The iteratee is invoked with one argument: (value). | |
| 11 | * by which they're compared. The order and references of result values are | |
| 12 | * determined by the first array. The iteratee is invoked with one argument: | |
| 13 | * (value). | |
| 13 | 14 | * |
| 14 | 15 | * **Note:** Unlike `_.pullAllBy`, this method returns a new array. |
| 15 | 16 | * |
@@ -6,9 +6,9 @@ | ||
| 6 | 6 | |
| 7 | 7 | /** |
| 8 | 8 | * This method is like `_.difference` except that it accepts `comparator` |
| 9 | * which is invoked to compare elements of `array` to `values`. Result values | |
| 10 | * are chosen from the first array. The comparator is invoked with two arguments: | |
| 11 | * (arrVal, othVal). | |
| 9 | * which is invoked to compare elements of `array` to `values`. The order and | |
| 10 | * references of result values are determined by the first array. The comparator | |
| 11 | * is invoked with two arguments: (arrVal, othVal). | |
| 12 | 12 | * |
| 13 | 13 | * **Note:** Unlike `_.pullAllWith`, this method returns a new array. |
| 14 | 14 | * |
@@ -11,12 +11,6 @@ | ||
| 11 | 11 | /** Used to check objects for own properties. */ |
| 12 | 12 | var hasOwnProperty = objectProto.hasOwnProperty; |
| 13 | 13 | |
| 14 | /** Built-in value references. */ | |
| 15 | var propertyIsEnumerable = objectProto.propertyIsEnumerable; | |
| 16 | ||
| 17 | /** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */ | |
| 18 | var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf'); | |
| 19 | ||
| 20 | 14 | /** |
| 21 | 15 | * Assigns own enumerable string keyed properties of source objects to the |
| 22 | 16 | * destination object. Source objects are applied from left to right. |
@@ -50,7 +44,7 @@ | ||
| 50 | 44 | * // => { 'a': 1, 'c': 3 } |
| 51 | 45 | */ |
| 52 | 46 | var assign = createAssigner(function(object, source) { |
| 53 | if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) { | |
| 47 | if (isPrototype(source) || isArrayLike(source)) { | |
| 54 | 48 | copyObject(source, keys(source), object); |
| 55 | 49 | return; |
| 56 | 50 | } |
@@ -6,8 +6,8 @@ | ||
| 6 | 6 | reHasUnescapedHtml = RegExp(reUnescapedHtml.source); |
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | * Converts the characters "&", "<", ">", '"', "'", and "\`" in `string` to | |
| 10 | * their corresponding HTML entities. | |
| 9 | * Converts the characters "&", "<", ">", '"', and "'" in `string` to their | |
| 10 | * corresponding HTML entities. | |
| 11 | 11 | * |
| 12 | 12 | * **Note:** No other characters are escaped. To escape additional |
| 13 | 13 | * characters use a third-party library like [_he_](https://mths.be/he). |
@@ -18,12 +18,6 @@ | ||
| 18 | 18 | * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) |
| 19 | 19 | * (under "semi-related fun fact") for more details. |
| 20 | 20 | * |
| 21 | * Backticks are escaped because in IE < 9, they can break out of | |
| 22 | * attribute values or HTML comments. See [#59](https://html5sec.org/#59), | |
| 23 | * [#102](https://html5sec.org/#102), [#108](https://html5sec.org/#108), and | |
| 24 | * [#133](https://html5sec.org/#133) of the | |
| 25 | * [HTML5 Security Cheatsheet](https://html5sec.org/) for more details. | |
| 26 | * | |
| 27 | 21 | * When working with HTML you should always |
| 28 | 22 | * [quote attribute values](http://wonko.com/post/html-escaping) to reduce |
| 29 | 23 | * XSS vectors. |
@@ -1,4 +1,4 @@ | ||
| 1 | var memoize = require('./memoize'), | |
| 1 | var memoizeCapped = require('./_memoizeCapped'), | |
| 2 | 2 | toString = require('./toString'); |
| 3 | 3 | |
| 4 | 4 | /** Used to match property names within property paths. */ |
@@ -15,7 +15,7 @@ | ||
| 15 | 15 | * @param {string} string The string to convert. |
| 16 | 16 | * @returns {Array} Returns the property path array. |
| 17 | 17 | */ |
| 18 | var stringToPath = memoize(function(string) { | |
| 18 | var stringToPath = memoizeCapped(function(string) { | |
| 19 | 19 | string = toString(string); |
| 20 | 20 | |
| 21 | 21 | var result = []; |
@@ -16,16 +16,18 @@ | ||
| 16 | 16 | * @returns {Object} Returns the stack cache instance. |
| 17 | 17 | */ |
| 18 | 18 | function stackSet(key, value) { |
| 19 | var cache = this.__data__; | |
| 20 | if (cache instanceof ListCache) { | |
| 21 | var pairs = cache.__data__; | |
| 19 | var data = this.__data__; | |
| 20 | if (data instanceof ListCache) { | |
| 21 | var pairs = data.__data__; | |
| 22 | 22 | if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { |
| 23 | 23 | pairs.push([key, value]); |
| 24 | this.size = ++data.size; | |
| 24 | 25 | return this; |
| 25 | 26 | } |
| 26 | cache = this.__data__ = new MapCache(pairs); | |
| 27 | data = this.__data__ = new MapCache(pairs); | |
| 27 | 28 | } |
| 28 | cache.set(key, value); | |
| 29 | data.set(key, value); | |
| 30 | this.size = data.size; | |
| 29 | 31 | return this; |
| 30 | 32 | } |
| 31 | 33 | |
@@ -8,7 +8,11 @@ | ||
| 8 | 8 | * @returns {boolean} Returns `true` if the entry was removed, else `false`. |
| 9 | 9 | */ |
| 10 | 10 | function stackDelete(key) { |
| 11 | return this.__data__['delete'](key); | |
| 11 | var data = this.__data__, | |
| 12 | result = data['delete'](key); | |
| 13 | ||
| 14 | this.size = data.size; | |
| 15 | return result; | |
| 12 | 16 | } |
| 13 | 17 | |
| 14 | 18 | module.exports = stackDelete; |
@@ -1,8 +1,6 @@ | ||
| 1 | var constant = require('./constant'), | |
| 2 | defineProperty = require('./_defineProperty'), | |
| 3 | getWrapDetails = require('./_getWrapDetails'), | |
| 4 | identity = require('./identity'), | |
| 1 | var getWrapDetails = require('./_getWrapDetails'), | |
| 5 | 2 | insertWrapDetails = require('./_insertWrapDetails'), |
| 3 | setToString = require('./_setToString'), | |
| 6 | 4 | updateWrapDetails = require('./_updateWrapDetails'); |
| 7 | 5 | |
| 8 | 6 | /** |
@@ -15,13 +13,9 @@ | ||
| 15 | 13 | * @param {number} bitmask The bitmask flags. See `createWrap` for more details. |
| 16 | 14 | * @returns {Function} Returns `wrapper`. |
| 17 | 15 | */ |
| 18 | var setWrapToString = !defineProperty ? identity : function(wrapper, reference, bitmask) { | |
| 16 | function setWrapToString(wrapper, reference, bitmask) { | |
| 19 | 17 | var source = (reference + ''); |
| 20 | return defineProperty(wrapper, 'toString', { | |
| 21 | 'configurable': true, | |
| 22 | 'enumerable': false, | |
| 23 | 'value': constant(insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))) | |
| 24 | }); | |
| 25 | }; | |
| 18 | return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); | |
| 19 | } | |
| 26 | 20 | |
| 27 | 21 | module.exports = setWrapToString; |
@@ -1,10 +1,6 @@ | ||
| 1 | 1 | var baseSetData = require('./_baseSetData'), |
| 2 | now = require('./now'); | |
| 2 | shortOut = require('./_shortOut'); | |
| 3 | 3 | |
| 4 | /** Used to detect hot functions by number of calls within a span of milliseconds. */ | |
| 5 | var HOT_COUNT = 150, | |
| 6 | HOT_SPAN = 16; | |
| 7 | ||
| 8 | 4 | /** |
| 9 | 5 | * Sets metadata for `func`. |
| 10 | 6 | * |
@@ -19,24 +15,6 @@ | ||
| 19 | 15 | * @param {*} data The metadata. |
| 20 | 16 | * @returns {Function} Returns `func`. |
| 21 | 17 | */ |
| 22 | var setData = (function() { | |
| 23 | var count = 0, | |
| 24 | lastCalled = 0; | |
| 18 | var setData = shortOut(baseSetData); | |
| 25 | 19 | |
| 26 | return function(key, value) { | |
| 27 | var stamp = now(), | |
| 28 | remaining = HOT_SPAN - (stamp - lastCalled); | |
| 29 | ||
| 30 | lastCalled = stamp; | |
| 31 | if (remaining > 0) { | |
| 32 | if (++count >= HOT_COUNT) { | |
| 33 | return key; | |
| 34 | } | |
| 35 | } else { | |
| 36 | count = 0; | |
| 37 | } | |
| 38 | return baseSetData(key, value); | |
| 39 | }; | |
| 40 | }()); | |
| 41 | ||
| 42 | 20 | module.exports = setData; |
@@ -11,7 +11,11 @@ | ||
| 11 | 11 | * @returns {Object} Returns the map cache instance. |
| 12 | 12 | */ |
| 13 | 13 | function mapCacheSet(key, value) { |
| 14 | getMapData(this, key).set(key, value); | |
| 14 | var data = getMapData(this, key), | |
| 15 | size = data.size; | |
| 16 | ||
| 17 | data.set(key, value); | |
| 18 | this.size += data.size == size ? 0 : 1; | |
| 15 | 19 | return this; |
| 16 | 20 | } |
| 17 | 21 | |
@@ -1,4 +1,5 @@ | ||
| 1 | var createAggregator = require('./_createAggregator'); | |
| 1 | var baseAssignValue = require('./_baseAssignValue'), | |
| 2 | createAggregator = require('./_createAggregator'); | |
| 2 | 3 | |
| 3 | 4 | /** Used for built-in method references. */ |
| 4 | 5 | var objectProto = Object.prototype; |
@@ -34,7 +35,7 @@ | ||
| 34 | 35 | if (hasOwnProperty.call(result, key)) { |
| 35 | 36 | result[key].push(value); |
| 36 | 37 | } else { |
| 37 | result[key] = [value]; | |
| 38 | baseAssignValue(result, key, [value]); | |
| 38 | 39 | } |
| 39 | 40 | }); |
| 40 | 41 | |
@@ -10,7 +10,9 @@ | ||
| 10 | 10 | * @returns {boolean} Returns `true` if the entry was removed, else `false`. |
| 11 | 11 | */ |
| 12 | 12 | function mapCacheDelete(key) { |
| 13 | return getMapData(this, key)['delete'](key); | |
| 13 | var result = getMapData(this, key)['delete'](key); | |
| 14 | this.size -= result ? 1 : 0; | |
| 15 | return result; | |
| 14 | 16 | } |
| 15 | 17 | |
| 16 | 18 | module.exports = mapCacheDelete; |
@@ -6,8 +6,8 @@ | ||
| 6 | 6 | /** |
| 7 | 7 | * Creates an array of unique values that are included in all given arrays |
| 8 | 8 | * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) |
| 9 | * for equality comparisons. The order of result values is determined by the | |
| 10 | * order they occur in the first array. | |
| 9 | * for equality comparisons. The order and references of result values are | |
| 10 | * determined by the first array. | |
| 11 | 11 | * |
| 12 | 12 | * @static |
| 13 | 13 | * @memberOf _ |
@@ -8,8 +8,9 @@ | ||
| 8 | 8 | /** |
| 9 | 9 | * This method is like `_.intersection` except that it accepts `iteratee` |
| 10 | 10 | * which is invoked for each element of each `arrays` to generate the criterion |
| 11 | * by which they're compared. Result values are chosen from the first array. | |
| 12 | * The iteratee is invoked with one argument: (value). | |
| 11 | * by which they're compared. The order and references of result values are | |
| 12 | * determined by the first array. The iteratee is invoked with one argument: | |
| 13 | * (value). | |
| 13 | 14 | * |
| 14 | 15 | * @static |
| 15 | 16 | * @memberOf _ |
@@ -6,9 +6,9 @@ | ||
| 6 | 6 | |
| 7 | 7 | /** |
| 8 | 8 | * This method is like `_.intersection` except that it accepts `comparator` |
| 9 | * which is invoked to compare elements of `arrays`. Result values are chosen | |
| 10 | * from the first array. The comparator is invoked with two arguments: | |
| 11 | * (arrVal, othVal). | |
| 9 | * which is invoked to compare elements of `arrays`. The order and references | |
| 10 | * of result values are determined by the first array. The comparator is | |
| 11 | * invoked with two arguments: (arrVal, othVal). | |
| 12 | 12 | * |
| 13 | 13 | * @static |
| 14 | 14 | * @memberOf _ |
@@ -10,9 +10,11 @@ | ||
| 10 | 10 | * @returns {string} Returns the modified source. |
| 11 | 11 | */ |
| 12 | 12 | function insertWrapDetails(source, details) { |
| 13 | var length = details.length, | |
| 14 | lastIndex = length - 1; | |
| 15 | ||
| 13 | var length = details.length; | |
| 14 | if (!length) { | |
| 15 | return source; | |
| 16 | } | |
| 17 | var lastIndex = length - 1; | |
| 16 | 18 | details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; |
| 17 | 19 | details = details.join(length > 2 ? ', ' : ' '); |
| 18 | 20 | return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n'); |
@@ -19,7 +19,7 @@ | ||
| 19 | 19 | * // => false |
| 20 | 20 | */ |
| 21 | 21 | function isElement(value) { |
| 22 | return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value); | |
| 22 | return value != null && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value); | |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | module.exports = isElement; |
@@ -16,12 +16,6 @@ | ||
| 16 | 16 | /** Used to check objects for own properties. */ |
| 17 | 17 | var hasOwnProperty = objectProto.hasOwnProperty; |
| 18 | 18 | |
| 19 | /** Built-in value references. */ | |
| 20 | var propertyIsEnumerable = objectProto.propertyIsEnumerable; | |
| 21 | ||
| 22 | /** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */ | |
| 23 | var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf'); | |
| 24 | ||
| 25 | 19 | /** |
| 26 | 20 | * Checks if `value` is an empty object, collection, map, or set. |
| 27 | 21 | * |
@@ -65,7 +59,7 @@ | ||
| 65 | 59 | if (tag == mapTag || tag == setTag) { |
| 66 | 60 | return !value.size; |
| 67 | 61 | } |
| 68 | if (nonEnumShadows || isPrototype(value)) { | |
| 62 | if (isPrototype(value)) { | |
| 69 | 63 | return !nativeKeys(value).length; |
| 70 | 64 | } |
| 71 | 65 | for (var key in value) { |
@@ -9,7 +9,9 @@ | ||
| 9 | 9 | * @returns {boolean} Returns `true` if the entry was removed, else `false`. |
| 10 | 10 | */ |
| 11 | 11 | function hashDelete(key) { |
| 12 | return this.has(key) && delete this.__data__[key]; | |
| 12 | var result = this.has(key) && delete this.__data__[key]; | |
| 13 | this.size -= result ? 1 : 0; | |
| 14 | return result; | |
| 13 | 15 | } |
| 14 | 16 | |
| 15 | 17 | module.exports = hashDelete; |
@@ -18,9 +18,9 @@ | ||
| 18 | 18 | function hasPath(object, path, hasFunc) { |
| 19 | 19 | path = isKey(path, object) ? [path] : castPath(path); |
| 20 | 20 | |
| 21 | var result, | |
| 22 | index = -1, | |
| 23 | length = path.length; | |
| 21 | var index = -1, | |
| 22 | length = path.length, | |
| 23 | result = false; | |
| 24 | 24 | |
| 25 | 25 | while (++index < length) { |
| 26 | 26 | var key = toKey(path[index]); |
@@ -29,10 +29,10 @@ | ||
| 29 | 29 | } |
| 30 | 30 | object = object[key]; |
| 31 | 31 | } |
| 32 | if (result) { | |
| 32 | if (result || ++index != length) { | |
| 33 | 33 | return result; |
| 34 | 34 | } |
| 35 | var length = object ? object.length : 0; | |
| 35 | length = object ? object.length : 0; | |
| 36 | 36 | return !!length && isLength(length) && isIndex(key, length) && |
| 37 | 37 | (isArray(object) || isArguments(object)); |
| 38 | 38 | } |
@@ -41,8 +41,7 @@ | ||
| 41 | 41 | */ |
| 42 | 42 | var getTag = baseGetTag; |
| 43 | 43 | |
| 44 | // Fallback for data views, maps, sets, and weak maps in IE 11, | |
| 45 | // for data views in Edge < 14, and promises in Node.js. | |
| 44 | // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. | |
| 46 | 45 | if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || |
| 47 | 46 | (Map && getTag(new Map) != mapTag) || |
| 48 | 47 | (Promise && getTag(Promise.resolve()) != promiseTag) || |
@@ -1,5 +1,4 @@ | ||
| 1 | 1 | var getPrototype = require('./_getPrototype'), |
| 2 | isHostObject = require('./_isHostObject'), | |
| 3 | 2 | isObjectLike = require('./isObjectLike'); |
| 4 | 3 | |
| 5 | 4 | /** `Object#toString` result references. */ |
@@ -54,8 +53,7 @@ | ||
| 54 | 53 | * // => true |
| 55 | 54 | */ |
| 56 | 55 | function isPlainObject(value) { |
| 57 | if (!isObjectLike(value) || | |
| 58 | objectToString.call(value) != objectTag || isHostObject(value)) { | |
| 56 | if (!isObjectLike(value) || objectToString.call(value) != objectTag) { | |
| 59 | 57 | return false; |
| 60 | 58 | } |
| 61 | 59 | var proto = getPrototype(value); |
@@ -1,5 +1,6 @@ | ||
| 1 | 1 | var SetCache = require('./_SetCache'), |
| 2 | arraySome = require('./_arraySome'); | |
| 2 | arraySome = require('./_arraySome'), | |
| 3 | cacheHas = require('./_cacheHas'); | |
| 3 | 4 | |
| 4 | 5 | /** Used to compose bitmasks for comparison styles. */ |
| 5 | 6 | var UNORDERED_COMPARE_FLAG = 1, |
@@ -59,9 +60,9 @@ | ||
| 59 | 60 | // Recursively compare arrays (susceptible to call stack limits). |
| 60 | 61 | if (seen) { |
| 61 | 62 | if (!arraySome(other, function(othValue, othIndex) { |
| 62 | if (!seen.has(othIndex) && | |
| 63 | if (!cacheHas(seen, othIndex) && | |
| 63 | 64 | (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) { |
| 64 | return seen.add(othIndex); | |
| 65 | return seen.push(othIndex); | |
| 65 | 66 | } |
| 66 | 67 | })) { |
| 67 | 68 | result = false; |
@@ -1,4 +1,5 @@ | ||
| 1 | var createAggregator = require('./_createAggregator'); | |
| 1 | var baseAssignValue = require('./_baseAssignValue'), | |
| 2 | createAggregator = require('./_createAggregator'); | |
| 2 | 3 | |
| 3 | 4 | /** |
| 4 | 5 | * Creates an object composed of keys generated from the results of running |
@@ -30,7 +31,7 @@ | ||
| 30 | 31 | * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } |
| 31 | 32 | */ |
| 32 | 33 | var keyBy = createAggregator(function(result, value, key) { |
| 33 | result[key] = value; | |
| 34 | baseAssignValue(result, key, value); | |
| 34 | 35 | }); |
| 35 | 36 | |
| 36 | 37 | module.exports = keyBy; |
@@ -1,5 +1,6 @@ | ||
| 1 | 1 | var baseFindIndex = require('./_baseFindIndex'), |
| 2 | 2 | baseIsNaN = require('./_baseIsNaN'), |
| 3 | strictLastIndexOf = require('./_strictLastIndexOf'), | |
| 3 | 4 | toInteger = require('./toInteger'); |
| 4 | 5 | |
| 5 | 6 | /* Built-in method references for those with the same name as other `lodash` methods. */ |
@@ -35,21 +36,11 @@ | ||
| 35 | 36 | var index = length; |
| 36 | 37 | if (fromIndex !== undefined) { |
| 37 | 38 | index = toInteger(fromIndex); |
| 38 | index = ( | |
| 39 | index < 0 | |
| 40 | ? nativeMax(length + index, 0) | |
| 41 | : nativeMin(index, length - 1) | |
| 42 | ) + 1; | |
| 39 | index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1); | |
| 43 | 40 | } |
| 44 | if (value !== value) { | |
| 45 | return baseFindIndex(array, baseIsNaN, index - 1, true); | |
| 46 | } | |
| 47 | while (index--) { | |
| 48 | if (array[index] === value) { | |
| 49 | return index; | |
| 50 | } | |
| 51 | } | |
| 52 | return -1; | |
| 41 | return value === value | |
| 42 | ? strictLastIndexOf(array, value, index) | |
| 43 | : baseFindIndex(array, baseIsNaN, index, true); | |
| 53 | 44 | } |
| 54 | 45 | |
| 55 | 46 | module.exports = lastIndexOf; |
@@ -1,10 +1,9 @@ | ||
| 1 | 1 | var apply = require('./_apply'), |
| 2 | 2 | arrayMap = require('./_arrayMap'), |
| 3 | baseFlatten = require('./_baseFlatten'), | |
| 4 | 3 | baseIteratee = require('./_baseIteratee'), |
| 5 | 4 | baseRest = require('./_baseRest'), |
| 6 | 5 | baseUnary = require('./_baseUnary'), |
| 7 | isArray = require('./isArray'); | |
| 6 | flatRest = require('./_flatRest'); | |
| 8 | 7 | |
| 9 | 8 | /** |
| 10 | 9 | * Creates a function like `_.over`. |
@@ -14,11 +13,8 @@ | ||
| 14 | 13 | * @returns {Function} Returns the new over function. |
| 15 | 14 | */ |
| 16 | 15 | function createOver(arrayFunc) { |
| 17 | return baseRest(function(iteratees) { | |
| 18 | iteratees = (iteratees.length == 1 && isArray(iteratees[0])) | |
| 19 | ? arrayMap(iteratees[0], baseUnary(baseIteratee)) | |
| 20 | : arrayMap(baseFlatten(iteratees, 1), baseUnary(baseIteratee)); | |
| 21 | ||
| 16 | return flatRest(function(iteratees) { | |
| 17 | iteratees = arrayMap(iteratees, baseUnary(baseIteratee)); | |
| 22 | 18 | return baseRest(function(args) { |
| 23 | 19 | var thisArg = this; |
| 24 | 20 | return arrayFunc(iteratees, function(iteratee) { |
@@ -1,6 +1,5 @@ | ||
| 1 | 1 | var LodashWrapper = require('./_LodashWrapper'), |
| 2 | baseFlatten = require('./_baseFlatten'), | |
| 3 | baseRest = require('./_baseRest'), | |
| 2 | flatRest = require('./_flatRest'), | |
| 4 | 3 | getData = require('./_getData'), |
| 5 | 4 | getFuncName = require('./_getFuncName'), |
| 6 | 5 | isArray = require('./isArray'), |
@@ -26,9 +25,7 @@ | ||
| 26 | 25 | * @returns {Function} Returns the new flow function. |
| 27 | 26 | */ |
| 28 | 27 | function createFlow(fromRight) { |
| 29 | return baseRest(function(funcs) { | |
| 30 | funcs = baseFlatten(funcs, 1); | |
| 31 | ||
| 28 | return flatRest(function(funcs) { | |
| 32 | 29 | var length = funcs.length, |
| 33 | 30 | index = length, |
| 34 | 31 | prereq = LodashWrapper.prototype.thru; |
@@ -1,4 +1,5 @@ | ||
| 1 | var baseForOwn = require('./_baseForOwn'), | |
| 1 | var baseAssignValue = require('./_baseAssignValue'), | |
| 2 | baseForOwn = require('./_baseForOwn'), | |
| 2 | 3 | baseIteratee = require('./_baseIteratee'); |
| 3 | 4 | |
| 4 | 5 | /** |
@@ -27,7 +28,7 @@ | ||
| 27 | 28 | iteratee = baseIteratee(iteratee, 3); |
| 28 | 29 | |
| 29 | 30 | baseForOwn(object, function(value, key, object) { |
| 30 | result[iteratee(value, key, object)] = value; | |
| 31 | baseAssignValue(result, iteratee(value, key, object), value); | |
| 31 | 32 | }); |
| 32 | 33 | return result; |
| 33 | 34 | } |
@@ -1,4 +1,5 @@ | ||
| 1 | var baseForOwn = require('./_baseForOwn'), | |
| 1 | var baseAssignValue = require('./_baseAssignValue'), | |
| 2 | baseForOwn = require('./_baseForOwn'), | |
| 2 | 3 | baseIteratee = require('./_baseIteratee'); |
| 3 | 4 | |
| 4 | 5 | /** |
@@ -34,7 +35,7 @@ | ||
| 34 | 35 | iteratee = baseIteratee(iteratee, 3); |
| 35 | 36 | |
| 36 | 37 | baseForOwn(object, function(value, key, object) { |
| 37 | result[key] = iteratee(value, key, object); | |
| 38 | baseAssignValue(result, key, iteratee(value, key, object)); | |
| 38 | 39 | }); |
| 39 | 40 | return result; |
| 40 | 41 | } |
@@ -60,14 +60,14 @@ | ||
| 60 | 60 | return cache.get(key); |
| 61 | 61 | } |
| 62 | 62 | var result = func.apply(this, args); |
| 63 | memoized.cache = cache.set(key, result); | |
| 63 | memoized.cache = cache.set(key, result) || cache; | |
| 64 | 64 | return result; |
| 65 | 65 | }; |
| 66 | 66 | memoized.cache = new (memoize.Cache || MapCache); |
| 67 | 67 | return memoized; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | // Assign cache to `_.memoize`. | |
| 70 | // Expose `MapCache`. | |
| 71 | 71 | memoize.Cache = MapCache; |
| 72 | 72 | |
| 73 | 73 | module.exports = memoize; |
@@ -5,7 +5,7 @@ | ||
| 5 | 5 | * This method is like `_.merge` except that it accepts `customizer` which |
| 6 | 6 | * is invoked to produce the merged values of the destination and source |
| 7 | 7 | * properties. If `customizer` returns `undefined`, merging is handled by the |
| 8 | * method instead. The `customizer` is invoked with seven arguments: | |
| 8 | * method instead. The `customizer` is invoked with six arguments: | |
| 9 | 9 | * (objValue, srcValue, key, object, source, stack). |
| 10 | 10 | * |
| 11 | 11 | * **Note:** This method mutates `object`. |
@@ -1,4 +1,5 @@ | ||
| 1 | var assignValue = require('./_assignValue'); | |
| 1 | var assignValue = require('./_assignValue'), | |
| 2 | baseAssignValue = require('./_baseAssignValue'); | |
| 2 | 3 | |
| 3 | 4 | /** |
| 4 | 5 | * Copies properties of `source` to `object`. |
@@ -11,6 +12,7 @@ | ||
| 11 | 12 | * @returns {Object} Returns `object`. |
| 12 | 13 | */ |
| 13 | 14 | function copyObject(source, props, object, customizer) { |
| 15 | var isNew = !object; | |
| 14 | 16 | object || (object = {}); |
| 15 | 17 | |
| 16 | 18 | var index = -1, |
@@ -23,7 +25,14 @@ | ||
| 23 | 25 | ? customizer(object[key], source[key], key, object, source) |
| 24 | 26 | : undefined; |
| 25 | 27 | |
| 26 | assignValue(object, key, newValue === undefined ? source[key] : newValue); | |
| 28 | if (newValue === undefined) { | |
| 29 | newValue = source[key]; | |
| 30 | } | |
| 31 | if (isNew) { | |
| 32 | baseAssignValue(object, key, newValue); | |
| 33 | } else { | |
| 34 | assignValue(object, key, newValue); | |
| 35 | } | |
| 27 | 36 | } |
| 28 | 37 | return object; |
| 29 | 38 | } |
@@ -1,8 +1,7 @@ | ||
| 1 | 1 | var arrayMap = require('./_arrayMap'), |
| 2 | 2 | baseDifference = require('./_baseDifference'), |
| 3 | baseFlatten = require('./_baseFlatten'), | |
| 4 | 3 | basePick = require('./_basePick'), |
| 5 | baseRest = require('./_baseRest'), | |
| 4 | flatRest = require('./_flatRest'), | |
| 6 | 5 | getAllKeysIn = require('./_getAllKeysIn'), |
| 7 | 6 | toKey = require('./_toKey'); |
| 8 | 7 | |
@@ -25,11 +24,11 @@ | ||
| 25 | 24 | * _.omit(object, ['a', 'c']); |
| 26 | 25 | * // => { 'b': '2' } |
| 27 | 26 | */ |
| 28 | var omit = baseRest(function(object, props) { | |
| 27 | var omit = flatRest(function(object, props) { | |
| 29 | 28 | if (object == null) { |
| 30 | 29 | return {}; |
| 31 | 30 | } |
| 32 | props = arrayMap(baseFlatten(props, 1), toKey); | |
| 31 | props = arrayMap(props, toKey); | |
| 33 | 32 | return basePick(object, baseDifference(getAllKeysIn(object), props)); |
| 34 | 33 | }); |
| 35 | 34 | |
@@ -4,6 +4,7 @@ | ||
| 4 | 4 | baseIteratee = require('./_baseIteratee'), |
| 5 | 5 | baseRest = require('./_baseRest'), |
| 6 | 6 | baseUnary = require('./_baseUnary'), |
| 7 | castRest = require('./_castRest'), | |
| 7 | 8 | isArray = require('./isArray'); |
| 8 | 9 | |
| 9 | 10 | /* Built-in method references for those with the same name as other `lodash` methods. */ |
@@ -40,7 +41,7 @@ | ||
| 40 | 41 | * func(10, 5); |
| 41 | 42 | * // => [100, 10] |
| 42 | 43 | */ |
| 43 | var overArgs = baseRest(function(func, transforms) { | |
| 44 | var overArgs = castRest(function(func, transforms) { | |
| 44 | 45 | transforms = (transforms.length == 1 && isArray(transforms[0])) |
| 45 | 46 | ? arrayMap(transforms[0], baseUnary(baseIteratee)) |
| 46 | 47 | : arrayMap(baseFlatten(transforms, 1), baseUnary(baseIteratee)); |
@@ -26,17 +26,18 @@ | ||
| 26 | 26 | * // => [1] |
| 27 | 27 | */ |
| 28 | 28 | function concat() { |
| 29 | var length = arguments.length, | |
| 30 | args = Array(length ? length - 1 : 0), | |
| 29 | var length = arguments.length; | |
| 30 | if (!length) { | |
| 31 | return []; | |
| 32 | } | |
| 33 | var args = Array(length - 1), | |
| 31 | 34 | array = arguments[0], |
| 32 | 35 | index = length; |
| 33 | 36 | |
| 34 | 37 | while (index--) { |
| 35 | 38 | args[index - 1] = arguments[index]; |
| 36 | 39 | } |
| 37 | return length | |
| 38 | ? arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1)) | |
| 39 | : []; | |
| 40 | return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1)); | |
| 40 | 41 | } |
| 41 | 42 | |
| 42 | 43 | module.exports = concat; |
@@ -1,12 +1,6 @@ | ||
| 1 | 1 | var root = require('./_root'), |
| 2 | 2 | toString = require('./toString'); |
| 3 | 3 | |
| 4 | /** Used to match leading and trailing whitespace. */ | |
| 5 | var reTrim = /^\s+|\s+$/g; | |
| 6 | ||
| 7 | /** Used to detect hexadecimal string values. */ | |
| 8 | var reHasHexPrefix = /^0x/i; | |
| 9 | ||
| 10 | 4 | /* Built-in method references for those with the same name as other `lodash` methods. */ |
| 11 | 5 | var nativeParseInt = root.parseInt; |
| 12 | 6 | |
@@ -35,15 +29,12 @@ | ||
| 35 | 29 | * // => [6, 8, 10] |
| 36 | 30 | */ |
| 37 | 31 | function parseInt(string, radix, guard) { |
| 38 | // Chrome fails to trim leading <BOM> whitespace characters. | |
| 39 | // See https://bugs.chromium.org/p/v8/issues/detail?id=3109 for more details. | |
| 40 | 32 | if (guard || radix == null) { |
| 41 | 33 | radix = 0; |
| 42 | 34 | } else if (radix) { |
| 43 | 35 | radix = +radix; |
| 44 | 36 | } |
| 45 | string = toString(string).replace(reTrim, ''); | |
| 46 | return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10)); | |
| 37 | return nativeParseInt(toString(string), radix || 0); | |
| 47 | 38 | } |
| 48 | 39 | |
| 49 | 40 | module.exports = parseInt; |
@@ -1,7 +1,6 @@ | ||
| 1 | 1 | var arrayMap = require('./_arrayMap'), |
| 2 | baseFlatten = require('./_baseFlatten'), | |
| 3 | 2 | basePick = require('./_basePick'), |
| 4 | baseRest = require('./_baseRest'), | |
| 3 | flatRest = require('./_flatRest'), | |
| 5 | 4 | toKey = require('./_toKey'); |
| 6 | 5 | |
| 7 | 6 | /** |
@@ -21,8 +20,8 @@ | ||
| 21 | 20 | * _.pick(object, ['a', 'c']); |
| 22 | 21 | * // => { 'a': 1, 'c': 3 } |
| 23 | 22 | */ |
| 24 | var pick = baseRest(function(object, props) { | |
| 25 | return object == null ? {} : basePick(object, arrayMap(baseFlatten(props, 1), toKey)); | |
| 23 | var pick = flatRest(function(object, props) { | |
| 24 | return object == null ? {} : basePick(object, arrayMap(props, toKey)); | |
| 26 | 25 | }); |
| 27 | 26 | |
| 28 | 27 | module.exports = pick; |
@@ -1,9 +1,8 @@ | ||
| 1 | 1 | var arrayMap = require('./_arrayMap'), |
| 2 | 2 | baseAt = require('./_baseAt'), |
| 3 | baseFlatten = require('./_baseFlatten'), | |
| 4 | 3 | basePullAt = require('./_basePullAt'), |
| 5 | baseRest = require('./_baseRest'), | |
| 6 | 4 | compareAscending = require('./_compareAscending'), |
| 5 | flatRest = require('./_flatRest'), | |
| 7 | 6 | isIndex = require('./_isIndex'); |
| 8 | 7 | |
| 9 | 8 | /** |
@@ -30,9 +29,7 @@ | ||
| 30 | 29 | * console.log(pulled); |
| 31 | 30 | * // => ['b', 'd'] |
| 32 | 31 | */ |
| 33 | var pullAt = baseRest(function(array, indexes) { | |
| 34 | indexes = baseFlatten(indexes, 1); | |
| 35 | ||
| 32 | var pullAt = flatRest(function(array, indexes) { | |
| 36 | 33 | var length = array ? array.length : 0, |
| 37 | 34 | result = baseAt(array, indexes); |
| 38 | 35 | |