Compare commits

...

7 Commits

Author SHA1 Message Date
John-David Dalton
35805ec250 Bump to v4.11.2. 2016-04-21 07:06:47 -07:00
John-David Dalton
692aabae13 Bump to v4.11.1. 2016-04-13 21:03:52 -07:00
John-David Dalton
764eccfdc0 Bump to v4.11.0. 2016-04-13 10:21:06 -07:00
John-David Dalton
f10bb8b80b Bump to v4.10.0. 2016-04-10 22:55:59 -07:00
John-David Dalton
b7e3b3febd Bump to v4.9.0. 2016-04-08 01:32:35 -07:00
John-David Dalton
e8cff1ef54 Bump to v4.8.2. 2016-04-04 13:55:37 -07:00
John-David Dalton
723c02dbfa Bump to v4.8.0. 2016-04-03 23:03:03 -07:00
198 changed files with 981 additions and 583 deletions

View File

@@ -1,10 +1,10 @@
# lodash-es v4.7.0
# lodash-es v4.11.2
The [lodash](https://lodash.com/) library exported as [ES](http://www.ecma-international.org/ecma-262/6.0/) modules.
The [Lodash](https://lodash.com/) library exported as [ES](http://www.ecma-international.org/ecma-262/6.0/) modules.
Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli):
```bash
$ lodash modularize exports=es -o ./
```
See the [package source](https://github.com/lodash/lodash/tree/4.7.0-es) for more details.
See the [package source](https://github.com/lodash/lodash/tree/4.11.2-es) for more details.

View File

@@ -4,7 +4,7 @@ import nativeCreate from './_nativeCreate';
var objectProto = Object.prototype;
/**
* Creates an hash object.
* Creates a hash object.
*
* @private
* @constructor

View File

@@ -5,7 +5,7 @@
* @private
* @param {Function} func The function to invoke.
* @param {*} thisArg The `this` binding of `func`.
* @param {...*} args The arguments to invoke `func` with.
* @param {Array} args The arguments to invoke `func` with.
* @returns {*} Returns the result of `func`.
*/
function apply(func, thisArg, args) {

View File

@@ -1,14 +0,0 @@
import isSymbol from './isSymbol';
/**
* Casts `value` to a string if it's not a string or symbol.
*
* @private
* @param {*} value The value to inspect.
* @returns {string|symbol} Returns the cast key.
*/
function baseCastKey(key) {
return (typeof key == 'string' || isSymbol(key)) ? key : (key + '');
}
export default baseCastKey;

View File

@@ -47,6 +47,7 @@ function baseDifference(array, values, iteratee, comparator) {
var value = array[index],
computed = iteratee ? iteratee(value) : value;
value = (comparator || value !== 0) ? value : 0;
if (isCommon && computed === computed) {
var valuesIndex = valuesLength;
while (valuesIndex--) {

View File

@@ -1,3 +1,5 @@
import isSymbol from './isSymbol';
/**
* The base implementation of methods like `_.max` and `_.min` which accepts a
* `comparator` to determine the extremum value.
@@ -17,7 +19,7 @@ function baseExtremum(array, iteratee, comparator) {
current = iteratee(value);
if (current != null && (computed === undefined
? current === current
? (current === current && !isSymbol(current))
: comparator(current, computed)
)) {
var computed = current,

View File

@@ -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);
}

View File

@@ -2,7 +2,7 @@ import createBaseFor from './_createBaseFor';
/**
* The base implementation of `baseForOwn` which iterates over `object`
* properties returned by `keysFunc` invoking `iteratee` for each property.
* properties returned by `keysFunc` and invokes `iteratee` for each property.
* Iteratee functions may exit iteration early by explicitly returning `false`.
*
* @private

View File

@@ -1,5 +1,6 @@
import baseCastPath from './_baseCastPath';
import castPath from './_castPath';
import isKey from './_isKey';
import toKey from './_toKey';
/**
* The base implementation of `_.get` without support for default values.
@@ -10,13 +11,13 @@ import isKey from './_isKey';
* @returns {*} Returns the resolved value.
*/
function baseGet(object, path) {
path = isKey(path, object) ? [path] : baseCastPath(path);
path = isKey(path, object) ? [path] : castPath(path);
var index = 0,
length = path.length;
while (object != null && index < length) {
object = object[path[index++]];
object = object[toKey(path[index++])];
}
return (index && index == length) ? object : undefined;
}

14
_baseGt.js Normal file
View File

@@ -0,0 +1,14 @@
/**
* The base implementation of `_.gt` which doesn't coerce arguments to numbers.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if `value` is greater than `other`,
* else `false`.
*/
function baseGt(value, other) {
return value > other;
}
export default baseGt;

View File

@@ -47,6 +47,7 @@ function baseIntersection(arrays, iteratee, comparator) {
var value = array[index],
computed = iteratee ? iteratee(value) : value;
value = (comparator || value !== 0) ? value : 0;
if (!(seen
? cacheHas(seen, computed)
: includes(result, computed, comparator)

View File

@@ -1,8 +1,9 @@
import apply from './_apply';
import baseCastPath from './_baseCastPath';
import castPath from './_castPath';
import isKey from './_isKey';
import last from './last';
import parent from './_parent';
import toKey from './_toKey';
/**
* The base implementation of `_.invoke` without support for individual
@@ -16,11 +17,11 @@ import parent from './_parent';
*/
function baseInvoke(object, path, args) {
if (!isKey(path, object)) {
path = baseCastPath(path);
path = castPath(path);
object = parent(object, path);
path = last(path);
}
var func = object == null ? object : object[path];
var func = object == null ? object : object[toKey(path)];
return func == null ? undefined : apply(func, object, args);
}

14
_baseLt.js Normal file
View File

@@ -0,0 +1,14 @@
/**
* The base implementation of `_.lt` which doesn't coerce arguments to numbers.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if `value` is less than `other`,
* else `false`.
*/
function baseLt(value, other) {
return value < other;
}
export default baseLt;

View File

@@ -1,5 +1,6 @@
import baseIsMatch from './_baseIsMatch';
import getMatchData from './_getMatchData';
import matchesStrictComparable from './_matchesStrictComparable';
/**
* The base implementation of `_.matches` which doesn't clone `source`.
@@ -11,16 +12,7 @@ import getMatchData from './_getMatchData';
function baseMatches(source) {
var matchData = getMatchData(source);
if (matchData.length == 1 && matchData[0][2]) {
var key = matchData[0][0],
value = matchData[0][1];
return function(object) {
if (object == null) {
return false;
}
return object[key] === value &&
(value !== undefined || (key in Object(object)));
};
return matchesStrictComparable(matchData[0][0], matchData[0][1]);
}
return function(object) {
return object === source || baseIsMatch(object, source, matchData);

View File

@@ -1,6 +1,10 @@
import baseIsEqual from './_baseIsEqual';
import get from './get';
import hasIn from './hasIn';
import isKey from './_isKey';
import isStrictComparable from './_isStrictComparable';
import matchesStrictComparable from './_matchesStrictComparable';
import toKey from './_toKey';
/** Used to compose bitmasks for comparison styles. */
var UNORDERED_COMPARE_FLAG = 1,
@@ -15,6 +19,9 @@ var UNORDERED_COMPARE_FLAG = 1,
* @returns {Function} Returns the new function.
*/
function baseMatchesProperty(path, srcValue) {
if (isKey(path) && isStrictComparable(srcValue)) {
return matchesStrictComparable(toKey(path), srcValue);
}
return function(object) {
var objValue = get(object, path);
return (objValue === undefined && objValue === srcValue)

20
_baseNth.js Normal file
View File

@@ -0,0 +1,20 @@
import isIndex from './_isIndex';
/**
* The base implementation of `_.nth` which doesn't coerce `n` to an integer.
*
* @private
* @param {Array} array The array to query.
* @param {number} n The index of the element to return.
* @returns {*} Returns the nth element of `array`.
*/
function baseNth(array, n) {
var length = array.length;
if (!length) {
return;
}
n += n < 0 ? length : 0;
return isIndex(n, length) ? array[n] : undefined;
}
export default baseNth;

View File

@@ -2,6 +2,7 @@ import arrayMap from './_arrayMap';
import baseIteratee from './_baseIteratee';
import baseMap from './_baseMap';
import baseSortBy from './_baseSortBy';
import baseUnary from './_baseUnary';
import compareMultiple from './_compareMultiple';
import identity from './identity';
@@ -16,7 +17,7 @@ import identity from './identity';
*/
function baseOrderBy(collection, iteratees, orders) {
var index = -1;
iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseIteratee);
iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(baseIteratee));
var result = baseMap(collection, function(value, key, collection) {
var criteria = arrayMap(iteratees, function(iteratee) {

View File

@@ -1,8 +1,9 @@
import baseCastPath from './_baseCastPath';
import castPath from './_castPath';
import isIndex from './_isIndex';
import isKey from './_isKey';
import last from './last';
import parent from './_parent';
import toKey from './_toKey';
/** Used for built-in method references. */
var arrayProto = Array.prototype;
@@ -25,21 +26,21 @@ function basePullAt(array, indexes) {
while (length--) {
var index = indexes[length];
if (lastIndex == length || index != previous) {
if (length == lastIndex || index !== previous) {
var previous = index;
if (isIndex(index)) {
splice.call(array, index, 1);
}
else if (!isKey(index, array)) {
var path = baseCastPath(index),
var path = castPath(index),
object = parent(array, path);
if (object != null) {
delete object[last(path)];
delete object[toKey(last(path))];
}
}
else {
delete array[index];
delete array[toKey(index)];
}
}
}

View File

@@ -1,8 +1,9 @@
import assignValue from './_assignValue';
import baseCastPath from './_baseCastPath';
import castPath from './_castPath';
import isIndex from './_isIndex';
import isKey from './_isKey';
import isObject from './isObject';
import toKey from './_toKey';
/**
* The base implementation of `_.set`.
@@ -15,7 +16,7 @@ import isObject from './isObject';
* @returns {Object} Returns `object`.
*/
function baseSet(object, path, value, customizer) {
path = isKey(path, object) ? [path] : baseCastPath(path);
path = isKey(path, object) ? [path] : castPath(path);
var index = -1,
length = path.length,
@@ -23,7 +24,7 @@ function baseSet(object, path, value, customizer) {
nested = object;
while (nested != null && ++index < length) {
var key = path[index];
var key = toKey(path[index]);
if (isObject(nested)) {
var newValue = value;
if (index != lastIndex) {

View File

@@ -1,5 +1,6 @@
import baseSortedIndexBy from './_baseSortedIndexBy';
import identity from './identity';
import isSymbol from './isSymbol';
/** Used as references for the maximum length and index of an array. */
var MAX_ARRAY_LENGTH = 4294967295,
@@ -26,7 +27,8 @@ function baseSortedIndex(array, value, retHighest) {
var mid = (low + high) >>> 1,
computed = array[mid];
if ((retHighest ? (computed <= value) : (computed < value)) && computed !== null) {
if (computed !== null && !isSymbol(computed) &&
(retHighest ? (computed <= value) : (computed < value))) {
low = mid + 1;
} else {
high = mid;

View File

@@ -1,3 +1,5 @@
import isSymbol from './isSymbol';
/** Used as references for the maximum length and index of an array. */
var MAX_ARRAY_LENGTH = 4294967295,
MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1;
@@ -26,21 +28,26 @@ function baseSortedIndexBy(array, value, iteratee, retHighest) {
high = array ? array.length : 0,
valIsNaN = value !== value,
valIsNull = value === null,
valIsUndef = value === undefined;
valIsSymbol = isSymbol(value),
valIsUndefined = value === undefined;
while (low < high) {
var mid = nativeFloor((low + high) / 2),
computed = iteratee(array[mid]),
isDef = computed !== undefined,
isReflexive = computed === computed;
othIsDefined = computed !== undefined,
othIsNull = computed === null,
othIsReflexive = computed === computed,
othIsSymbol = isSymbol(computed);
if (valIsNaN) {
var setLow = isReflexive || retHighest;
var setLow = retHighest || othIsReflexive;
} else if (valIsUndefined) {
setLow = othIsReflexive && (retHighest || othIsDefined);
} else if (valIsNull) {
setLow = isReflexive && isDef && (retHighest || computed != null);
} else if (valIsUndef) {
setLow = isReflexive && (retHighest || isDef);
} else if (computed == null) {
setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
} else if (valIsSymbol) {
setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
} else if (othIsNull || othIsSymbol) {
setLow = false;
} else {
setLow = retHighest ? (computed <= value) : (computed < value);

View File

@@ -1,14 +1,30 @@
import baseSortedUniqBy from './_baseSortedUniqBy';
import eq from './eq';
/**
* The base implementation of `_.sortedUniq`.
* The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
* support for iteratee shorthands.
*
* @private
* @param {Array} array The array to inspect.
* @param {Function} [iteratee] The iteratee invoked per element.
* @returns {Array} Returns the new duplicate free array.
*/
function baseSortedUniq(array) {
return baseSortedUniqBy(array);
function baseSortedUniq(array, iteratee) {
var index = -1,
length = array.length,
resIndex = 0,
result = [];
while (++index < length) {
var value = array[index],
computed = iteratee ? iteratee(value) : value;
if (!index || !eq(computed, seen)) {
var seen = computed;
result[resIndex++] = value === 0 ? 0 : value;
}
}
return result;
}
export default baseSortedUniq;

View File

@@ -1,33 +0,0 @@
import eq from './eq';
/**
* The base implementation of `_.sortedUniqBy` without support for iteratee
* shorthands.
*
* @private
* @param {Array} array The array to inspect.
* @param {Function} [iteratee] The iteratee invoked per element.
* @returns {Array} Returns the new duplicate free array.
*/
function baseSortedUniqBy(array, iteratee) {
var index = 0,
length = array.length,
value = array[0],
computed = iteratee ? iteratee(value) : value,
seen = computed,
resIndex = 1,
result = [value];
while (++index < length) {
value = array[index],
computed = iteratee ? iteratee(value) : value;
if (!eq(computed, seen)) {
seen = computed;
result[resIndex++] = value;
}
}
return result;
}
export default baseSortedUniqBy;

24
_baseToNumber.js Normal file
View File

@@ -0,0 +1,24 @@
import isSymbol from './isSymbol';
/** Used as references for various `Number` constants. */
var NAN = 0 / 0;
/**
* The base implementation of `_.toNumber` which doesn't ensure correct
* conversions of binary, hexadecimal, or octal string values.
*
* @private
* @param {*} value The value to process.
* @returns {number} Returns the number.
*/
function baseToNumber(value) {
if (typeof value == 'number') {
return value;
}
if (isSymbol(value)) {
return NAN;
}
return +value;
}
export default baseToNumber;

31
_baseToString.js Normal file
View File

@@ -0,0 +1,31 @@
import Symbol from './_Symbol';
import isSymbol from './isSymbol';
/** Used as references for various `Number` constants. */
var INFINITY = 1 / 0;
/** Used to convert symbols to primitives and strings. */
var symbolProto = Symbol ? Symbol.prototype : undefined,
symbolToString = symbolProto ? symbolProto.toString : undefined;
/**
* The base implementation of `_.toString` which doesn't convert nullish
* values to empty strings.
*
* @private
* @param {*} value The value to process.
* @returns {string} Returns the string.
*/
function baseToString(value) {
// Exit early for strings to avoid a performance hit in some environments.
if (typeof value == 'string') {
return value;
}
if (isSymbol(value)) {
return symbolToString ? symbolToString.call(value) : '';
}
var result = (value + '');
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
}
export default baseToString;

View File

@@ -46,6 +46,7 @@ function baseUniq(array, iteratee, comparator) {
var value = array[index],
computed = iteratee ? iteratee(value) : value;
value = (comparator || value !== 0) ? value : 0;
if (isCommon && computed === computed) {
var seenIndex = seen.length;
while (seenIndex--) {

View File

@@ -1,8 +1,9 @@
import baseCastPath from './_baseCastPath';
import has from './has';
import baseHas from './_baseHas';
import castPath from './_castPath';
import isKey from './_isKey';
import last from './last';
import parent from './_parent';
import toKey from './_toKey';
/**
* The base implementation of `_.unset`.
@@ -13,10 +14,11 @@ import parent from './_parent';
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
*/
function baseUnset(object, path) {
path = isKey(path, object) ? [path] : baseCastPath(path);
path = isKey(path, object) ? [path] : castPath(path);
object = parent(object, path);
var key = last(path);
return (object != null && has(object, key)) ? delete object[key] : true;
var key = toKey(last(path));
return !(object != null && baseHas(object, key)) || delete object[key];
}
export default baseUnset;

View File

@@ -7,8 +7,8 @@ import isArrayLikeObject from './isArrayLikeObject';
* @param {*} value The value to inspect.
* @returns {Array|Object} Returns the cast array-like object.
*/
function baseCastArrayLikeObject(value) {
function castArrayLikeObject(value) {
return isArrayLikeObject(value) ? value : [];
}
export default baseCastArrayLikeObject;
export default castArrayLikeObject;

View File

@@ -7,8 +7,8 @@ import identity from './identity';
* @param {*} value The value to inspect.
* @returns {Function} Returns cast function.
*/
function baseCastFunction(value) {
function castFunction(value) {
return typeof value == 'function' ? value : identity;
}
export default baseCastFunction;
export default castFunction;

View File

@@ -8,8 +8,8 @@ import stringToPath from './_stringToPath';
* @param {*} value The value to inspect.
* @returns {Array} Returns the cast property path array.
*/
function baseCastPath(value) {
function castPath(value) {
return isArray(value) ? value : stringToPath(value);
}
export default baseCastPath;
export default castPath;

18
_castSlice.js Normal file
View File

@@ -0,0 +1,18 @@
import baseSlice from './_baseSlice';
/**
* Casts `array` to a slice if it's needed.
*
* @private
* @param {Array} array The array to inspect.
* @param {number} start The start position.
* @param {number} [end=array.length] The end position.
* @returns {Array} Returns the cast slice.
*/
function castSlice(array, start, end) {
var length = array.length;
end = end === undefined ? length : end;
return (!start && end >= length) ? array : baseSlice(array, start, end);
}
export default castSlice;

View File

@@ -1,3 +1,5 @@
import isSymbol from './isSymbol';
/**
* Compares values to sort them in ascending order.
*
@@ -8,22 +10,28 @@
*/
function compareAscending(value, other) {
if (value !== other) {
var valIsNull = value === null,
valIsUndef = value === undefined,
valIsReflexive = value === value;
var valIsDefined = value !== undefined,
valIsNull = value === null,
valIsReflexive = value === value,
valIsSymbol = isSymbol(value);
var othIsNull = other === null,
othIsUndef = other === undefined,
othIsReflexive = other === other;
var othIsDefined = other !== undefined,
othIsNull = other === null,
othIsReflexive = other === other,
othIsSymbol = isSymbol(other);
if ((value > other && !othIsNull) || !valIsReflexive ||
(valIsNull && !othIsUndef && othIsReflexive) ||
(valIsUndef && othIsReflexive)) {
if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
(valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
(valIsNull && othIsDefined && othIsReflexive) ||
(!valIsDefined && othIsReflexive) ||
!valIsReflexive) {
return 1;
}
if ((value < other && !valIsNull) || !othIsReflexive ||
(othIsNull && !valIsUndef && valIsReflexive) ||
(othIsUndef && valIsReflexive)) {
if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
(othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
(othIsNull && valIsDefined && valIsReflexive) ||
(!othIsDefined && valIsReflexive) ||
!othIsReflexive) {
return -1;
}
}

View File

@@ -1,4 +1,4 @@
import copyObjectWith from './_copyObjectWith';
import assignValue from './_assignValue';
/**
* Copies properties of `source` to `object`.
@@ -7,10 +7,25 @@ import copyObjectWith from './_copyObjectWith';
* @param {Object} source The object to copy properties from.
* @param {Array} props The property identifiers to copy.
* @param {Object} [object={}] The object to copy properties to.
* @param {Function} [customizer] The function to customize copied values.
* @returns {Object} Returns `object`.
*/
function copyObject(source, props, object) {
return copyObjectWith(source, props, object);
function copyObject(source, props, object, customizer) {
object || (object = {});
var index = -1,
length = props.length;
while (++index < length) {
var key = props[index];
var newValue = customizer
? customizer(object[key], source[key], key, object, source)
: source[key];
assignValue(object, key, newValue);
}
return object;
}
export default copyObject;

View File

@@ -1,32 +0,0 @@
import assignValue from './_assignValue';
/**
* This function is like `copyObject` except that it accepts a function to
* customize copied values.
*
* @private
* @param {Object} source The object to copy properties from.
* @param {Array} props The property identifiers to copy.
* @param {Object} [object={}] The object to copy properties to.
* @param {Function} [customizer] The function to customize copied values.
* @returns {Object} Returns `object`.
*/
function copyObjectWith(source, props, object, customizer) {
object || (object = {});
var index = -1,
length = props.length;
while (++index < length) {
var key = props[index];
var newValue = customizer
? customizer(object[key], source[key], key, object, source)
: source[key];
assignValue(object, key, newValue);
}
return object;
}
export default copyObjectWith;

View File

@@ -1,18 +1,8 @@
import castSlice from './_castSlice';
import reHasComplexSymbol from './_reHasComplexSymbol';
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 + ']');
/**
* Creates a function like `_.lowerFirst`.
*
@@ -28,8 +18,13 @@ function createCaseFirst(methodName) {
? stringToArray(string)
: undefined;
var chr = strSymbols ? strSymbols[0] : string.charAt(0),
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
var chr = strSymbols
? strSymbols[0]
: string.charAt(0);
var trailing = strSymbols
? castSlice(strSymbols, 1).join('')
: string.slice(1);
return chr[methodName]() + trailing;
};

View File

@@ -2,6 +2,12 @@ import arrayReduce from './_arrayReduce';
import deburr from './deburr';
import words from './words';
/** Used to compose unicode capture groups. */
var rsApos = "['\u2019]";
/** Used to match apostrophes. */
var reApos = RegExp(rsApos, 'g');
/**
* Creates a function like `_.camelCase`.
*
@@ -11,7 +17,7 @@ import words from './words';
*/
function createCompounder(callback) {
return function(string) {
return arrayReduce(words(deburr(string)), callback, '');
return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
};
}

View File

@@ -11,8 +11,8 @@ import isObject from './isObject';
*/
function createCtorWrapper(Ctor) {
return function() {
// Use a `switch` statement to work with class constructors.
// See http://ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
// Use a `switch` statement to work with class constructors. See
// http://ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
// for more details.
var args = arguments;
switch (args.length) {

View File

@@ -1,3 +1,6 @@
import baseToNumber from './_baseToNumber';
import baseToString from './_baseToString';
/**
* Creates a function that performs a mathematical operation on two values.
*
@@ -15,7 +18,17 @@ function createMathOperation(operator) {
result = value;
}
if (other !== undefined) {
result = result === undefined ? other : operator(result, other);
if (result === undefined) {
return other;
}
if (typeof value == 'string' || typeof other == 'string') {
value = baseToString(value);
other = baseToString(other);
} else {
value = baseToNumber(value);
other = baseToNumber(other);
}
result = operator(value, other);
}
return result;
};

View File

@@ -2,6 +2,9 @@ import apply from './_apply';
import arrayMap from './_arrayMap';
import baseFlatten from './_baseFlatten';
import baseIteratee from './_baseIteratee';
import baseUnary from './_baseUnary';
import isArray from './isArray';
import isFlattenableIteratee from './_isFlattenableIteratee';
import rest from './rest';
/**
@@ -13,7 +16,10 @@ import rest from './rest';
*/
function createOver(arrayFunc) {
return rest(function(iteratees) {
iteratees = arrayMap(baseFlatten(iteratees, 1), baseIteratee);
iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
? arrayMap(iteratees[0], baseUnary(baseIteratee))
: arrayMap(baseFlatten(iteratees, 1, isFlattenableIteratee), baseUnary(baseIteratee));
return rest(function(args) {
var thisArg = this;
return arrayFunc(iteratees, function(iteratee) {

View File

@@ -1,19 +1,10 @@
import baseRepeat from './_baseRepeat';
import baseToString from './_baseToString';
import castSlice from './_castSlice';
import reHasComplexSymbol from './_reHasComplexSymbol';
import stringSize from './_stringSize';
import stringToArray from './_stringToArray';
/** 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 + ']');
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeCeil = Math.ceil;
@@ -27,7 +18,7 @@ var nativeCeil = Math.ceil;
* @returns {string} Returns the padding for `string`.
*/
function createPadding(length, chars) {
chars = chars === undefined ? ' ' : (chars + '');
chars = chars === undefined ? ' ' : baseToString(chars);
var charsLength = chars.length;
if (charsLength < 2) {
@@ -35,7 +26,7 @@ function createPadding(length, chars) {
}
var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
return reHasComplexSymbol.test(chars)
? stringToArray(result).slice(0, length).join('')
? castSlice(stringToArray(result), 0, length).join('')
: result.slice(0, length);
}

View File

@@ -6,9 +6,8 @@ import root from './_root';
var BIND_FLAG = 1;
/**
* Creates a function that wraps `func` to invoke it with the optional `this`
* binding of `thisArg` and the `partials` prepended to those provided to
* the wrapper.
* Creates a function that wraps `func` to invoke it with the `this` binding
* of `thisArg` and `partials` prepended to the arguments it receives.
*
* @private
* @param {Function} func The function to wrap.

View File

@@ -1,4 +1,3 @@
import copyArray from './_copyArray';
import isLaziable from './_isLaziable';
import setData from './_setData';
@@ -30,7 +29,6 @@ var BIND_FLAG = 1,
*/
function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
var isCurry = bitmask & CURRY_FLAG,
newArgPos = argPos ? copyArray(argPos) : undefined,
newHolders = isCurry ? holders : undefined,
newHoldersRight = isCurry ? undefined : holders,
newPartials = isCurry ? partials : undefined,
@@ -44,7 +42,7 @@ function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, par
}
var newData = [
func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
newHoldersRight, newArgPos, ary, arity
newHoldersRight, argPos, ary, arity
];
var result = wrapFunc.apply(undefined, newData);

View File

@@ -0,0 +1,20 @@
import toNumber from './toNumber';
/**
* Creates a function that performs a relational operation on two values.
*
* @private
* @param {Function} operator The function to perform the operation.
* @returns {Function} Returns the new relational operation function.
*/
function createRelationalOperation(operator) {
return function(value, other) {
if (!(typeof value == 'string' && typeof other == 'string')) {
value = toNumber(value);
other = toNumber(other);
}
return operator(value, other);
};
}
export default createRelationalOperation;

View File

@@ -1,5 +1,9 @@
import Set from './_Set';
import noop from './noop';
import setToArray from './_setToArray';
/** Used as references for various `Number` constants. */
var INFINITY = 1 / 0;
/**
* Creates a set of `values`.
@@ -8,7 +12,7 @@ import noop from './noop';
* @param {Array} values The values to add to the set.
* @returns {Object} Returns the new set.
*/
var createSet = !(Set && new Set([1, 2]).size === 2) ? noop : function(values) {
var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
return new Set(values);
};

View File

@@ -78,7 +78,8 @@ function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
case regexpTag:
case stringTag:
// Coerce regexes to strings and treat strings, primitives and objects,
// as equal. See https://es5.github.io/#x15.10.6.4 for more details.
// as equal. See http://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype.tostring
// for more details.
return object == (other + '');
case mapTag:

View File

@@ -3,6 +3,7 @@ import Map from './_Map';
import Promise from './_Promise';
import Set from './_Set';
import WeakMap from './_WeakMap';
import toSource from './_toSource';
/** `Object#toString` result references. */
var mapTag = '[object Map]',
@@ -16,21 +17,19 @@ var dataViewTag = '[object DataView]';
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to resolve the decompiled source of functions. */
var funcToString = Function.prototype.toString;
/**
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/** Used to detect maps, sets, and weakmaps. */
var dataViewCtorString = DataView ? (DataView + '') : '',
mapCtorString = Map ? funcToString.call(Map) : '',
promiseCtorString = Promise ? funcToString.call(Promise) : '',
setCtorString = Set ? funcToString.call(Set) : '',
weakMapCtorString = WeakMap ? funcToString.call(WeakMap) : '';
var dataViewCtorString = toSource(DataView),
mapCtorString = toSource(Map),
promiseCtorString = toSource(Promise),
setCtorString = toSource(Set),
weakMapCtorString = toSource(WeakMap);
/**
* Gets the `toStringTag` of `value`.
@@ -52,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 = typeof Ctor == 'function' ? funcToString.call(Ctor) : '';
Ctor = result == objectTag ? value.constructor : undefined,
ctorString = Ctor ? toSource(Ctor) : undefined;
if (ctorString) {
switch (ctorString) {

View File

@@ -1,10 +1,11 @@
import baseCastPath from './_baseCastPath';
import castPath from './_castPath';
import isArguments from './isArguments';
import isArray from './isArray';
import isIndex from './_isIndex';
import isKey from './_isKey';
import isLength from './isLength';
import isString from './isString';
import toKey from './_toKey';
/**
* Checks if `path` exists on `object`.
@@ -16,29 +17,25 @@ import isString from './isString';
* @returns {boolean} Returns `true` if `path` exists, else `false`.
*/
function hasPath(object, path, hasFunc) {
if (object == null) {
return false;
}
var result = hasFunc(object, path);
if (!result && !isKey(path)) {
path = baseCastPath(path);
path = isKey(path, object) ? [path] : castPath(path);
var index = -1,
length = path.length;
var result,
index = -1,
length = path.length;
while (object != null && ++index < length) {
var key = path[index];
if (!(result = hasFunc(object, key))) {
break;
}
object = object[key];
while (++index < length) {
var key = toKey(path[index]);
if (!(result = object != null && hasFunc(object, key))) {
break;
}
object = object[key];
}
var length = object ? object.length : undefined;
return result || (
!!length && isLength(length) && isIndex(path, length) &&
(isArray(object) || isString(object) || isArguments(object))
);
if (result) {
return result;
}
var length = object ? object.length : 0;
return !!length && isLength(length) && isIndex(key, length) &&
(isArray(object) || isString(object) || isArguments(object));
}
export default hasPath;

16
_isFlattenable.js Normal file
View File

@@ -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;

16
_isFlattenableIteratee.js Normal file
View File

@@ -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;

View File

@@ -13,9 +13,10 @@ var reIsUint = /^(?:0|[1-9]\d*)$/;
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
*/
function isIndex(value, length) {
value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
length = length == null ? MAX_SAFE_INTEGER : length;
return value > -1 && value % 1 == 0 && value < length;
return !!length &&
(typeof value == 'number' || reIsUint.test(value)) &&
(value > -1 && value % 1 == 0 && value < length);
}
export default isIndex;

View File

@@ -14,13 +14,16 @@ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
*/
function isKey(value, object) {
if (isArray(value)) {
return false;
}
var type = typeof value;
if (type == 'number' || type == 'symbol') {
if (type == 'number' || type == 'symbol' || type == 'boolean' ||
value == null || isSymbol(value)) {
return true;
}
return !isArray(value) &&
(isSymbol(value) || reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
(object != null && value in Object(object)));
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
(object != null && value in Object(object));
}
export default isKey;

View File

@@ -7,8 +7,9 @@
*/
function isKeyable(value) {
var type = typeof value;
return type == 'number' || type == 'boolean' ||
(type == 'string' && value != '__proto__') || value == null;
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
? (value !== '__proto__')
: (value === null);
}
export default isKeyable;

View File

@@ -0,0 +1,20 @@
/**
* A specialized version of `matchesProperty` for source values suitable
* for strict equality comparisons, i.e. `===`.
*
* @private
* @param {string} key The key of the property to get.
* @param {*} srcValue The value to match.
* @returns {Function} Returns the new function.
*/
function matchesStrictComparable(key, srcValue) {
return function(object) {
if (object == null) {
return false;
}
return object[key] === srcValue &&
(srcValue !== undefined || (key in Object(object)));
};
}
export default matchesStrictComparable;

View File

@@ -1,6 +1,5 @@
import composeArgs from './_composeArgs';
import composeArgsRight from './_composeArgsRight';
import copyArray from './_copyArray';
import replaceHolders from './_replaceHolders';
/** Used as the internal argument placeholder. */
@@ -58,20 +57,20 @@ function mergeData(data, source) {
var value = source[3];
if (value) {
var partials = data[3];
data[3] = partials ? composeArgs(partials, value, source[4]) : copyArray(value);
data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : copyArray(source[4]);
data[3] = partials ? composeArgs(partials, value, source[4]) : value;
data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
}
// Compose partial right arguments.
value = source[5];
if (value) {
partials = data[5];
data[5] = partials ? composeArgsRight(partials, value, source[6]) : copyArray(value);
data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : copyArray(source[6]);
data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
}
// Use source `argPos` if available.
value = source[7];
if (value) {
data[7] = copyArray(value);
data[7] = value;
}
// Use source `ary` if it's smaller.
if (srcBitmask & ARY_FLAG) {

13
_reHasComplexSymbol.js Normal file
View File

@@ -0,0 +1,13 @@
/** 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 + ']');
export default reHasComplexSymbol;

View File

@@ -1,3 +1,5 @@
import reHasComplexSymbol from './_reHasComplexSymbol';
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
@@ -24,9 +26,6 @@ var reOptMod = rsModifier + '?',
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
/** 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 + ']');
/**
* Gets the number of symbols in `string`.
*

21
_toKey.js Normal file
View File

@@ -0,0 +1,21 @@
import isSymbol from './isSymbol';
/** Used as references for various `Number` constants. */
var INFINITY = 1 / 0;
/**
* Converts `value` to a string key if it's not a string or symbol.
*
* @private
* @param {*} value The value to inspect.
* @returns {string|symbol} Returns the key.
*/
function toKey(value) {
if (typeof value == 'string' || isSymbol(value)) {
return value;
}
var result = (value + '');
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
}
export default toKey;

23
_toSource.js Normal file
View File

@@ -0,0 +1,23 @@
/** Used to resolve the decompiled source of functions. */
var funcToString = Function.prototype.toString;
/**
* Converts `func` to its source code.
*
* @private
* @param {Function} func The function to process.
* @returns {string} Returns the source code.
*/
function toSource(func) {
if (func != null) {
try {
return funcToString.call(func);
} catch (e) {}
try {
return (func + '');
} catch (e) {}
}
return '';
}
export default toSource;

View File

@@ -24,6 +24,7 @@ import intersectionWith from './intersectionWith';
import join from './join';
import last from './last';
import lastIndexOf from './lastIndexOf';
import nth from './nth';
import pull from './pull';
import pullAll from './pullAll';
import pullAllBy from './pullAllBy';
@@ -68,12 +69,12 @@ export default {
fill, findIndex, findLastIndex, flatten, flattenDeep,
flattenDepth, fromPairs, head, indexOf, initial,
intersection, intersectionBy, intersectionWith, join, last,
lastIndexOf, pull, pullAll, pullAllBy, pullAllWith,
pullAt, remove, reverse, slice, sortedIndex,
sortedIndexBy, sortedIndexOf, sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf,
sortedUniq, sortedUniqBy, tail, take, takeRight,
takeRightWhile, takeWhile, union, unionBy, unionWith,
uniq, uniqBy, uniqWith, unzip, unzipWith,
without, xor, xorBy, xorWith, zip,
zipObject, zipObjectDeep, zipWith
lastIndexOf, nth, pull, pullAll, pullAllBy,
pullAllWith, pullAt, remove, reverse, slice,
sortedIndex, sortedIndexBy, sortedIndexOf, sortedLastIndex, sortedLastIndexBy,
sortedLastIndexOf, sortedUniq, sortedUniqBy, tail, take,
takeRight, takeRightWhile, takeWhile, union, unionBy,
unionWith, uniq, uniqBy, uniqWith, unzip,
unzipWith, without, xor, xorBy, xorWith,
zip, zipObject, zipObjectDeep, zipWith
};

View File

@@ -24,6 +24,7 @@ export { default as intersectionWith } from './intersectionWith';
export { default as join } from './join';
export { default as last } from './last';
export { default as lastIndexOf } from './lastIndexOf';
export { default as nth } from './nth';
export { default as pull } from './pull';
export { default as pullAll } from './pullAll';
export { default as pullAllBy } from './pullAllBy';

4
ary.js
View File

@@ -4,8 +4,8 @@ import createWrapper from './_createWrapper';
var ARY_FLAG = 128;
/**
* Creates a function that accepts up to `n` arguments, ignoring any
* additional arguments.
* Creates a function that invokes `func`, with up to `n` arguments,
* ignoring any additional arguments.
*
* @static
* @memberOf _

View File

@@ -32,6 +32,7 @@ var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
* @param {Object} object The destination object.
* @param {...Object} [sources] The source objects.
* @returns {Object} Returns `object`.
* @see _.assignIn
* @example
*
* function Foo() {

View File

@@ -28,6 +28,7 @@ var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
* @param {Object} object The destination object.
* @param {...Object} [sources] The source objects.
* @returns {Object} Returns `object`.
* @see _.assign
* @example
*
* function Foo() {

View File

@@ -1,11 +1,11 @@
import copyObjectWith from './_copyObjectWith';
import copyObject from './_copyObject';
import createAssigner from './_createAssigner';
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`.
@@ -19,6 +19,7 @@ import keysIn from './keysIn';
* @param {...Object} sources The source objects.
* @param {Function} [customizer] The function to customize assigned values.
* @returns {Object} Returns `object`.
* @see _.assignWith
* @example
*
* function customizer(objValue, srcValue) {
@@ -31,7 +32,7 @@ import keysIn from './keysIn';
* // => { 'a': 1, 'b': 2 }
*/
var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
copyObjectWith(source, keysIn(source), object, customizer);
copyObject(source, keysIn(source), object, customizer);
});
export default assignInWith;

View File

@@ -1,11 +1,11 @@
import copyObjectWith from './_copyObjectWith';
import copyObject from './_copyObject';
import createAssigner from './_createAssigner';
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`.
@@ -18,6 +18,7 @@ import keys from './keys';
* @param {...Object} sources The source objects.
* @param {Function} [customizer] The function to customize assigned values.
* @returns {Object} Returns `object`.
* @see _.assignInWith
* @example
*
* function customizer(objValue, srcValue) {
@@ -30,7 +31,7 @@ import keys from './keys';
* // => { 'a': 1, 'b': 2 }
*/
var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
copyObjectWith(source, keys(source), object, customizer);
copyObject(source, keys(source), object, customizer);
});
export default assignWith;

3
at.js
View File

@@ -10,8 +10,7 @@ import rest from './rest';
* @since 1.0.0
* @category Object
* @param {Object} object The object to iterate over.
* @param {...(string|string[])} [paths] The property paths of elements to pick,
* specified individually or in arrays.
* @param {...(string|string[])} [paths] The property paths of elements to pick.
* @returns {Array} Returns the new array of picked elements.
* @example
*

View File

@@ -9,8 +9,7 @@ var BIND_FLAG = 1,
/**
* Creates a function that invokes `func` with the `this` binding of `thisArg`
* and prepends any additional `_.bind` arguments to those provided to the
* bound function.
* and `partials` prepended to the arguments it receives.
*
* The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
* may be used as a placeholder for partially applied arguments.

View File

@@ -2,6 +2,7 @@ import arrayEach from './_arrayEach';
import baseFlatten from './_baseFlatten';
import bind from './bind';
import rest from './rest';
import toKey from './_toKey';
/**
* Binds methods of an object to the object itself, overwriting the existing
@@ -14,8 +15,7 @@ import rest from './rest';
* @memberOf _
* @category Util
* @param {Object} object The object to bind and assign the bound methods to.
* @param {...(string|string[])} methodNames The object method names to bind,
* specified individually or in arrays.
* @param {...(string|string[])} methodNames The object method names to bind.
* @returns {Object} Returns `object`.
* @example
*
@@ -32,6 +32,7 @@ import rest from './rest';
*/
var bindAll = rest(function(object, methodNames) {
arrayEach(baseFlatten(methodNames, 1), function(key) {
key = toKey(key);
object[key] = bind(object[key], object);
});
return object;

View File

@@ -9,8 +9,8 @@ var BIND_FLAG = 1,
PARTIAL_FLAG = 32;
/**
* Creates a function that invokes the method at `object[key]` and prepends
* any additional `_.bindKey` arguments to those provided to the bound function.
* Creates a function that invokes the method at `object[key]` with `partials`
* prepended to the arguments it receives.
*
* This method differs from `_.bind` by allowing bound functions to reference
* methods that may be redefined or don't yet exist. See

View File

@@ -1,4 +1,5 @@
import baseSlice from './_baseSlice';
import isIterateeCall from './_isIterateeCall';
import toInteger from './toInteger';
/* Built-in method references for those with the same name as other `lodash` methods. */
@@ -15,7 +16,8 @@ var nativeCeil = Math.ceil,
* @since 3.0.0
* @category Array
* @param {Array} array The array to process.
* @param {number} [size=0] The length of each chunk.
* @param {number} [size=1] The length of each chunk
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {Array} Returns the new array containing chunks.
* @example
*
@@ -25,9 +27,12 @@ var nativeCeil = Math.ceil,
* _.chunk(['a', 'b', 'c', 'd'], 3);
* // => [['a', 'b', 'c'], ['d']]
*/
function chunk(array, size) {
size = nativeMax(toInteger(size), 0);
function chunk(array, size, guard) {
if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
size = 1;
} else {
size = nativeMax(toInteger(size), 0);
}
var length = array ? array.length : 0;
if (!length || size < 1) {
return [];

View File

@@ -17,6 +17,7 @@ import baseClone from './_baseClone';
* @category Lang
* @param {*} value The value to clone.
* @returns {*} Returns the cloned value.
* @see _.cloneDeep
* @example
*
* var objects = [{ 'a': 1 }, { 'b': 2 }];

View File

@@ -9,6 +9,7 @@ import baseClone from './_baseClone';
* @category Lang
* @param {*} value The value to recursively clone.
* @returns {*} Returns the deep cloned value.
* @see _.clone
* @example
*
* var objects = [{ 'a': 1 }, { 'b': 2 }];

View File

@@ -10,6 +10,7 @@ import baseClone from './_baseClone';
* @param {*} value The value to recursively clone.
* @param {Function} [customizer] The function to customize cloning.
* @returns {*} Returns the deep cloned value.
* @see _.cloneWith
* @example
*
* function customizer(value) {

View File

@@ -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]).
*
@@ -13,6 +13,7 @@ import baseClone from './_baseClone';
* @param {*} value The value to clone.
* @param {Function} [customizer] The function to customize cloning.
* @returns {*} Returns the cloned value.
* @see _.cloneDeepWith
* @example
*
* function customizer(value) {

View File

@@ -7,7 +7,7 @@ import rest from './rest';
var FUNC_ERROR_TEXT = 'Expected a function';
/**
* Creates a function that iterates over `pairs` invoking the corresponding
* Creates a function that iterates over `pairs` and invokes the corresponding
* function of the first predicate to return truthy. The predicate-function
* pairs are invoked with the `this` binding and arguments of the created
* function.

View File

@@ -8,9 +8,9 @@ var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Creates an object composed of keys generated from the results of running
* each element of `collection` through `iteratee`. The corresponding value
* of each key is the number of times the key was returned by `iteratee`.
* The iteratee is invoked with one argument: (value).
* each element of `collection` thru `iteratee`. The corresponding value of
* each key is the number of times the key was returned by `iteratee`. The
* iteratee is invoked with one argument: (value).
*
* @static
* @memberOf _

View File

@@ -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

View File

@@ -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
@@ -62,12 +62,13 @@ var nativeMax = Math.max,
function debounce(func, wait, options) {
var lastArgs,
lastThis,
maxWait,
result,
timerId,
lastCallTime = 0,
lastInvokeTime = 0,
leading = false,
maxWait = false,
maxing = false,
trailing = true;
if (typeof func != 'function') {
@@ -76,7 +77,8 @@ function debounce(func, wait, options) {
wait = toNumber(wait) || 0;
if (isObject(options)) {
leading = !!options.leading;
maxWait = 'maxWait' in options && nativeMax(toNumber(options.maxWait) || 0, wait);
maxing = 'maxWait' in options;
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
trailing = 'trailing' in options ? !!options.trailing : trailing;
}
@@ -104,7 +106,7 @@ function debounce(func, wait, options) {
timeSinceLastInvoke = time - lastInvokeTime,
result = wait - timeSinceLastCall;
return maxWait === false ? result : nativeMin(result, maxWait - timeSinceLastInvoke);
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
}
function shouldInvoke(time) {
@@ -115,7 +117,7 @@ function debounce(func, wait, options) {
// trailing edge, the system time has gone backwards and we're treating
// it as the trailing edge, or we've hit the `maxWait` limit.
return (!lastCallTime || (timeSinceLastCall >= wait) ||
(timeSinceLastCall < 0) || (maxWait !== false && timeSinceLastInvoke >= maxWait));
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
}
function timerExpired() {
@@ -164,10 +166,15 @@ function debounce(func, wait, options) {
if (timerId === undefined) {
return leadingEdge(lastCallTime);
}
// Handle invocations in a tight loop.
clearTimeout(timerId);
if (maxing) {
// Handle invocations in a tight loop.
clearTimeout(timerId);
timerId = setTimeout(timerExpired, wait);
return invokeFunc(lastCallTime);
}
}
if (timerId === undefined) {
timerId = setTimeout(timerExpired, wait);
return invokeFunc(lastCallTime);
}
return result;
}

View File

@@ -18,6 +18,7 @@ import rest from './rest';
* @param {Object} object The destination object.
* @param {...Object} [sources] The source objects.
* @returns {Object} Returns `object`.
* @see _.defaultsDeep
* @example
*
* _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });

View File

@@ -16,6 +16,7 @@ import rest from './rest';
* @param {Object} object The destination object.
* @param {...Object} [sources] The source objects.
* @returns {Object} Returns `object`.
* @see _.defaults
* @example
*
* _.defaultsDeep({ 'user': { 'name': 'barney' } }, { 'user': { 'name': 'fred', 'age': 36 } });

View File

@@ -16,6 +16,7 @@ import rest from './rest';
* @param {Array} array The array to inspect.
* @param {...Array} [values] The values to exclude.
* @returns {Array} Returns the new array of filtered values.
* @see _.without, _.xor
* @example
*
* _.difference([3, 2, 1], [4, 2]);
@@ -23,7 +24,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))
: [];
});

View File

@@ -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))
: [];
});

View File

@@ -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)
: [];
});

View File

@@ -1,4 +1,5 @@
import baseClamp from './_baseClamp';
import baseToString from './_baseToString';
import toInteger from './toInteger';
import toString from './toString';
@@ -27,7 +28,7 @@ import toString from './toString';
*/
function endsWith(string, target, position) {
string = toString(string);
target = typeof target == 'string' ? target : (target + '');
target = baseToString(target);
var length = string.length;
position = position === undefined

View File

@@ -1,6 +1,9 @@
import toString from './toString';
/** Used to match `RegExp` [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns). */
/**
* Used to match `RegExp`
* [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns).
*/
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
reHasRegExpChar = RegExp(reRegExpChar.source);

View File

@@ -16,6 +16,7 @@ import isArray from './isArray';
* @param {Array|Function|Object|string} [predicate=_.identity]
* The function invoked per iteration.
* @returns {Array} Returns the new filtered array.
* @see _.reject
* @example
*
* var users = [

View File

@@ -3,8 +3,8 @@ import map from './map';
/**
* Creates a flattened array of values by running each element in `collection`
* through `iteratee` and flattening the mapped results. The iteratee is
* invoked with three arguments: (value, index|key, collection).
* thru `iteratee` and flattening the mapped results. The iteratee is invoked
* with three arguments: (value, index|key, collection).
*
* @static
* @memberOf _

View File

@@ -11,6 +11,7 @@ import createFlow from './_createFlow';
* @category Util
* @param {...(Function|Function[])} [funcs] Functions to invoke.
* @returns {Function} Returns the new function.
* @see _.flowRight
* @example
*
* function square(n) {

View File

@@ -5,11 +5,12 @@ import createFlow from './_createFlow';
* invokes the given functions from right to left.
*
* @static
* @since 0.1.0
* @since 3.0.0
* @memberOf _
* @category Util
* @param {...(Function|Function[])} [funcs] Functions to invoke.
* @returns {Function} Returns the new function.
* @see _.flow
* @example
*
* function square(n) {

View File

@@ -4,7 +4,7 @@ import baseIteratee from './_baseIteratee';
import isArray from './isArray';
/**
* Iterates over elements of `collection` invoking `iteratee` for each element.
* Iterates over elements of `collection` and invokes `iteratee` for each element.
* The iteratee is invoked with three arguments: (value, index|key, collection).
* Iteratee functions may exit iteration early by explicitly returning `false`.
*
@@ -20,6 +20,7 @@ import isArray from './isArray';
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Array|Object} Returns `collection`.
* @see _.forEachRight
* @example
*
* _([1, 2]).forEach(function(value) {

View File

@@ -15,6 +15,7 @@ import isArray from './isArray';
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Array|Object} Returns `collection`.
* @see _.forEach
* @example
*
* _.forEachRight([1, 2], function(value) {

View File

@@ -4,9 +4,9 @@ import keysIn from './keysIn';
/**
* Iterates over own and inherited enumerable string keyed properties of an
* object invoking `iteratee` for each property. The iteratee is invoked with
* three arguments: (value, key, object). Iteratee functions may exit iteration
* early by explicitly returning `false`.
* object and invokes `iteratee` for each property. The iteratee is invoked
* with three arguments: (value, key, object). Iteratee functions may exit
* iteration early by explicitly returning `false`.
*
* @static
* @memberOf _
@@ -15,6 +15,7 @@ import keysIn from './keysIn';
* @param {Object} object The object to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Object} Returns `object`.
* @see _.forInRight
* @example
*
* function Foo() {

View File

@@ -13,6 +13,7 @@ import keysIn from './keysIn';
* @param {Object} object The object to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Object} Returns `object`.
* @see _.forIn
* @example
*
* function Foo() {

View File

@@ -2,10 +2,10 @@ import baseForOwn from './_baseForOwn';
import baseIteratee from './_baseIteratee';
/**
* Iterates over own enumerable string keyed properties of an object invoking
* `iteratee` for each property. The iteratee is invoked with three arguments:
* (value, key, object). Iteratee functions may exit iteration early by
* explicitly returning `false`.
* Iterates over own enumerable string keyed properties of an object and
* invokes `iteratee` for each property. The iteratee is invoked with three
* arguments: (value, key, object). Iteratee functions may exit iteration
* early by explicitly returning `false`.
*
* @static
* @memberOf _
@@ -14,6 +14,7 @@ import baseIteratee from './_baseIteratee';
* @param {Object} object The object to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Object} Returns `object`.
* @see _.forOwnRight
* @example
*
* function Foo() {

View File

@@ -12,6 +12,7 @@ import baseIteratee from './_baseIteratee';
* @param {Object} object The object to iterate over.
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Object} Returns `object`.
* @see _.forOwn
* @example
*
* function Foo() {

View File

@@ -11,6 +11,7 @@ import keys from './keys';
* @category Object
* @param {Object} object The object to inspect.
* @returns {Array} Returns the new array of property names.
* @see _.functionsIn
* @example
*
* function Foo() {

View File

@@ -11,6 +11,7 @@ import keysIn from './keysIn';
* @category Object
* @param {Object} object The object to inspect.
* @returns {Array} Returns the new array of property names.
* @see _.functions
* @example
*
* function Foo() {

2
get.js
View File

@@ -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 _

View File

@@ -8,9 +8,10 @@ var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Creates an object composed of keys generated from the results of running
* each element of `collection` through `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 _

8
gt.js
View File

@@ -1,3 +1,6 @@
import baseGt from './_baseGt';
import createRelationalOperation from './_createRelationalOperation';
/**
* Checks if `value` is greater than `other`.
*
@@ -9,6 +12,7 @@
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if `value` is greater than `other`,
* else `false`.
* @see _.lt
* @example
*
* _.gt(3, 1);
@@ -20,8 +24,6 @@
* _.gt(1, 3);
* // => false
*/
function gt(value, other) {
return value > other;
}
var gt = createRelationalOperation(baseGt);
export default gt;

Some files were not shown because too many files have changed in this diff Show More