From b7e3b3febd9e1a52a95a4da28f698e0b53e39291 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 7 Apr 2016 21:38:09 -0700 Subject: [PATCH] Bump to v4.9.0. --- README.md | 4 ++-- _Hash.js | 2 +- _baseFlatten.js | 19 +++++++++---------- _createOver.js | 3 ++- _getTag.js | 4 ++-- _isFlattenable.js | 16 ++++++++++++++++ _isFlattenableIteratee.js | 16 ++++++++++++++++ _toSource.js | 10 +++++----- assignInWith.js | 2 +- assignWith.js | 2 +- cloneWith.js | 2 +- create.js | 2 +- debounce.js | 2 +- difference.js | 2 +- differenceBy.js | 2 +- differenceWith.js | 2 +- get.js | 2 +- groupBy.js | 7 ++++--- has.js | 8 ++++---- hasIn.js | 6 +++--- inRange.js | 2 +- includes.js | 2 +- indexOf.js | 4 ++-- invokeMap.js | 4 ++-- isEqualWith.js | 2 +- isMatchWith.js | 2 +- iteratee.js | 4 ++-- lodash.default.js | 4 ++-- lodash.js | 2 +- max.js | 2 +- memoize.js | 2 +- mergeWith.js | 2 +- method.js | 8 ++++---- min.js | 2 +- mixin.js | 2 +- overArgs.js | 4 ++-- package.json | 2 +- property.js | 8 ++++---- range.js | 2 +- reduce.js | 2 +- set.js | 2 +- split.js | 27 ++++++++++++++++++++++++++- template.js | 2 +- throttle.js | 2 +- union.js | 3 ++- unionBy.js | 2 +- unionWith.js | 2 +- uniqueId.js | 2 +- wrapperLodash.js | 6 +++--- 49 files changed, 141 insertions(+), 82 deletions(-) create mode 100644 _isFlattenable.js create mode 100644 _isFlattenableIteratee.js diff --git a/README.md b/README.md index f74018cac..31c1217ac 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# lodash-es v4.8.2 +# lodash-es v4.9.0 The [Lodash](https://lodash.com/) library exported as [ES](http://www.ecma-international.org/ecma-262/6.0/) modules. @@ -7,4 +7,4 @@ Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli): $ lodash modularize exports=es -o ./ ``` -See the [package source](https://github.com/lodash/lodash/tree/4.8.2-es) for more details. +See the [package source](https://github.com/lodash/lodash/tree/4.9.0-es) for more details. diff --git a/_Hash.js b/_Hash.js index 0848848de..4796078cc 100644 --- a/_Hash.js +++ b/_Hash.js @@ -4,7 +4,7 @@ import nativeCreate from './_nativeCreate'; var objectProto = Object.prototype; /** - * Creates an hash object. + * Creates a hash object. * * @private * @constructor diff --git a/_baseFlatten.js b/_baseFlatten.js index f9ea40749..d19d8f5d6 100644 --- a/_baseFlatten.js +++ b/_baseFlatten.js @@ -1,7 +1,5 @@ import arrayPush from './_arrayPush'; -import isArguments from './isArguments'; -import isArray from './isArray'; -import isArrayLikeObject from './isArrayLikeObject'; +import isFlattenable from './_isFlattenable'; /** * The base implementation of `_.flatten` with support for restricting flattening. @@ -9,23 +7,24 @@ import isArrayLikeObject from './isArrayLikeObject'; * @private * @param {Array} array The array to flatten. * @param {number} depth The maximum recursion depth. - * @param {boolean} [isStrict] Restrict flattening to arrays-like objects. + * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. + * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. * @param {Array} [result=[]] The initial result value. * @returns {Array} Returns the new flattened array. */ -function baseFlatten(array, depth, isStrict, result) { - result || (result = []); - +function baseFlatten(array, depth, predicate, isStrict, result) { var index = -1, length = array.length; + predicate || (predicate = isFlattenable); + result || (result = []); + while (++index < length) { var value = array[index]; - if (depth > 0 && isArrayLikeObject(value) && - (isStrict || isArray(value) || isArguments(value))) { + if (depth > 0 && predicate(value)) { if (depth > 1) { // Recursively flatten arrays (susceptible to call stack limits). - baseFlatten(value, depth - 1, isStrict, result); + baseFlatten(value, depth - 1, predicate, isStrict, result); } else { arrayPush(result, value); } diff --git a/_createOver.js b/_createOver.js index c24b36cfe..c972d4696 100644 --- a/_createOver.js +++ b/_createOver.js @@ -2,6 +2,7 @@ import apply from './_apply'; import arrayMap from './_arrayMap'; import baseFlatten from './_baseFlatten'; import baseIteratee from './_baseIteratee'; +import isFlattenableIteratee from './_isFlattenableIteratee'; import rest from './rest'; /** @@ -13,7 +14,7 @@ import rest from './rest'; */ function createOver(arrayFunc) { return rest(function(iteratees) { - iteratees = arrayMap(baseFlatten(iteratees, 1), baseIteratee); + iteratees = arrayMap(baseFlatten(iteratees, 1, isFlattenableIteratee), baseIteratee); return rest(function(args) { var thisArg = this; return arrayFunc(iteratees, function(iteratee) { diff --git a/_getTag.js b/_getTag.js index 663ac5fa6..d9c3884ec 100644 --- a/_getTag.js +++ b/_getTag.js @@ -51,8 +51,8 @@ if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || (WeakMap && getTag(new WeakMap) != weakMapTag)) { getTag = function(value) { var result = objectToString.call(value), - Ctor = result == objectTag ? value.constructor : null, - ctorString = toSource(Ctor); + Ctor = result == objectTag ? value.constructor : undefined, + ctorString = Ctor ? toSource(Ctor) : undefined; if (ctorString) { switch (ctorString) { diff --git a/_isFlattenable.js b/_isFlattenable.js new file mode 100644 index 000000000..4a98c9b76 --- /dev/null +++ b/_isFlattenable.js @@ -0,0 +1,16 @@ +import isArguments from './isArguments'; +import isArray from './isArray'; +import isArrayLikeObject from './isArrayLikeObject'; + +/** + * Checks if `value` is a flattenable `arguments` object or array. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. + */ +function isFlattenable(value) { + return isArrayLikeObject(value) && (isArray(value) || isArguments(value)); +} + +export default isFlattenable; diff --git a/_isFlattenableIteratee.js b/_isFlattenableIteratee.js new file mode 100644 index 000000000..61a54ed44 --- /dev/null +++ b/_isFlattenableIteratee.js @@ -0,0 +1,16 @@ +import isArray from './isArray'; +import isFunction from './isFunction'; + +/** + * Checks if `value` is a flattenable array and not a `_.matchesProperty` + * iteratee shorthand. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. + */ +function isFlattenableIteratee(value) { + return isArray(value) && !(value.length == 2 && !isFunction(value[0])); +} + +export default isFlattenableIteratee; diff --git a/_toSource.js b/_toSource.js index dd11d2fe3..04d5b5072 100644 --- a/_toSource.js +++ b/_toSource.js @@ -1,6 +1,3 @@ -import isFunction from './isFunction'; -import toString from './toString'; - /** Used to resolve the decompiled source of functions. */ var funcToString = Function.prototype.toString; @@ -12,12 +9,15 @@ var funcToString = Function.prototype.toString; * @returns {string} Returns the source code. */ function toSource(func) { - if (isFunction(func)) { + if (func != null) { try { return funcToString.call(func); } catch (e) {} + try { + return (func + ''); + } catch (e) {} } - return toString(func); + return ''; } export default toSource; diff --git a/assignInWith.js b/assignInWith.js index 5c702bfac..7f2aa2755 100644 --- a/assignInWith.js +++ b/assignInWith.js @@ -5,7 +5,7 @@ import keysIn from './keysIn'; /** * This method is like `_.assignIn` except that it accepts `customizer` * which is invoked to produce the assigned values. If `customizer` returns - * `undefined` assignment is handled by the method instead. The `customizer` + * `undefined`, assignment is handled by the method instead. The `customizer` * is invoked with five arguments: (objValue, srcValue, key, object, source). * * **Note:** This method mutates `object`. diff --git a/assignWith.js b/assignWith.js index 8aedc7e88..0b8bfe124 100644 --- a/assignWith.js +++ b/assignWith.js @@ -5,7 +5,7 @@ import keys from './keys'; /** * This method is like `_.assign` except that it accepts `customizer` * which is invoked to produce the assigned values. If `customizer` returns - * `undefined` assignment is handled by the method instead. The `customizer` + * `undefined`, assignment is handled by the method instead. The `customizer` * is invoked with five arguments: (objValue, srcValue, key, object, source). * * **Note:** This method mutates `object`. diff --git a/cloneWith.js b/cloneWith.js index d82f22272..777cad37a 100644 --- a/cloneWith.js +++ b/cloneWith.js @@ -2,7 +2,7 @@ import baseClone from './_baseClone'; /** * This method is like `_.clone` except that it accepts `customizer` which - * is invoked to produce the cloned value. If `customizer` returns `undefined` + * is invoked to produce the cloned value. If `customizer` returns `undefined`, * cloning is handled by the method instead. The `customizer` is invoked with * up to four arguments; (value [, index|key, object, stack]). * diff --git a/create.js b/create.js index 7392e53bf..ab060acf3 100644 --- a/create.js +++ b/create.js @@ -3,7 +3,7 @@ import baseCreate from './_baseCreate'; /** * Creates an object that inherits from the `prototype` object. If a - * `properties` object is given its own enumerable string keyed properties + * `properties` object is given, its own enumerable string keyed properties * are assigned to the created object. * * @static diff --git a/debounce.js b/debounce.js index 77ee2abd2..f13119b66 100644 --- a/debounce.js +++ b/debounce.js @@ -23,7 +23,7 @@ var nativeMax = Math.max, * on the trailing edge of the timeout only if the debounced function is * invoked more than once during the `wait` timeout. * - * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation) + * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) * for details over the differences between `_.debounce` and `_.throttle`. * * @static diff --git a/difference.js b/difference.js index fe9bc80ac..ce49129c9 100644 --- a/difference.js +++ b/difference.js @@ -23,7 +23,7 @@ import rest from './rest'; */ var difference = rest(function(array, values) { return isArrayLikeObject(array) - ? baseDifference(array, baseFlatten(values, 1, true)) + ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) : []; }); diff --git a/differenceBy.js b/differenceBy.js index 2e09ccdd2..971468324 100644 --- a/differenceBy.js +++ b/differenceBy.js @@ -35,7 +35,7 @@ var differenceBy = rest(function(array, values) { iteratee = undefined; } return isArrayLikeObject(array) - ? baseDifference(array, baseFlatten(values, 1, true), baseIteratee(iteratee)) + ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), baseIteratee(iteratee)) : []; }); diff --git a/differenceWith.js b/differenceWith.js index 2f8336a9a..60f307a36 100644 --- a/differenceWith.js +++ b/differenceWith.js @@ -31,7 +31,7 @@ var differenceWith = rest(function(array, values) { comparator = undefined; } return isArrayLikeObject(array) - ? baseDifference(array, baseFlatten(values, 1, true), undefined, comparator) + ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) : []; }); diff --git a/get.js b/get.js index 2cb923cc0..c241eab71 100644 --- a/get.js +++ b/get.js @@ -2,7 +2,7 @@ import baseGet from './_baseGet'; /** * Gets the value at `path` of `object`. If the resolved value is - * `undefined` the `defaultValue` is used in its place. + * `undefined`, the `defaultValue` is used in its place. * * @static * @memberOf _ diff --git a/groupBy.js b/groupBy.js index 38e4ab4cf..c42ce5bb3 100644 --- a/groupBy.js +++ b/groupBy.js @@ -8,9 +8,10 @@ var hasOwnProperty = objectProto.hasOwnProperty; /** * Creates an object composed of keys generated from the results of running - * each element of `collection` thru `iteratee`. The corresponding value of - * each key is an array of elements responsible for generating the key. The - * iteratee is invoked with one argument: (value). + * each element of `collection` thru `iteratee`. The order of grouped values + * is determined by the order they occur in `collection`. The corresponding + * value of each key is an array of elements responsible for generating the + * key. The iteratee is invoked with one argument: (value). * * @static * @memberOf _ diff --git a/has.js b/has.js index 5e0b461bc..e7844016a 100644 --- a/has.js +++ b/has.js @@ -13,16 +13,16 @@ import hasPath from './_hasPath'; * @returns {boolean} Returns `true` if `path` exists, else `false`. * @example * - * var object = { 'a': { 'b': { 'c': 3 } } }; - * var other = _.create({ 'a': _.create({ 'b': _.create({ 'c': 3 }) }) }); + * var object = { 'a': { 'b': 2 } }; + * var other = _.create({ 'a': _.create({ 'b': 2 }) }); * * _.has(object, 'a'); * // => true * - * _.has(object, 'a.b.c'); + * _.has(object, 'a.b'); * // => true * - * _.has(object, ['a', 'b', 'c']); + * _.has(object, ['a', 'b']); * // => true * * _.has(other, 'a'); diff --git a/hasIn.js b/hasIn.js index ae43c336f..f1bc190a8 100644 --- a/hasIn.js +++ b/hasIn.js @@ -13,15 +13,15 @@ import hasPath from './_hasPath'; * @returns {boolean} Returns `true` if `path` exists, else `false`. * @example * - * var object = _.create({ 'a': _.create({ 'b': _.create({ 'c': 3 }) }) }); + * var object = _.create({ 'a': _.create({ 'b': 2 }) }); * * _.hasIn(object, 'a'); * // => true * - * _.hasIn(object, 'a.b.c'); + * _.hasIn(object, 'a.b'); * // => true * - * _.hasIn(object, ['a', 'b', 'c']); + * _.hasIn(object, ['a', 'b']); * // => true * * _.hasIn(object, 'b'); diff --git a/inRange.js b/inRange.js index e55e7ec8e..e151cd36e 100644 --- a/inRange.js +++ b/inRange.js @@ -3,7 +3,7 @@ import toNumber from './toNumber'; /** * Checks if `n` is between `start` and up to but not including, `end`. If - * `end` is not specified it's set to `start` with `start` then set to `0`. + * `end` is not specified, it's set to `start` with `start` then set to `0`. * If `start` is greater than `end` the params are swapped to support * negative ranges. * diff --git a/includes.js b/includes.js index 61420ab9e..82ba4882c 100644 --- a/includes.js +++ b/includes.js @@ -8,7 +8,7 @@ import values from './values'; var nativeMax = Math.max; /** - * Checks if `value` is in `collection`. If `collection` is a string it's + * Checks if `value` is in `collection`. If `collection` is a string, it's * checked for a substring of `value`, otherwise * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) * is used for equality comparisons. If `fromIndex` is negative, it's used as diff --git a/indexOf.js b/indexOf.js index 5200b51c6..64940c6cc 100644 --- a/indexOf.js +++ b/indexOf.js @@ -7,8 +7,8 @@ var nativeMax = Math.max; /** * Gets the index at which the first occurrence of `value` is found in `array` * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) - * for equality comparisons. If `fromIndex` is negative, it's used as the offset - * from the end of `array`. + * for equality comparisons. If `fromIndex` is negative, it's used as the + * offset from the end of `array`. * * @static * @memberOf _ diff --git a/invokeMap.js b/invokeMap.js index f2d0e19a1..2115786ab 100644 --- a/invokeMap.js +++ b/invokeMap.js @@ -8,8 +8,8 @@ import rest from './rest'; /** * Invokes the method at `path` of each element in `collection`, returning * an array of the results of each invoked method. Any additional arguments - * are provided to each invoked method. If `methodName` is a function it's - * invoked for, and `this` bound to, each element in `collection`. + * are provided to each invoked method. If `methodName` is a function, it's + * invoked for and `this` bound to, each element in `collection`. * * @static * @memberOf _ diff --git a/isEqualWith.js b/isEqualWith.js index 22a3df806..2b5cc3747 100644 --- a/isEqualWith.js +++ b/isEqualWith.js @@ -2,7 +2,7 @@ import baseIsEqual from './_baseIsEqual'; /** * This method is like `_.isEqual` except that it accepts `customizer` which - * is invoked to compare values. If `customizer` returns `undefined` comparisons + * is invoked to compare values. If `customizer` returns `undefined`, comparisons * are handled by the method instead. The `customizer` is invoked with up to * six arguments: (objValue, othValue [, index|key, object, other, stack]). * diff --git a/isMatchWith.js b/isMatchWith.js index 08868b70f..0065aa3f6 100644 --- a/isMatchWith.js +++ b/isMatchWith.js @@ -3,7 +3,7 @@ import getMatchData from './_getMatchData'; /** * This method is like `_.isMatch` except that it accepts `customizer` which - * is invoked to compare values. If `customizer` returns `undefined` comparisons + * is invoked to compare values. If `customizer` returns `undefined`, comparisons * are handled by the method instead. The `customizer` is invoked with five * arguments: (objValue, srcValue, index|key, object, source). * diff --git a/iteratee.js b/iteratee.js index dd3295106..bc2aead60 100644 --- a/iteratee.js +++ b/iteratee.js @@ -3,8 +3,8 @@ import baseIteratee from './_baseIteratee'; /** * Creates a function that invokes `func` with the arguments of the created - * function. If `func` is a property name the created function returns the - * property value for a given element. If `func` is an array or object the + * function. If `func` is a property name, the created function returns the + * property value for a given element. If `func` is an array or object, the * created function returns `true` for elements that contain the equivalent * source properties, otherwise it returns `false`. * diff --git a/lodash.default.js b/lodash.default.js index f61b55e31..903a4eeab 100644 --- a/lodash.default.js +++ b/lodash.default.js @@ -1,6 +1,6 @@ /** * @license - * lodash 4.8.2 (Custom Build) + * lodash 4.9.0 (Custom Build) * Build: `lodash modularize exports="es" -o ./` * Copyright jQuery Foundation and other contributors * Released under MIT license @@ -44,7 +44,7 @@ import toInteger from './toInteger'; import lodash from './wrapperLodash'; /** Used as the semantic version number. */ -var VERSION = '4.8.2'; +var VERSION = '4.9.0'; /** Used to compose bitmasks for wrapper metadata. */ var BIND_KEY_FLAG = 2; diff --git a/lodash.js b/lodash.js index 501ea04a7..58564153d 100644 --- a/lodash.js +++ b/lodash.js @@ -1,6 +1,6 @@ /** * @license - * lodash 4.8.2 (Custom Build) + * lodash 4.9.0 (Custom Build) * Build: `lodash modularize exports="es" -o ./` * Copyright jQuery Foundation and other contributors * Released under MIT license diff --git a/max.js b/max.js index 2954c5c08..f498ea1f9 100644 --- a/max.js +++ b/max.js @@ -3,7 +3,7 @@ import gt from './gt'; import identity from './identity'; /** - * Computes the maximum value of `array`. If `array` is empty or falsey + * Computes the maximum value of `array`. If `array` is empty or falsey, * `undefined` is returned. * * @static diff --git a/memoize.js b/memoize.js index f0bf0f872..d836dae7a 100644 --- a/memoize.js +++ b/memoize.js @@ -5,7 +5,7 @@ var FUNC_ERROR_TEXT = 'Expected a function'; /** * Creates a function that memoizes the result of `func`. If `resolver` is - * provided it determines the cache key for storing the result based on the + * provided, it determines the cache key for storing the result based on the * arguments provided to the memoized function. By default, the first argument * provided to the memoized function is used as the map cache key. The `func` * is invoked with the `this` binding of the memoized function. diff --git a/mergeWith.js b/mergeWith.js index 7ddada07c..2824e70a6 100644 --- a/mergeWith.js +++ b/mergeWith.js @@ -4,7 +4,7 @@ import createAssigner from './_createAssigner'; /** * This method is like `_.merge` except that it accepts `customizer` which * is invoked to produce the merged values of the destination and source - * properties. If `customizer` returns `undefined` merging is handled by the + * properties. If `customizer` returns `undefined`, merging is handled by the * method instead. The `customizer` is invoked with seven arguments: * (objValue, srcValue, key, object, source, stack). * diff --git a/method.js b/method.js index 33586dd80..6ce1f1569 100644 --- a/method.js +++ b/method.js @@ -15,14 +15,14 @@ import rest from './rest'; * @example * * var objects = [ - * { 'a': { 'b': { 'c': _.constant(2) } } }, - * { 'a': { 'b': { 'c': _.constant(1) } } } + * { 'a': { 'b': _.constant(2) } }, + * { 'a': { 'b': _.constant(1) } } * ]; * - * _.map(objects, _.method('a.b.c')); + * _.map(objects, _.method('a.b')); * // => [2, 1] * - * _.map(objects, _.method(['a', 'b', 'c'])); + * _.map(objects, _.method(['a', 'b'])); * // => [2, 1] */ var method = rest(function(path, args) { diff --git a/min.js b/min.js index 76d95cd34..a6f8fd3ce 100644 --- a/min.js +++ b/min.js @@ -3,7 +3,7 @@ import identity from './identity'; import lt from './lt'; /** - * Computes the minimum value of `array`. If `array` is empty or falsey + * Computes the minimum value of `array`. If `array` is empty or falsey, * `undefined` is returned. * * @static diff --git a/mixin.js b/mixin.js index da42ea089..82915aaf0 100644 --- a/mixin.js +++ b/mixin.js @@ -8,7 +8,7 @@ import keys from './keys'; /** * Adds all own enumerable string keyed function properties of a source - * object to the destination object. If `object` is a function then methods + * object to the destination object. If `object` is a function, then methods * are added to its prototype as well. * * **Note:** Use `_.runInContext` to create a pristine `lodash` function to diff --git a/overArgs.js b/overArgs.js index 318e51f7e..4e9e24ced 100644 --- a/overArgs.js +++ b/overArgs.js @@ -2,6 +2,7 @@ import apply from './_apply'; import arrayMap from './_arrayMap'; import baseFlatten from './_baseFlatten'; import baseIteratee from './_baseIteratee'; +import isFlattenableIteratee from './_isFlattenableIteratee'; import rest from './rest'; /* Built-in method references for those with the same name as other `lodash` methods. */ @@ -40,8 +41,7 @@ var nativeMin = Math.min; * // => [100, 10] */ var overArgs = rest(function(func, transforms) { - transforms = arrayMap(baseFlatten(transforms, 1), baseIteratee); - + transforms = arrayMap(baseFlatten(transforms, 1, isFlattenableIteratee), baseIteratee); var funcsLength = transforms.length; return rest(function(args) { var index = -1, diff --git a/package.json b/package.json index 3a5174ce6..927bb673d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lodash-es", - "version": "4.8.2", + "version": "4.9.0", "description": "Lodash exported as ES modules.", "homepage": "https://lodash.com/custom-builds", "license": "MIT", diff --git a/property.js b/property.js index 805270b74..559968dd8 100644 --- a/property.js +++ b/property.js @@ -14,14 +14,14 @@ import isKey from './_isKey'; * @example * * var objects = [ - * { 'a': { 'b': { 'c': 2 } } }, - * { 'a': { 'b': { 'c': 1 } } } + * { 'a': { 'b': 2 } }, + * { 'a': { 'b': 1 } } * ]; * - * _.map(objects, _.property('a.b.c')); + * _.map(objects, _.property('a.b')); * // => [2, 1] * - * _.map(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c'); + * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); * // => [1, 2] */ function property(path) { diff --git a/range.js b/range.js index 2a985c3b2..ed7de9b86 100644 --- a/range.js +++ b/range.js @@ -3,7 +3,7 @@ import createRange from './_createRange'; /** * Creates an array of numbers (positive and/or negative) progressing from * `start` up to, but not including, `end`. A step of `-1` is used if a negative - * `start` is specified without an `end` or `step`. If `end` is not specified + * `start` is specified without an `end` or `step`. If `end` is not specified, * it's set to `start` with `start` then set to `0`. * * **Note:** JavaScript follows the IEEE-754 standard for resolving diff --git a/reduce.js b/reduce.js index 187cfd8db..46a78cafe 100644 --- a/reduce.js +++ b/reduce.js @@ -8,7 +8,7 @@ import isArray from './isArray'; * Reduces `collection` to a value which is the accumulated result of running * each element in `collection` thru `iteratee`, where each successive * invocation is supplied the return value of the previous. If `accumulator` - * is not given the first element of `collection` is used as the initial + * is not given, the first element of `collection` is used as the initial * value. The iteratee is invoked with four arguments: * (accumulator, value, index|key, collection). * diff --git a/set.js b/set.js index f7581832c..45a6d334c 100644 --- a/set.js +++ b/set.js @@ -1,7 +1,7 @@ import baseSet from './_baseSet'; /** - * Sets the value at `path` of `object`. If a portion of `path` doesn't exist + * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, * it's created. Arrays are created for missing index properties while objects * are created for all other missing properties. Use `_.setWith` to customize * `path` creation. diff --git a/split.js b/split.js index 30640a6ec..773ce73bc 100644 --- a/split.js +++ b/split.js @@ -1,5 +1,19 @@ +import isRegExp from './isRegExp'; +import stringToArray from './_stringToArray'; import toString from './toString'; +/** Used to compose unicode character classes. */ +var rsAstralRange = '\\ud800-\\udfff', + rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23', + rsComboSymbolsRange = '\\u20d0-\\u20f0', + rsVarRange = '\\ufe0e\\ufe0f'; + +/** Used to compose unicode capture groups. */ +var rsZWJ = '\\u200d'; + +/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ +var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']'); + /** * Splits `string` by `separator`. * @@ -20,7 +34,18 @@ import toString from './toString'; * // => ['a', 'b'] */ function split(string, separator, limit) { - return toString(string).split(separator, limit); + string = toString(string); + if (string && ( + typeof separator == 'string' || + (separator != null && !isRegExp(separator)) + )) { + separator += ''; + if (separator == '' && reHasComplexSymbol.test(string)) { + var strSymbols = stringToArray(string); + return limit === undefined ? strSymbols : strSymbols.slice(0, limit < 0 ? 0 : limit); + } + } + return string.split(separator, limit); } export default split; diff --git a/template.js b/template.js index 11662425e..9c69aa210 100644 --- a/template.js +++ b/template.js @@ -32,7 +32,7 @@ var reUnescapedString = /['\n\r\u2028\u2029\\]/g; * in "interpolate" delimiters, HTML-escape interpolated data properties in * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data * properties may be accessed as free variables in the template. If a setting - * object is given it takes precedence over `_.templateSettings` values. + * object is given, it takes precedence over `_.templateSettings` values. * * **Note:** In the development build `_.template` utilizes * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) diff --git a/throttle.js b/throttle.js index cc0c7f324..92616a8af 100644 --- a/throttle.js +++ b/throttle.js @@ -18,7 +18,7 @@ var FUNC_ERROR_TEXT = 'Expected a function'; * invoked on the trailing edge of the timeout only if the throttled function * is invoked more than once during the `wait` timeout. * - * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation) + * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) * for details over the differences between `_.throttle` and `_.debounce`. * * @static diff --git a/union.js b/union.js index 9699a0f55..6e23eed49 100644 --- a/union.js +++ b/union.js @@ -1,5 +1,6 @@ import baseFlatten from './_baseFlatten'; import baseUniq from './_baseUniq'; +import isArrayLikeObject from './isArrayLikeObject'; import rest from './rest'; /** @@ -19,7 +20,7 @@ import rest from './rest'; * // => [2, 1, 4] */ var union = rest(function(arrays) { - return baseUniq(baseFlatten(arrays, 1, true)); + return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); }); export default union; diff --git a/unionBy.js b/unionBy.js index f8b44b76c..11c1afe15 100644 --- a/unionBy.js +++ b/unionBy.js @@ -33,7 +33,7 @@ var unionBy = rest(function(arrays) { if (isArrayLikeObject(iteratee)) { iteratee = undefined; } - return baseUniq(baseFlatten(arrays, 1, true), baseIteratee(iteratee)); + return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), baseIteratee(iteratee)); }); export default unionBy; diff --git a/unionWith.js b/unionWith.js index efe002bdc..16a8197b1 100644 --- a/unionWith.js +++ b/unionWith.js @@ -29,7 +29,7 @@ var unionWith = rest(function(arrays) { if (isArrayLikeObject(comparator)) { comparator = undefined; } - return baseUniq(baseFlatten(arrays, 1, true), undefined, comparator); + return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator); }); export default unionWith; diff --git a/uniqueId.js b/uniqueId.js index a1d9002fd..9684ede3d 100644 --- a/uniqueId.js +++ b/uniqueId.js @@ -4,7 +4,7 @@ import toString from './toString'; var idCounter = 0; /** - * Generates a unique ID. If `prefix` is given the ID is appended to it. + * Generates a unique ID. If `prefix` is given, the ID is appended to it. * * @static * @since 0.1.0 diff --git a/wrapperLodash.js b/wrapperLodash.js index 062adfa88..c5ebfbff5 100644 --- a/wrapperLodash.js +++ b/wrapperLodash.js @@ -29,9 +29,9 @@ var hasOwnProperty = objectProto.hasOwnProperty; * Shortcut fusion is an optimization to merge iteratee calls; this avoids * the creation of intermediate arrays and can greatly reduce the number of * iteratee executions. Sections of a chain sequence qualify for shortcut - * fusion if the section is applied to an array of at least two hundred - * elements and any iteratees accept only one argument. The heuristic for - * whether a section qualifies for shortcut fusion is subject to change. + * fusion if the section is applied to an array of at least `200` elements + * and any iteratees accept only one argument. The heuristic for whether a + * section qualifies for shortcut fusion is subject to change. * * Chaining is supported in custom builds as long as the `_#value` method is * directly or indirectly included in the build.