mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 09:27:49 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35805ec250 | ||
|
|
692aabae13 | ||
|
|
764eccfdc0 |
@@ -1,4 +1,4 @@
|
|||||||
# lodash-es v4.10.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.
|
||||||
|
|
||||||
@@ -7,4 +7,4 @@ Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli):
|
|||||||
$ lodash modularize exports=es -o ./
|
$ lodash modularize exports=es -o ./
|
||||||
```
|
```
|
||||||
|
|
||||||
See the [package source](https://github.com/lodash/lodash/tree/4.10.0-es) for more details.
|
See the [package source](https://github.com/lodash/lodash/tree/4.11.2-es) for more details.
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ function baseDifference(array, values, iteratee, comparator) {
|
|||||||
var value = array[index],
|
var value = array[index],
|
||||||
computed = iteratee ? iteratee(value) : value;
|
computed = iteratee ? iteratee(value) : value;
|
||||||
|
|
||||||
|
value = (comparator || value !== 0) ? value : 0;
|
||||||
if (isCommon && computed === computed) {
|
if (isCommon && computed === computed) {
|
||||||
var valuesIndex = valuesLength;
|
var valuesIndex = valuesLength;
|
||||||
while (valuesIndex--) {
|
while (valuesIndex--) {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import isSymbol from './isSymbol';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of methods like `_.max` and `_.min` which accepts a
|
* The base implementation of methods like `_.max` and `_.min` which accepts a
|
||||||
* `comparator` to determine the extremum value.
|
* `comparator` to determine the extremum value.
|
||||||
@@ -17,7 +19,7 @@ function baseExtremum(array, iteratee, comparator) {
|
|||||||
current = iteratee(value);
|
current = iteratee(value);
|
||||||
|
|
||||||
if (current != null && (computed === undefined
|
if (current != null && (computed === undefined
|
||||||
? current === current
|
? (current === current && !isSymbol(current))
|
||||||
: comparator(current, computed)
|
: comparator(current, computed)
|
||||||
)) {
|
)) {
|
||||||
var computed = current,
|
var computed = current,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import castPath from './_castPath';
|
import castPath from './_castPath';
|
||||||
import isKey from './_isKey';
|
import isKey from './_isKey';
|
||||||
|
import toKey from './_toKey';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.get` without support for default values.
|
* The base implementation of `_.get` without support for default values.
|
||||||
@@ -16,7 +17,7 @@ function baseGet(object, path) {
|
|||||||
length = path.length;
|
length = path.length;
|
||||||
|
|
||||||
while (object != null && index < length) {
|
while (object != null && index < length) {
|
||||||
object = object[path[index++]];
|
object = object[toKey(path[index++])];
|
||||||
}
|
}
|
||||||
return (index && index == length) ? object : undefined;
|
return (index && index == length) ? object : undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
14
_baseGt.js
Normal file
14
_baseGt.js
Normal 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;
|
||||||
@@ -47,6 +47,7 @@ function baseIntersection(arrays, iteratee, comparator) {
|
|||||||
var value = array[index],
|
var value = array[index],
|
||||||
computed = iteratee ? iteratee(value) : value;
|
computed = iteratee ? iteratee(value) : value;
|
||||||
|
|
||||||
|
value = (comparator || value !== 0) ? value : 0;
|
||||||
if (!(seen
|
if (!(seen
|
||||||
? cacheHas(seen, computed)
|
? cacheHas(seen, computed)
|
||||||
: includes(result, computed, comparator)
|
: includes(result, computed, comparator)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import castPath from './_castPath';
|
|||||||
import isKey from './_isKey';
|
import isKey from './_isKey';
|
||||||
import last from './last';
|
import last from './last';
|
||||||
import parent from './_parent';
|
import parent from './_parent';
|
||||||
|
import toKey from './_toKey';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.invoke` without support for individual
|
* The base implementation of `_.invoke` without support for individual
|
||||||
@@ -20,7 +21,7 @@ function baseInvoke(object, path, args) {
|
|||||||
object = parent(object, path);
|
object = parent(object, path);
|
||||||
path = last(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);
|
return func == null ? undefined : apply(func, object, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
14
_baseLt.js
Normal file
14
_baseLt.js
Normal 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;
|
||||||
@@ -4,6 +4,7 @@ import hasIn from './hasIn';
|
|||||||
import isKey from './_isKey';
|
import isKey from './_isKey';
|
||||||
import isStrictComparable from './_isStrictComparable';
|
import isStrictComparable from './_isStrictComparable';
|
||||||
import matchesStrictComparable from './_matchesStrictComparable';
|
import matchesStrictComparable from './_matchesStrictComparable';
|
||||||
|
import toKey from './_toKey';
|
||||||
|
|
||||||
/** Used to compose bitmasks for comparison styles. */
|
/** Used to compose bitmasks for comparison styles. */
|
||||||
var UNORDERED_COMPARE_FLAG = 1,
|
var UNORDERED_COMPARE_FLAG = 1,
|
||||||
@@ -19,7 +20,7 @@ var UNORDERED_COMPARE_FLAG = 1,
|
|||||||
*/
|
*/
|
||||||
function baseMatchesProperty(path, srcValue) {
|
function baseMatchesProperty(path, srcValue) {
|
||||||
if (isKey(path) && isStrictComparable(srcValue)) {
|
if (isKey(path) && isStrictComparable(srcValue)) {
|
||||||
return matchesStrictComparable(path, srcValue);
|
return matchesStrictComparable(toKey(path), srcValue);
|
||||||
}
|
}
|
||||||
return function(object) {
|
return function(object) {
|
||||||
var objValue = get(object, path);
|
var objValue = get(object, path);
|
||||||
|
|||||||
20
_baseNth.js
Normal file
20
_baseNth.js
Normal 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;
|
||||||
@@ -2,6 +2,7 @@ import arrayMap from './_arrayMap';
|
|||||||
import baseIteratee from './_baseIteratee';
|
import baseIteratee from './_baseIteratee';
|
||||||
import baseMap from './_baseMap';
|
import baseMap from './_baseMap';
|
||||||
import baseSortBy from './_baseSortBy';
|
import baseSortBy from './_baseSortBy';
|
||||||
|
import baseUnary from './_baseUnary';
|
||||||
import compareMultiple from './_compareMultiple';
|
import compareMultiple from './_compareMultiple';
|
||||||
import identity from './identity';
|
import identity from './identity';
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ import identity from './identity';
|
|||||||
*/
|
*/
|
||||||
function baseOrderBy(collection, iteratees, orders) {
|
function baseOrderBy(collection, iteratees, orders) {
|
||||||
var index = -1;
|
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 result = baseMap(collection, function(value, key, collection) {
|
||||||
var criteria = arrayMap(iteratees, function(iteratee) {
|
var criteria = arrayMap(iteratees, function(iteratee) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import isIndex from './_isIndex';
|
|||||||
import isKey from './_isKey';
|
import isKey from './_isKey';
|
||||||
import last from './last';
|
import last from './last';
|
||||||
import parent from './_parent';
|
import parent from './_parent';
|
||||||
|
import toKey from './_toKey';
|
||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var arrayProto = Array.prototype;
|
var arrayProto = Array.prototype;
|
||||||
@@ -25,7 +26,7 @@ function basePullAt(array, indexes) {
|
|||||||
|
|
||||||
while (length--) {
|
while (length--) {
|
||||||
var index = indexes[length];
|
var index = indexes[length];
|
||||||
if (lastIndex == length || index != previous) {
|
if (length == lastIndex || index !== previous) {
|
||||||
var previous = index;
|
var previous = index;
|
||||||
if (isIndex(index)) {
|
if (isIndex(index)) {
|
||||||
splice.call(array, index, 1);
|
splice.call(array, index, 1);
|
||||||
@@ -35,11 +36,11 @@ function basePullAt(array, indexes) {
|
|||||||
object = parent(array, path);
|
object = parent(array, path);
|
||||||
|
|
||||||
if (object != null) {
|
if (object != null) {
|
||||||
delete object[last(path)];
|
delete object[toKey(last(path))];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
delete array[index];
|
delete array[toKey(index)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import castPath from './_castPath';
|
|||||||
import isIndex from './_isIndex';
|
import isIndex from './_isIndex';
|
||||||
import isKey from './_isKey';
|
import isKey from './_isKey';
|
||||||
import isObject from './isObject';
|
import isObject from './isObject';
|
||||||
|
import toKey from './_toKey';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.set`.
|
* The base implementation of `_.set`.
|
||||||
@@ -23,7 +24,7 @@ function baseSet(object, path, value, customizer) {
|
|||||||
nested = object;
|
nested = object;
|
||||||
|
|
||||||
while (nested != null && ++index < length) {
|
while (nested != null && ++index < length) {
|
||||||
var key = path[index];
|
var key = toKey(path[index]);
|
||||||
if (isObject(nested)) {
|
if (isObject(nested)) {
|
||||||
var newValue = value;
|
var newValue = value;
|
||||||
if (index != lastIndex) {
|
if (index != lastIndex) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import baseSortedIndexBy from './_baseSortedIndexBy';
|
import baseSortedIndexBy from './_baseSortedIndexBy';
|
||||||
import identity from './identity';
|
import identity from './identity';
|
||||||
|
import isSymbol from './isSymbol';
|
||||||
|
|
||||||
/** Used as references for the maximum length and index of an array. */
|
/** Used as references for the maximum length and index of an array. */
|
||||||
var MAX_ARRAY_LENGTH = 4294967295,
|
var MAX_ARRAY_LENGTH = 4294967295,
|
||||||
@@ -26,7 +27,8 @@ function baseSortedIndex(array, value, retHighest) {
|
|||||||
var mid = (low + high) >>> 1,
|
var mid = (low + high) >>> 1,
|
||||||
computed = array[mid];
|
computed = array[mid];
|
||||||
|
|
||||||
if ((retHighest ? (computed <= value) : (computed < value)) && computed !== null) {
|
if (computed !== null && !isSymbol(computed) &&
|
||||||
|
(retHighest ? (computed <= value) : (computed < value))) {
|
||||||
low = mid + 1;
|
low = mid + 1;
|
||||||
} else {
|
} else {
|
||||||
high = mid;
|
high = mid;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import isSymbol from './isSymbol';
|
||||||
|
|
||||||
/** Used as references for the maximum length and index of an array. */
|
/** Used as references for the maximum length and index of an array. */
|
||||||
var MAX_ARRAY_LENGTH = 4294967295,
|
var MAX_ARRAY_LENGTH = 4294967295,
|
||||||
MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1;
|
MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1;
|
||||||
@@ -26,21 +28,26 @@ function baseSortedIndexBy(array, value, iteratee, retHighest) {
|
|||||||
high = array ? array.length : 0,
|
high = array ? array.length : 0,
|
||||||
valIsNaN = value !== value,
|
valIsNaN = value !== value,
|
||||||
valIsNull = value === null,
|
valIsNull = value === null,
|
||||||
valIsUndef = value === undefined;
|
valIsSymbol = isSymbol(value),
|
||||||
|
valIsUndefined = value === undefined;
|
||||||
|
|
||||||
while (low < high) {
|
while (low < high) {
|
||||||
var mid = nativeFloor((low + high) / 2),
|
var mid = nativeFloor((low + high) / 2),
|
||||||
computed = iteratee(array[mid]),
|
computed = iteratee(array[mid]),
|
||||||
isDef = computed !== undefined,
|
othIsDefined = computed !== undefined,
|
||||||
isReflexive = computed === computed;
|
othIsNull = computed === null,
|
||||||
|
othIsReflexive = computed === computed,
|
||||||
|
othIsSymbol = isSymbol(computed);
|
||||||
|
|
||||||
if (valIsNaN) {
|
if (valIsNaN) {
|
||||||
var setLow = isReflexive || retHighest;
|
var setLow = retHighest || othIsReflexive;
|
||||||
|
} else if (valIsUndefined) {
|
||||||
|
setLow = othIsReflexive && (retHighest || othIsDefined);
|
||||||
} else if (valIsNull) {
|
} else if (valIsNull) {
|
||||||
setLow = isReflexive && isDef && (retHighest || computed != null);
|
setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
|
||||||
} else if (valIsUndef) {
|
} else if (valIsSymbol) {
|
||||||
setLow = isReflexive && (retHighest || isDef);
|
setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
|
||||||
} else if (computed == null) {
|
} else if (othIsNull || othIsSymbol) {
|
||||||
setLow = false;
|
setLow = false;
|
||||||
} else {
|
} else {
|
||||||
setLow = retHighest ? (computed <= value) : (computed < value);
|
setLow = retHighest ? (computed <= value) : (computed < value);
|
||||||
|
|||||||
@@ -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
|
* @private
|
||||||
* @param {Array} array The array to inspect.
|
* @param {Array} array The array to inspect.
|
||||||
|
* @param {Function} [iteratee] The iteratee invoked per element.
|
||||||
* @returns {Array} Returns the new duplicate free array.
|
* @returns {Array} Returns the new duplicate free array.
|
||||||
*/
|
*/
|
||||||
function baseSortedUniq(array) {
|
function baseSortedUniq(array, iteratee) {
|
||||||
return baseSortedUniqBy(array);
|
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;
|
export default baseSortedUniq;
|
||||||
|
|||||||
@@ -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
24
_baseToNumber.js
Normal 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
31
_baseToString.js
Normal 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;
|
||||||
@@ -46,6 +46,7 @@ function baseUniq(array, iteratee, comparator) {
|
|||||||
var value = array[index],
|
var value = array[index],
|
||||||
computed = iteratee ? iteratee(value) : value;
|
computed = iteratee ? iteratee(value) : value;
|
||||||
|
|
||||||
|
value = (comparator || value !== 0) ? value : 0;
|
||||||
if (isCommon && computed === computed) {
|
if (isCommon && computed === computed) {
|
||||||
var seenIndex = seen.length;
|
var seenIndex = seen.length;
|
||||||
while (seenIndex--) {
|
while (seenIndex--) {
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
|
import baseHas from './_baseHas';
|
||||||
import castPath from './_castPath';
|
import castPath from './_castPath';
|
||||||
import has from './has';
|
|
||||||
import isKey from './_isKey';
|
import isKey from './_isKey';
|
||||||
import last from './last';
|
import last from './last';
|
||||||
import parent from './_parent';
|
import parent from './_parent';
|
||||||
|
import toKey from './_toKey';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.unset`.
|
* The base implementation of `_.unset`.
|
||||||
@@ -15,8 +16,9 @@ import parent from './_parent';
|
|||||||
function baseUnset(object, path) {
|
function baseUnset(object, path) {
|
||||||
path = isKey(path, object) ? [path] : castPath(path);
|
path = isKey(path, object) ? [path] : castPath(path);
|
||||||
object = parent(object, 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;
|
export default baseUnset;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import isSymbol from './isSymbol';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares values to sort them in ascending order.
|
* Compares values to sort them in ascending order.
|
||||||
*
|
*
|
||||||
@@ -8,22 +10,28 @@
|
|||||||
*/
|
*/
|
||||||
function compareAscending(value, other) {
|
function compareAscending(value, other) {
|
||||||
if (value !== other) {
|
if (value !== other) {
|
||||||
var valIsNull = value === null,
|
var valIsDefined = value !== undefined,
|
||||||
valIsUndef = value === undefined,
|
valIsNull = value === null,
|
||||||
valIsReflexive = value === value;
|
valIsReflexive = value === value,
|
||||||
|
valIsSymbol = isSymbol(value);
|
||||||
|
|
||||||
var othIsNull = other === null,
|
var othIsDefined = other !== undefined,
|
||||||
othIsUndef = other === undefined,
|
othIsNull = other === null,
|
||||||
othIsReflexive = other === other;
|
othIsReflexive = other === other,
|
||||||
|
othIsSymbol = isSymbol(other);
|
||||||
|
|
||||||
if ((value > other && !othIsNull) || !valIsReflexive ||
|
if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
|
||||||
(valIsNull && !othIsUndef && othIsReflexive) ||
|
(valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
|
||||||
(valIsUndef && othIsReflexive)) {
|
(valIsNull && othIsDefined && othIsReflexive) ||
|
||||||
|
(!valIsDefined && othIsReflexive) ||
|
||||||
|
!valIsReflexive) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if ((value < other && !valIsNull) || !othIsReflexive ||
|
if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
|
||||||
(othIsNull && !valIsUndef && valIsReflexive) ||
|
(othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
|
||||||
(othIsUndef && valIsReflexive)) {
|
(othIsNull && valIsDefined && valIsReflexive) ||
|
||||||
|
(!othIsDefined && valIsReflexive) ||
|
||||||
|
!othIsReflexive) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import copyObjectWith from './_copyObjectWith';
|
import assignValue from './_assignValue';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies properties of `source` to `object`.
|
* Copies properties of `source` to `object`.
|
||||||
@@ -7,10 +7,25 @@ import copyObjectWith from './_copyObjectWith';
|
|||||||
* @param {Object} source The object to copy properties from.
|
* @param {Object} source The object to copy properties from.
|
||||||
* @param {Array} props The property identifiers to copy.
|
* @param {Array} props The property identifiers to copy.
|
||||||
* @param {Object} [object={}] The object to copy properties to.
|
* @param {Object} [object={}] The object to copy properties to.
|
||||||
|
* @param {Function} [customizer] The function to customize copied values.
|
||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
*/
|
*/
|
||||||
function copyObject(source, props, object) {
|
function copyObject(source, props, object, customizer) {
|
||||||
return copyObjectWith(source, props, object);
|
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;
|
export default copyObject;
|
||||||
|
|||||||
@@ -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;
|
|
||||||
@@ -2,6 +2,12 @@ import arrayReduce from './_arrayReduce';
|
|||||||
import deburr from './deburr';
|
import deburr from './deburr';
|
||||||
import words from './words';
|
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`.
|
* Creates a function like `_.camelCase`.
|
||||||
*
|
*
|
||||||
@@ -11,7 +17,7 @@ import words from './words';
|
|||||||
*/
|
*/
|
||||||
function createCompounder(callback) {
|
function createCompounder(callback) {
|
||||||
return function(string) {
|
return function(string) {
|
||||||
return arrayReduce(words(deburr(string)), callback, '');
|
return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import baseToNumber from './_baseToNumber';
|
||||||
|
import baseToString from './_baseToString';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function that performs a mathematical operation on two values.
|
* Creates a function that performs a mathematical operation on two values.
|
||||||
*
|
*
|
||||||
@@ -15,7 +18,17 @@ function createMathOperation(operator) {
|
|||||||
result = value;
|
result = value;
|
||||||
}
|
}
|
||||||
if (other !== undefined) {
|
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;
|
return result;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import apply from './_apply';
|
|||||||
import arrayMap from './_arrayMap';
|
import arrayMap from './_arrayMap';
|
||||||
import baseFlatten from './_baseFlatten';
|
import baseFlatten from './_baseFlatten';
|
||||||
import baseIteratee from './_baseIteratee';
|
import baseIteratee from './_baseIteratee';
|
||||||
|
import baseUnary from './_baseUnary';
|
||||||
|
import isArray from './isArray';
|
||||||
import isFlattenableIteratee from './_isFlattenableIteratee';
|
import isFlattenableIteratee from './_isFlattenableIteratee';
|
||||||
import rest from './rest';
|
import rest from './rest';
|
||||||
|
|
||||||
@@ -14,7 +16,10 @@ import rest from './rest';
|
|||||||
*/
|
*/
|
||||||
function createOver(arrayFunc) {
|
function createOver(arrayFunc) {
|
||||||
return rest(function(iteratees) {
|
return rest(function(iteratees) {
|
||||||
iteratees = arrayMap(baseFlatten(iteratees, 1, isFlattenableIteratee), baseIteratee);
|
iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
|
||||||
|
? arrayMap(iteratees[0], baseUnary(baseIteratee))
|
||||||
|
: arrayMap(baseFlatten(iteratees, 1, isFlattenableIteratee), baseUnary(baseIteratee));
|
||||||
|
|
||||||
return rest(function(args) {
|
return rest(function(args) {
|
||||||
var thisArg = this;
|
var thisArg = this;
|
||||||
return arrayFunc(iteratees, function(iteratee) {
|
return arrayFunc(iteratees, function(iteratee) {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import baseRepeat from './_baseRepeat';
|
import baseRepeat from './_baseRepeat';
|
||||||
|
import baseToString from './_baseToString';
|
||||||
import castSlice from './_castSlice';
|
import castSlice from './_castSlice';
|
||||||
import reHasComplexSymbol from './_reHasComplexSymbol';
|
import reHasComplexSymbol from './_reHasComplexSymbol';
|
||||||
import stringSize from './_stringSize';
|
import stringSize from './_stringSize';
|
||||||
@@ -17,7 +18,7 @@ var nativeCeil = Math.ceil;
|
|||||||
* @returns {string} Returns the padding for `string`.
|
* @returns {string} Returns the padding for `string`.
|
||||||
*/
|
*/
|
||||||
function createPadding(length, chars) {
|
function createPadding(length, chars) {
|
||||||
chars = chars === undefined ? ' ' : (chars + '');
|
chars = chars === undefined ? ' ' : baseToString(chars);
|
||||||
|
|
||||||
var charsLength = chars.length;
|
var charsLength = chars.length;
|
||||||
if (charsLength < 2) {
|
if (charsLength < 2) {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import copyArray from './_copyArray';
|
|
||||||
import isLaziable from './_isLaziable';
|
import isLaziable from './_isLaziable';
|
||||||
import setData from './_setData';
|
import setData from './_setData';
|
||||||
|
|
||||||
@@ -30,7 +29,6 @@ var BIND_FLAG = 1,
|
|||||||
*/
|
*/
|
||||||
function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
|
function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
|
||||||
var isCurry = bitmask & CURRY_FLAG,
|
var isCurry = bitmask & CURRY_FLAG,
|
||||||
newArgPos = argPos ? copyArray(argPos) : undefined,
|
|
||||||
newHolders = isCurry ? holders : undefined,
|
newHolders = isCurry ? holders : undefined,
|
||||||
newHoldersRight = isCurry ? undefined : holders,
|
newHoldersRight = isCurry ? undefined : holders,
|
||||||
newPartials = isCurry ? partials : undefined,
|
newPartials = isCurry ? partials : undefined,
|
||||||
@@ -44,7 +42,7 @@ function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, par
|
|||||||
}
|
}
|
||||||
var newData = [
|
var newData = [
|
||||||
func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
|
func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
|
||||||
newHoldersRight, newArgPos, ary, arity
|
newHoldersRight, argPos, ary, arity
|
||||||
];
|
];
|
||||||
|
|
||||||
var result = wrapFunc.apply(undefined, newData);
|
var result = wrapFunc.apply(undefined, newData);
|
||||||
|
|||||||
20
_createRelationalOperation.js
Normal file
20
_createRelationalOperation.js
Normal 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;
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
import Set from './_Set';
|
import Set from './_Set';
|
||||||
import noop from './noop';
|
import noop from './noop';
|
||||||
|
import setToArray from './_setToArray';
|
||||||
|
|
||||||
|
/** Used as references for various `Number` constants. */
|
||||||
|
var INFINITY = 1 / 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a set of `values`.
|
* Creates a set of `values`.
|
||||||
@@ -8,7 +12,7 @@ import noop from './noop';
|
|||||||
* @param {Array} values The values to add to the set.
|
* @param {Array} values The values to add to the set.
|
||||||
* @returns {Object} Returns the new 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);
|
return new Set(values);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import isIndex from './_isIndex';
|
|||||||
import isKey from './_isKey';
|
import isKey from './_isKey';
|
||||||
import isLength from './isLength';
|
import isLength from './isLength';
|
||||||
import isString from './isString';
|
import isString from './isString';
|
||||||
|
import toKey from './_toKey';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if `path` exists on `object`.
|
* Checks if `path` exists on `object`.
|
||||||
@@ -23,7 +24,7 @@ function hasPath(object, path, hasFunc) {
|
|||||||
length = path.length;
|
length = path.length;
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var key = path[index];
|
var key = toKey(path[index]);
|
||||||
if (!(result = object != null && hasFunc(object, key))) {
|
if (!(result = object != null && hasFunc(object, key))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,10 @@ var reIsUint = /^(?:0|[1-9]\d*)$/;
|
|||||||
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
||||||
*/
|
*/
|
||||||
function isIndex(value, length) {
|
function isIndex(value, length) {
|
||||||
value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
|
|
||||||
length = length == null ? MAX_SAFE_INTEGER : length;
|
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;
|
export default isIndex;
|
||||||
|
|||||||
11
_isKey.js
11
_isKey.js
@@ -14,13 +14,16 @@ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
|
|||||||
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
|
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
|
||||||
*/
|
*/
|
||||||
function isKey(value, object) {
|
function isKey(value, object) {
|
||||||
|
if (isArray(value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
var type = typeof value;
|
var type = typeof value;
|
||||||
if (type == 'number' || type == 'symbol') {
|
if (type == 'number' || type == 'symbol' || type == 'boolean' ||
|
||||||
|
value == null || isSymbol(value)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return !isArray(value) &&
|
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
|
||||||
(isSymbol(value) || reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
|
(object != null && value in Object(object));
|
||||||
(object != null && value in Object(object)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default isKey;
|
export default isKey;
|
||||||
|
|||||||
@@ -7,8 +7,9 @@
|
|||||||
*/
|
*/
|
||||||
function isKeyable(value) {
|
function isKeyable(value) {
|
||||||
var type = typeof value;
|
var type = typeof value;
|
||||||
return type == 'number' || type == 'boolean' ||
|
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
|
||||||
(type == 'string' && value != '__proto__') || value == null;
|
? (value !== '__proto__')
|
||||||
|
: (value === null);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default isKeyable;
|
export default isKeyable;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import composeArgs from './_composeArgs';
|
import composeArgs from './_composeArgs';
|
||||||
import composeArgsRight from './_composeArgsRight';
|
import composeArgsRight from './_composeArgsRight';
|
||||||
import copyArray from './_copyArray';
|
|
||||||
import replaceHolders from './_replaceHolders';
|
import replaceHolders from './_replaceHolders';
|
||||||
|
|
||||||
/** Used as the internal argument placeholder. */
|
/** Used as the internal argument placeholder. */
|
||||||
@@ -58,20 +57,20 @@ function mergeData(data, source) {
|
|||||||
var value = source[3];
|
var value = source[3];
|
||||||
if (value) {
|
if (value) {
|
||||||
var partials = data[3];
|
var partials = data[3];
|
||||||
data[3] = partials ? composeArgs(partials, value, source[4]) : copyArray(value);
|
data[3] = partials ? composeArgs(partials, value, source[4]) : value;
|
||||||
data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : copyArray(source[4]);
|
data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
|
||||||
}
|
}
|
||||||
// Compose partial right arguments.
|
// Compose partial right arguments.
|
||||||
value = source[5];
|
value = source[5];
|
||||||
if (value) {
|
if (value) {
|
||||||
partials = data[5];
|
partials = data[5];
|
||||||
data[5] = partials ? composeArgsRight(partials, value, source[6]) : copyArray(value);
|
data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
|
||||||
data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : copyArray(source[6]);
|
data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
|
||||||
}
|
}
|
||||||
// Use source `argPos` if available.
|
// Use source `argPos` if available.
|
||||||
value = source[7];
|
value = source[7];
|
||||||
if (value) {
|
if (value) {
|
||||||
data[7] = copyArray(value);
|
data[7] = value;
|
||||||
}
|
}
|
||||||
// Use source `ary` if it's smaller.
|
// Use source `ary` if it's smaller.
|
||||||
if (srcBitmask & ARY_FLAG) {
|
if (srcBitmask & ARY_FLAG) {
|
||||||
|
|||||||
11
_toKey.js
11
_toKey.js
@@ -1,5 +1,8 @@
|
|||||||
import isSymbol from './isSymbol';
|
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.
|
* Converts `value` to a string key if it's not a string or symbol.
|
||||||
*
|
*
|
||||||
@@ -7,8 +10,12 @@ import isSymbol from './isSymbol';
|
|||||||
* @param {*} value The value to inspect.
|
* @param {*} value The value to inspect.
|
||||||
* @returns {string|symbol} Returns the key.
|
* @returns {string|symbol} Returns the key.
|
||||||
*/
|
*/
|
||||||
function toKey(key) {
|
function toKey(value) {
|
||||||
return (typeof key == 'string' || isSymbol(key)) ? key : (key + '');
|
if (typeof value == 'string' || isSymbol(value)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
var result = (value + '');
|
||||||
|
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default toKey;
|
export default toKey;
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import intersectionWith from './intersectionWith';
|
|||||||
import join from './join';
|
import join from './join';
|
||||||
import last from './last';
|
import last from './last';
|
||||||
import lastIndexOf from './lastIndexOf';
|
import lastIndexOf from './lastIndexOf';
|
||||||
|
import nth from './nth';
|
||||||
import pull from './pull';
|
import pull from './pull';
|
||||||
import pullAll from './pullAll';
|
import pullAll from './pullAll';
|
||||||
import pullAllBy from './pullAllBy';
|
import pullAllBy from './pullAllBy';
|
||||||
@@ -68,12 +69,12 @@ export default {
|
|||||||
fill, findIndex, findLastIndex, flatten, flattenDeep,
|
fill, findIndex, findLastIndex, flatten, flattenDeep,
|
||||||
flattenDepth, fromPairs, head, indexOf, initial,
|
flattenDepth, fromPairs, head, indexOf, initial,
|
||||||
intersection, intersectionBy, intersectionWith, join, last,
|
intersection, intersectionBy, intersectionWith, join, last,
|
||||||
lastIndexOf, pull, pullAll, pullAllBy, pullAllWith,
|
lastIndexOf, nth, pull, pullAll, pullAllBy,
|
||||||
pullAt, remove, reverse, slice, sortedIndex,
|
pullAllWith, pullAt, remove, reverse, slice,
|
||||||
sortedIndexBy, sortedIndexOf, sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf,
|
sortedIndex, sortedIndexBy, sortedIndexOf, sortedLastIndex, sortedLastIndexBy,
|
||||||
sortedUniq, sortedUniqBy, tail, take, takeRight,
|
sortedLastIndexOf, sortedUniq, sortedUniqBy, tail, take,
|
||||||
takeRightWhile, takeWhile, union, unionBy, unionWith,
|
takeRight, takeRightWhile, takeWhile, union, unionBy,
|
||||||
uniq, uniqBy, uniqWith, unzip, unzipWith,
|
unionWith, uniq, uniqBy, uniqWith, unzip,
|
||||||
without, xor, xorBy, xorWith, zip,
|
unzipWith, without, xor, xorBy, xorWith,
|
||||||
zipObject, zipObjectDeep, zipWith
|
zip, zipObject, zipObjectDeep, zipWith
|
||||||
};
|
};
|
||||||
|
|||||||
1
array.js
1
array.js
@@ -24,6 +24,7 @@ export { default as intersectionWith } from './intersectionWith';
|
|||||||
export { default as join } from './join';
|
export { default as join } from './join';
|
||||||
export { default as last } from './last';
|
export { default as last } from './last';
|
||||||
export { default as lastIndexOf } from './lastIndexOf';
|
export { default as lastIndexOf } from './lastIndexOf';
|
||||||
|
export { default as nth } from './nth';
|
||||||
export { default as pull } from './pull';
|
export { default as pull } from './pull';
|
||||||
export { default as pullAll } from './pullAll';
|
export { default as pullAll } from './pullAll';
|
||||||
export { default as pullAllBy } from './pullAllBy';
|
export { default as pullAllBy } from './pullAllBy';
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
|
|||||||
* @param {Object} object The destination object.
|
* @param {Object} object The destination object.
|
||||||
* @param {...Object} [sources] The source objects.
|
* @param {...Object} [sources] The source objects.
|
||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
|
* @see _.assignIn
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* function Foo() {
|
* function Foo() {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
|
|||||||
* @param {Object} object The destination object.
|
* @param {Object} object The destination object.
|
||||||
* @param {...Object} [sources] The source objects.
|
* @param {...Object} [sources] The source objects.
|
||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
|
* @see _.assign
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* function Foo() {
|
* function Foo() {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import copyObjectWith from './_copyObjectWith';
|
import copyObject from './_copyObject';
|
||||||
import createAssigner from './_createAssigner';
|
import createAssigner from './_createAssigner';
|
||||||
import keysIn from './keysIn';
|
import keysIn from './keysIn';
|
||||||
|
|
||||||
@@ -19,6 +19,7 @@ import keysIn from './keysIn';
|
|||||||
* @param {...Object} sources The source objects.
|
* @param {...Object} sources The source objects.
|
||||||
* @param {Function} [customizer] The function to customize assigned values.
|
* @param {Function} [customizer] The function to customize assigned values.
|
||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
|
* @see _.assignWith
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* function customizer(objValue, srcValue) {
|
* function customizer(objValue, srcValue) {
|
||||||
@@ -31,7 +32,7 @@ import keysIn from './keysIn';
|
|||||||
* // => { 'a': 1, 'b': 2 }
|
* // => { 'a': 1, 'b': 2 }
|
||||||
*/
|
*/
|
||||||
var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
|
var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
|
||||||
copyObjectWith(source, keysIn(source), object, customizer);
|
copyObject(source, keysIn(source), object, customizer);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default assignInWith;
|
export default assignInWith;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import copyObjectWith from './_copyObjectWith';
|
import copyObject from './_copyObject';
|
||||||
import createAssigner from './_createAssigner';
|
import createAssigner from './_createAssigner';
|
||||||
import keys from './keys';
|
import keys from './keys';
|
||||||
|
|
||||||
@@ -18,6 +18,7 @@ import keys from './keys';
|
|||||||
* @param {...Object} sources The source objects.
|
* @param {...Object} sources The source objects.
|
||||||
* @param {Function} [customizer] The function to customize assigned values.
|
* @param {Function} [customizer] The function to customize assigned values.
|
||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
|
* @see _.assignInWith
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* function customizer(objValue, srcValue) {
|
* function customizer(objValue, srcValue) {
|
||||||
@@ -30,7 +31,7 @@ import keys from './keys';
|
|||||||
* // => { 'a': 1, 'b': 2 }
|
* // => { 'a': 1, 'b': 2 }
|
||||||
*/
|
*/
|
||||||
var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
|
var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
|
||||||
copyObjectWith(source, keys(source), object, customizer);
|
copyObject(source, keys(source), object, customizer);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default assignWith;
|
export default assignWith;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import arrayEach from './_arrayEach';
|
|||||||
import baseFlatten from './_baseFlatten';
|
import baseFlatten from './_baseFlatten';
|
||||||
import bind from './bind';
|
import bind from './bind';
|
||||||
import rest from './rest';
|
import rest from './rest';
|
||||||
|
import toKey from './_toKey';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binds methods of an object to the object itself, overwriting the existing
|
* Binds methods of an object to the object itself, overwriting the existing
|
||||||
@@ -31,6 +32,7 @@ import rest from './rest';
|
|||||||
*/
|
*/
|
||||||
var bindAll = rest(function(object, methodNames) {
|
var bindAll = rest(function(object, methodNames) {
|
||||||
arrayEach(baseFlatten(methodNames, 1), function(key) {
|
arrayEach(baseFlatten(methodNames, 1), function(key) {
|
||||||
|
key = toKey(key);
|
||||||
object[key] = bind(object[key], object);
|
object[key] = bind(object[key], object);
|
||||||
});
|
});
|
||||||
return object;
|
return object;
|
||||||
|
|||||||
1
clone.js
1
clone.js
@@ -17,6 +17,7 @@ import baseClone from './_baseClone';
|
|||||||
* @category Lang
|
* @category Lang
|
||||||
* @param {*} value The value to clone.
|
* @param {*} value The value to clone.
|
||||||
* @returns {*} Returns the cloned value.
|
* @returns {*} Returns the cloned value.
|
||||||
|
* @see _.cloneDeep
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* var objects = [{ 'a': 1 }, { 'b': 2 }];
|
* var objects = [{ 'a': 1 }, { 'b': 2 }];
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import baseClone from './_baseClone';
|
|||||||
* @category Lang
|
* @category Lang
|
||||||
* @param {*} value The value to recursively clone.
|
* @param {*} value The value to recursively clone.
|
||||||
* @returns {*} Returns the deep cloned value.
|
* @returns {*} Returns the deep cloned value.
|
||||||
|
* @see _.clone
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* var objects = [{ 'a': 1 }, { 'b': 2 }];
|
* var objects = [{ 'a': 1 }, { 'b': 2 }];
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import baseClone from './_baseClone';
|
|||||||
* @param {*} value The value to recursively clone.
|
* @param {*} value The value to recursively clone.
|
||||||
* @param {Function} [customizer] The function to customize cloning.
|
* @param {Function} [customizer] The function to customize cloning.
|
||||||
* @returns {*} Returns the deep cloned value.
|
* @returns {*} Returns the deep cloned value.
|
||||||
|
* @see _.cloneWith
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* function customizer(value) {
|
* function customizer(value) {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import baseClone from './_baseClone';
|
|||||||
* @param {*} value The value to clone.
|
* @param {*} value The value to clone.
|
||||||
* @param {Function} [customizer] The function to customize cloning.
|
* @param {Function} [customizer] The function to customize cloning.
|
||||||
* @returns {*} Returns the cloned value.
|
* @returns {*} Returns the cloned value.
|
||||||
|
* @see _.cloneDeepWith
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* function customizer(value) {
|
* function customizer(value) {
|
||||||
|
|||||||
20
debounce.js
20
debounce.js
@@ -62,12 +62,13 @@ var nativeMax = Math.max,
|
|||||||
function debounce(func, wait, options) {
|
function debounce(func, wait, options) {
|
||||||
var lastArgs,
|
var lastArgs,
|
||||||
lastThis,
|
lastThis,
|
||||||
|
maxWait,
|
||||||
result,
|
result,
|
||||||
timerId,
|
timerId,
|
||||||
lastCallTime = 0,
|
lastCallTime = 0,
|
||||||
lastInvokeTime = 0,
|
lastInvokeTime = 0,
|
||||||
leading = false,
|
leading = false,
|
||||||
maxWait = false,
|
maxing = false,
|
||||||
trailing = true;
|
trailing = true;
|
||||||
|
|
||||||
if (typeof func != 'function') {
|
if (typeof func != 'function') {
|
||||||
@@ -76,7 +77,8 @@ function debounce(func, wait, options) {
|
|||||||
wait = toNumber(wait) || 0;
|
wait = toNumber(wait) || 0;
|
||||||
if (isObject(options)) {
|
if (isObject(options)) {
|
||||||
leading = !!options.leading;
|
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;
|
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +106,7 @@ function debounce(func, wait, options) {
|
|||||||
timeSinceLastInvoke = time - lastInvokeTime,
|
timeSinceLastInvoke = time - lastInvokeTime,
|
||||||
result = wait - timeSinceLastCall;
|
result = wait - timeSinceLastCall;
|
||||||
|
|
||||||
return maxWait === false ? result : nativeMin(result, maxWait - timeSinceLastInvoke);
|
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldInvoke(time) {
|
function shouldInvoke(time) {
|
||||||
@@ -115,7 +117,7 @@ function debounce(func, wait, options) {
|
|||||||
// trailing edge, the system time has gone backwards and we're treating
|
// trailing edge, the system time has gone backwards and we're treating
|
||||||
// it as the trailing edge, or we've hit the `maxWait` limit.
|
// it as the trailing edge, or we've hit the `maxWait` limit.
|
||||||
return (!lastCallTime || (timeSinceLastCall >= wait) ||
|
return (!lastCallTime || (timeSinceLastCall >= wait) ||
|
||||||
(timeSinceLastCall < 0) || (maxWait !== false && timeSinceLastInvoke >= maxWait));
|
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
|
||||||
}
|
}
|
||||||
|
|
||||||
function timerExpired() {
|
function timerExpired() {
|
||||||
@@ -164,10 +166,12 @@ function debounce(func, wait, options) {
|
|||||||
if (timerId === undefined) {
|
if (timerId === undefined) {
|
||||||
return leadingEdge(lastCallTime);
|
return leadingEdge(lastCallTime);
|
||||||
}
|
}
|
||||||
// Handle invocations in a tight loop.
|
if (maxing) {
|
||||||
clearTimeout(timerId);
|
// Handle invocations in a tight loop.
|
||||||
timerId = setTimeout(timerExpired, wait);
|
clearTimeout(timerId);
|
||||||
return invokeFunc(lastCallTime);
|
timerId = setTimeout(timerExpired, wait);
|
||||||
|
return invokeFunc(lastCallTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (timerId === undefined) {
|
if (timerId === undefined) {
|
||||||
timerId = setTimeout(timerExpired, wait);
|
timerId = setTimeout(timerExpired, wait);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import rest from './rest';
|
|||||||
* @param {Object} object The destination object.
|
* @param {Object} object The destination object.
|
||||||
* @param {...Object} [sources] The source objects.
|
* @param {...Object} [sources] The source objects.
|
||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
|
* @see _.defaultsDeep
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
|
* _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import rest from './rest';
|
|||||||
* @param {Object} object The destination object.
|
* @param {Object} object The destination object.
|
||||||
* @param {...Object} [sources] The source objects.
|
* @param {...Object} [sources] The source objects.
|
||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
|
* @see _.defaults
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.defaultsDeep({ 'user': { 'name': 'barney' } }, { 'user': { 'name': 'fred', 'age': 36 } });
|
* _.defaultsDeep({ 'user': { 'name': 'barney' } }, { 'user': { 'name': 'fred', 'age': 36 } });
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import rest from './rest';
|
|||||||
* @param {Array} array The array to inspect.
|
* @param {Array} array The array to inspect.
|
||||||
* @param {...Array} [values] The values to exclude.
|
* @param {...Array} [values] The values to exclude.
|
||||||
* @returns {Array} Returns the new array of filtered values.
|
* @returns {Array} Returns the new array of filtered values.
|
||||||
|
* @see _.without, _.xor
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.difference([3, 2, 1], [4, 2]);
|
* _.difference([3, 2, 1], [4, 2]);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import baseClamp from './_baseClamp';
|
import baseClamp from './_baseClamp';
|
||||||
|
import baseToString from './_baseToString';
|
||||||
import toInteger from './toInteger';
|
import toInteger from './toInteger';
|
||||||
import toString from './toString';
|
import toString from './toString';
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ import toString from './toString';
|
|||||||
*/
|
*/
|
||||||
function endsWith(string, target, position) {
|
function endsWith(string, target, position) {
|
||||||
string = toString(string);
|
string = toString(string);
|
||||||
target = typeof target == 'string' ? target : (target + '');
|
target = baseToString(target);
|
||||||
|
|
||||||
var length = string.length;
|
var length = string.length;
|
||||||
position = position === undefined
|
position = position === undefined
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import isArray from './isArray';
|
|||||||
* @param {Array|Function|Object|string} [predicate=_.identity]
|
* @param {Array|Function|Object|string} [predicate=_.identity]
|
||||||
* The function invoked per iteration.
|
* The function invoked per iteration.
|
||||||
* @returns {Array} Returns the new filtered array.
|
* @returns {Array} Returns the new filtered array.
|
||||||
|
* @see _.reject
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* var users = [
|
* var users = [
|
||||||
|
|||||||
1
flow.js
1
flow.js
@@ -11,6 +11,7 @@ import createFlow from './_createFlow';
|
|||||||
* @category Util
|
* @category Util
|
||||||
* @param {...(Function|Function[])} [funcs] Functions to invoke.
|
* @param {...(Function|Function[])} [funcs] Functions to invoke.
|
||||||
* @returns {Function} Returns the new function.
|
* @returns {Function} Returns the new function.
|
||||||
|
* @see _.flowRight
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* function square(n) {
|
* function square(n) {
|
||||||
|
|||||||
@@ -5,11 +5,12 @@ import createFlow from './_createFlow';
|
|||||||
* invokes the given functions from right to left.
|
* invokes the given functions from right to left.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @since 0.1.0
|
* @since 3.0.0
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Util
|
* @category Util
|
||||||
* @param {...(Function|Function[])} [funcs] Functions to invoke.
|
* @param {...(Function|Function[])} [funcs] Functions to invoke.
|
||||||
* @returns {Function} Returns the new function.
|
* @returns {Function} Returns the new function.
|
||||||
|
* @see _.flow
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* function square(n) {
|
* function square(n) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import isArray from './isArray';
|
|||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||||||
* @returns {Array|Object} Returns `collection`.
|
* @returns {Array|Object} Returns `collection`.
|
||||||
|
* @see _.forEachRight
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _([1, 2]).forEach(function(value) {
|
* _([1, 2]).forEach(function(value) {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import isArray from './isArray';
|
|||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||||||
* @returns {Array|Object} Returns `collection`.
|
* @returns {Array|Object} Returns `collection`.
|
||||||
|
* @see _.forEach
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.forEachRight([1, 2], function(value) {
|
* _.forEachRight([1, 2], function(value) {
|
||||||
|
|||||||
1
forIn.js
1
forIn.js
@@ -15,6 +15,7 @@ import keysIn from './keysIn';
|
|||||||
* @param {Object} object The object to iterate over.
|
* @param {Object} object The object to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
|
* @see _.forInRight
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* function Foo() {
|
* function Foo() {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import keysIn from './keysIn';
|
|||||||
* @param {Object} object The object to iterate over.
|
* @param {Object} object The object to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
|
* @see _.forIn
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* function Foo() {
|
* function Foo() {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import baseIteratee from './_baseIteratee';
|
|||||||
* @param {Object} object The object to iterate over.
|
* @param {Object} object The object to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
|
* @see _.forOwnRight
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* function Foo() {
|
* function Foo() {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import baseIteratee from './_baseIteratee';
|
|||||||
* @param {Object} object The object to iterate over.
|
* @param {Object} object The object to iterate over.
|
||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||||||
* @returns {Object} Returns `object`.
|
* @returns {Object} Returns `object`.
|
||||||
|
* @see _.forOwn
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* function Foo() {
|
* function Foo() {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import keys from './keys';
|
|||||||
* @category Object
|
* @category Object
|
||||||
* @param {Object} object The object to inspect.
|
* @param {Object} object The object to inspect.
|
||||||
* @returns {Array} Returns the new array of property names.
|
* @returns {Array} Returns the new array of property names.
|
||||||
|
* @see _.functionsIn
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* function Foo() {
|
* function Foo() {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import keysIn from './keysIn';
|
|||||||
* @category Object
|
* @category Object
|
||||||
* @param {Object} object The object to inspect.
|
* @param {Object} object The object to inspect.
|
||||||
* @returns {Array} Returns the new array of property names.
|
* @returns {Array} Returns the new array of property names.
|
||||||
|
* @see _.functions
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* function Foo() {
|
* function Foo() {
|
||||||
|
|||||||
8
gt.js
8
gt.js
@@ -1,3 +1,6 @@
|
|||||||
|
import baseGt from './_baseGt';
|
||||||
|
import createRelationalOperation from './_createRelationalOperation';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if `value` is greater than `other`.
|
* Checks if `value` is greater than `other`.
|
||||||
*
|
*
|
||||||
@@ -9,6 +12,7 @@
|
|||||||
* @param {*} other The other value to compare.
|
* @param {*} other The other value to compare.
|
||||||
* @returns {boolean} Returns `true` if `value` is greater than `other`,
|
* @returns {boolean} Returns `true` if `value` is greater than `other`,
|
||||||
* else `false`.
|
* else `false`.
|
||||||
|
* @see _.lt
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.gt(3, 1);
|
* _.gt(3, 1);
|
||||||
@@ -20,8 +24,6 @@
|
|||||||
* _.gt(1, 3);
|
* _.gt(1, 3);
|
||||||
* // => false
|
* // => false
|
||||||
*/
|
*/
|
||||||
function gt(value, other) {
|
var gt = createRelationalOperation(baseGt);
|
||||||
return value > other;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default gt;
|
export default gt;
|
||||||
|
|||||||
7
gte.js
7
gte.js
@@ -1,3 +1,5 @@
|
|||||||
|
import createRelationalOperation from './_createRelationalOperation';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if `value` is greater than or equal to `other`.
|
* Checks if `value` is greater than or equal to `other`.
|
||||||
*
|
*
|
||||||
@@ -9,6 +11,7 @@
|
|||||||
* @param {*} other The other value to compare.
|
* @param {*} other The other value to compare.
|
||||||
* @returns {boolean} Returns `true` if `value` is greater than or equal to
|
* @returns {boolean} Returns `true` if `value` is greater than or equal to
|
||||||
* `other`, else `false`.
|
* `other`, else `false`.
|
||||||
|
* @see _.lte
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.gte(3, 1);
|
* _.gte(3, 1);
|
||||||
@@ -20,8 +23,8 @@
|
|||||||
* _.gte(1, 3);
|
* _.gte(1, 3);
|
||||||
* // => false
|
* // => false
|
||||||
*/
|
*/
|
||||||
function gte(value, other) {
|
var gte = createRelationalOperation(function(value, other) {
|
||||||
return value >= other;
|
return value >= other;
|
||||||
}
|
});
|
||||||
|
|
||||||
export default gte;
|
export default gte;
|
||||||
|
|||||||
2
head.js
2
head.js
@@ -17,7 +17,7 @@
|
|||||||
* // => undefined
|
* // => undefined
|
||||||
*/
|
*/
|
||||||
function head(array) {
|
function head(array) {
|
||||||
return array ? array[0] : undefined;
|
return (array && array.length) ? array[0] : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default head;
|
export default head;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import baseInRange from './_baseInRange';
|
|||||||
import toNumber from './toNumber';
|
import toNumber from './toNumber';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if `n` is between `start` and up to but not including, `end`. If
|
* 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
|
* If `start` is greater than `end` the params are swapped to support
|
||||||
* negative ranges.
|
* negative ranges.
|
||||||
@@ -15,6 +15,7 @@ import toNumber from './toNumber';
|
|||||||
* @param {number} [start=0] The start of the range.
|
* @param {number} [start=0] The start of the range.
|
||||||
* @param {number} end The end of the range.
|
* @param {number} end The end of the range.
|
||||||
* @returns {boolean} Returns `true` if `number` is in the range, else `false`.
|
* @returns {boolean} Returns `true` if `number` is in the range, else `false`.
|
||||||
|
* @see _.range, _.rangeRight
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.inRange(3, 2, 4);
|
* _.inRange(3, 2, 4);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @license
|
* @license
|
||||||
* lodash 4.10.0 (Custom Build) <https://lodash.com/>
|
* lodash 4.11.2 (Custom Build) <https://lodash.com/>
|
||||||
* Build: `lodash modularize exports="es" -o ./`
|
* Build: `lodash modularize exports="es" -o ./`
|
||||||
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
||||||
* Released under MIT license <https://lodash.com/license>
|
* Released under MIT license <https://lodash.com/license>
|
||||||
@@ -44,7 +44,7 @@ import toInteger from './toInteger';
|
|||||||
import lodash from './wrapperLodash';
|
import lodash from './wrapperLodash';
|
||||||
|
|
||||||
/** Used as the semantic version number. */
|
/** Used as the semantic version number. */
|
||||||
var VERSION = '4.10.0';
|
var VERSION = '4.11.2';
|
||||||
|
|
||||||
/** Used to compose bitmasks for wrapper metadata. */
|
/** Used to compose bitmasks for wrapper metadata. */
|
||||||
var BIND_KEY_FLAG = 2;
|
var BIND_KEY_FLAG = 2;
|
||||||
@@ -342,6 +342,7 @@ lodash.meanBy = math.meanBy;
|
|||||||
lodash.min = math.min;
|
lodash.min = math.min;
|
||||||
lodash.minBy = math.minBy;
|
lodash.minBy = math.minBy;
|
||||||
lodash.multiply = math.multiply;
|
lodash.multiply = math.multiply;
|
||||||
|
lodash.nth = array.nth;
|
||||||
lodash.noop = util.noop;
|
lodash.noop = util.noop;
|
||||||
lodash.now = date.now;
|
lodash.now = date.now;
|
||||||
lodash.pad = string.pad;
|
lodash.pad = string.pad;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @license
|
* @license
|
||||||
* lodash 4.10.0 (Custom Build) <https://lodash.com/>
|
* lodash 4.11.2 (Custom Build) <https://lodash.com/>
|
||||||
* Build: `lodash modularize exports="es" -o ./`
|
* Build: `lodash modularize exports="es" -o ./`
|
||||||
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
||||||
* Released under MIT license <https://lodash.com/license>
|
* Released under MIT license <https://lodash.com/license>
|
||||||
@@ -184,6 +184,7 @@ export { default as negate } from './negate';
|
|||||||
export { default as next } from './next';
|
export { default as next } from './next';
|
||||||
export { default as noop } from './noop';
|
export { default as noop } from './noop';
|
||||||
export { default as now } from './now';
|
export { default as now } from './now';
|
||||||
|
export { default as nth } from './nth';
|
||||||
export { default as nthArg } from './nthArg';
|
export { default as nthArg } from './nthArg';
|
||||||
export { default as omit } from './omit';
|
export { default as omit } from './omit';
|
||||||
export { default as omitBy } from './omitBy';
|
export { default as omitBy } from './omitBy';
|
||||||
|
|||||||
8
lt.js
8
lt.js
@@ -1,3 +1,6 @@
|
|||||||
|
import baseLt from './_baseLt';
|
||||||
|
import createRelationalOperation from './_createRelationalOperation';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if `value` is less than `other`.
|
* Checks if `value` is less than `other`.
|
||||||
*
|
*
|
||||||
@@ -9,6 +12,7 @@
|
|||||||
* @param {*} other The other value to compare.
|
* @param {*} other The other value to compare.
|
||||||
* @returns {boolean} Returns `true` if `value` is less than `other`,
|
* @returns {boolean} Returns `true` if `value` is less than `other`,
|
||||||
* else `false`.
|
* else `false`.
|
||||||
|
* @see _.gt
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.lt(1, 3);
|
* _.lt(1, 3);
|
||||||
@@ -20,8 +24,6 @@
|
|||||||
* _.lt(3, 1);
|
* _.lt(3, 1);
|
||||||
* // => false
|
* // => false
|
||||||
*/
|
*/
|
||||||
function lt(value, other) {
|
var lt = createRelationalOperation(baseLt);
|
||||||
return value < other;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default lt;
|
export default lt;
|
||||||
|
|||||||
7
lte.js
7
lte.js
@@ -1,3 +1,5 @@
|
|||||||
|
import createRelationalOperation from './_createRelationalOperation';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if `value` is less than or equal to `other`.
|
* Checks if `value` is less than or equal to `other`.
|
||||||
*
|
*
|
||||||
@@ -9,6 +11,7 @@
|
|||||||
* @param {*} other The other value to compare.
|
* @param {*} other The other value to compare.
|
||||||
* @returns {boolean} Returns `true` if `value` is less than or equal to
|
* @returns {boolean} Returns `true` if `value` is less than or equal to
|
||||||
* `other`, else `false`.
|
* `other`, else `false`.
|
||||||
|
* @see _.gte
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.lte(1, 3);
|
* _.lte(1, 3);
|
||||||
@@ -20,8 +23,8 @@
|
|||||||
* _.lte(3, 1);
|
* _.lte(3, 1);
|
||||||
* // => false
|
* // => false
|
||||||
*/
|
*/
|
||||||
function lte(value, other) {
|
var lte = createRelationalOperation(function(value, other) {
|
||||||
return value <= other;
|
return value <= other;
|
||||||
}
|
});
|
||||||
|
|
||||||
export default lte;
|
export default lte;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import baseIteratee from './_baseIteratee';
|
|||||||
* @param {Array|Function|Object|string} [iteratee=_.identity]
|
* @param {Array|Function|Object|string} [iteratee=_.identity]
|
||||||
* The function invoked per iteration.
|
* The function invoked per iteration.
|
||||||
* @returns {Object} Returns the new mapped object.
|
* @returns {Object} Returns the new mapped object.
|
||||||
|
* @see _.mapValues
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
|
* _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import baseIteratee from './_baseIteratee';
|
|||||||
* @param {Array|Function|Object|string} [iteratee=_.identity]
|
* @param {Array|Function|Object|string} [iteratee=_.identity]
|
||||||
* The function invoked per iteration.
|
* The function invoked per iteration.
|
||||||
* @returns {Object} Returns the new mapped object.
|
* @returns {Object} Returns the new mapped object.
|
||||||
|
* @see _.mapKeys
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* var users = {
|
* var users = {
|
||||||
|
|||||||
4
max.js
4
max.js
@@ -1,5 +1,5 @@
|
|||||||
import baseExtremum from './_baseExtremum';
|
import baseExtremum from './_baseExtremum';
|
||||||
import gt from './gt';
|
import baseGt from './_baseGt';
|
||||||
import identity from './identity';
|
import identity from './identity';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,7 +22,7 @@ import identity from './identity';
|
|||||||
*/
|
*/
|
||||||
function max(array) {
|
function max(array) {
|
||||||
return (array && array.length)
|
return (array && array.length)
|
||||||
? baseExtremum(array, identity, gt)
|
? baseExtremum(array, identity, baseGt)
|
||||||
: undefined;
|
: undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
maxBy.js
4
maxBy.js
@@ -1,6 +1,6 @@
|
|||||||
import baseExtremum from './_baseExtremum';
|
import baseExtremum from './_baseExtremum';
|
||||||
|
import baseGt from './_baseGt';
|
||||||
import baseIteratee from './_baseIteratee';
|
import baseIteratee from './_baseIteratee';
|
||||||
import gt from './gt';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.max` except that it accepts `iteratee` which is
|
* This method is like `_.max` except that it accepts `iteratee` which is
|
||||||
@@ -28,7 +28,7 @@ import gt from './gt';
|
|||||||
*/
|
*/
|
||||||
function maxBy(array, iteratee) {
|
function maxBy(array, iteratee) {
|
||||||
return (array && array.length)
|
return (array && array.length)
|
||||||
? baseExtremum(array, baseIteratee(iteratee), gt)
|
? baseExtremum(array, baseIteratee(iteratee), baseGt)
|
||||||
: undefined;
|
: undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
min.js
4
min.js
@@ -1,6 +1,6 @@
|
|||||||
import baseExtremum from './_baseExtremum';
|
import baseExtremum from './_baseExtremum';
|
||||||
|
import baseLt from './_baseLt';
|
||||||
import identity from './identity';
|
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,
|
||||||
@@ -22,7 +22,7 @@ import lt from './lt';
|
|||||||
*/
|
*/
|
||||||
function min(array) {
|
function min(array) {
|
||||||
return (array && array.length)
|
return (array && array.length)
|
||||||
? baseExtremum(array, identity, lt)
|
? baseExtremum(array, identity, baseLt)
|
||||||
: undefined;
|
: undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
minBy.js
4
minBy.js
@@ -1,6 +1,6 @@
|
|||||||
import baseExtremum from './_baseExtremum';
|
import baseExtremum from './_baseExtremum';
|
||||||
import baseIteratee from './_baseIteratee';
|
import baseIteratee from './_baseIteratee';
|
||||||
import lt from './lt';
|
import baseLt from './_baseLt';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.min` except that it accepts `iteratee` which is
|
* This method is like `_.min` except that it accepts `iteratee` which is
|
||||||
@@ -28,7 +28,7 @@ import lt from './lt';
|
|||||||
*/
|
*/
|
||||||
function minBy(array, iteratee) {
|
function minBy(array, iteratee) {
|
||||||
return (array && array.length)
|
return (array && array.length)
|
||||||
? baseExtremum(array, baseIteratee(iteratee), lt)
|
? baseExtremum(array, baseIteratee(iteratee), baseLt)
|
||||||
: undefined;
|
: undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
mixin.js
2
mixin.js
@@ -46,7 +46,7 @@ function mixin(object, source, options) {
|
|||||||
var props = keys(source),
|
var props = keys(source),
|
||||||
methodNames = baseFunctions(source, props);
|
methodNames = baseFunctions(source, props);
|
||||||
|
|
||||||
var chain = (isObject(options) && 'chain' in options) ? options.chain : true,
|
var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
|
||||||
isFunc = isFunction(object);
|
isFunc = isFunction(object);
|
||||||
|
|
||||||
arrayEach(methodNames, function(methodName) {
|
arrayEach(methodNames, function(methodName) {
|
||||||
|
|||||||
29
nth.js
Normal file
29
nth.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import baseNth from './_baseNth';
|
||||||
|
import toInteger from './toInteger';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the nth element of `array`. If `n` is negative, the nth element
|
||||||
|
* from the end is returned.
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @memberOf _
|
||||||
|
* @since 4.11.0
|
||||||
|
* @category Array
|
||||||
|
* @param {Array} array The array to query.
|
||||||
|
* @param {number} [n=0] The index of the element to return.
|
||||||
|
* @returns {*} Returns the nth element of `array`.
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* var array = ['a', 'b', 'c', 'd'];
|
||||||
|
*
|
||||||
|
* _.nth(array, 1);
|
||||||
|
* // => 'b'
|
||||||
|
*
|
||||||
|
* _.nth(array, -2);
|
||||||
|
* // => 'c';
|
||||||
|
*/
|
||||||
|
function nth(array, n) {
|
||||||
|
return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default nth;
|
||||||
18
nthArg.js
18
nthArg.js
@@ -1,7 +1,10 @@
|
|||||||
|
import baseNth from './_baseNth';
|
||||||
|
import rest from './rest';
|
||||||
import toInteger from './toInteger';
|
import toInteger from './toInteger';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function that returns its nth argument.
|
* Creates a function that returns its nth argument. If `n` is negative,
|
||||||
|
* the nth argument from the end is returned.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -12,15 +15,18 @@ import toInteger from './toInteger';
|
|||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* var func = _.nthArg(1);
|
* var func = _.nthArg(1);
|
||||||
*
|
* func('a', 'b', 'c', 'd');
|
||||||
* func('a', 'b', 'c');
|
|
||||||
* // => 'b'
|
* // => 'b'
|
||||||
|
*
|
||||||
|
* var func = _.nthArg(-2);
|
||||||
|
* func('a', 'b', 'c', 'd');
|
||||||
|
* // => 'c'
|
||||||
*/
|
*/
|
||||||
function nthArg(n) {
|
function nthArg(n) {
|
||||||
n = toInteger(n);
|
n = toInteger(n);
|
||||||
return function() {
|
return rest(function(args) {
|
||||||
return arguments[n];
|
return baseNth(args, n);
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default nthArg;
|
export default nthArg;
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import apply from './_apply';
|
|||||||
import arrayMap from './_arrayMap';
|
import arrayMap from './_arrayMap';
|
||||||
import baseFlatten from './_baseFlatten';
|
import baseFlatten from './_baseFlatten';
|
||||||
import baseIteratee from './_baseIteratee';
|
import baseIteratee from './_baseIteratee';
|
||||||
|
import baseUnary from './_baseUnary';
|
||||||
|
import isArray from './isArray';
|
||||||
import isFlattenableIteratee from './_isFlattenableIteratee';
|
import isFlattenableIteratee from './_isFlattenableIteratee';
|
||||||
import rest from './rest';
|
import rest from './rest';
|
||||||
|
|
||||||
@@ -41,7 +43,10 @@ var nativeMin = Math.min;
|
|||||||
* // => [100, 10]
|
* // => [100, 10]
|
||||||
*/
|
*/
|
||||||
var overArgs = rest(function(func, transforms) {
|
var overArgs = rest(function(func, transforms) {
|
||||||
transforms = arrayMap(baseFlatten(transforms, 1, isFlattenableIteratee), baseIteratee);
|
transforms = (transforms.length == 1 && isArray(transforms[0]))
|
||||||
|
? arrayMap(transforms[0], baseUnary(baseIteratee))
|
||||||
|
: arrayMap(baseFlatten(transforms, 1, isFlattenableIteratee), baseUnary(baseIteratee));
|
||||||
|
|
||||||
var funcsLength = transforms.length;
|
var funcsLength = transforms.length;
|
||||||
return rest(function(args) {
|
return rest(function(args) {
|
||||||
var index = -1,
|
var index = -1,
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
{
|
{
|
||||||
"name": "lodash-es",
|
"name": "lodash-es",
|
||||||
"version": "4.10.0",
|
"version": "4.11.2",
|
||||||
"description": "Lodash exported as ES modules.",
|
"description": "Lodash exported as ES modules.",
|
||||||
|
"keywords": "es6, modules, stdlib, util",
|
||||||
"homepage": "https://lodash.com/custom-builds",
|
"homepage": "https://lodash.com/custom-builds",
|
||||||
|
"bugs": "https://github.com/lodash/lodash-cli/issues",
|
||||||
|
"repository": "lodash/lodash",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"private": true,
|
"private": true,
|
||||||
"jsnext:main": "lodash.js",
|
"jsnext:main": "lodash.js",
|
||||||
"main": "lodash.js",
|
"main": "lodash.js",
|
||||||
"keywords": "es6, modules, stdlib, util",
|
|
||||||
"author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
|
"author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
|
"John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
|
||||||
"Blaine Bublitz <blaine.bublitz@gmail.com> (https://github.com/phated)",
|
"Blaine Bublitz <blaine.bublitz@gmail.com> (https://github.com/phated)",
|
||||||
"Mathias Bynens <mathias@qiwi.be> (https://mathiasbynens.be/)"
|
"Mathias Bynens <mathias@qiwi.be> (https://mathiasbynens.be/)"
|
||||||
],
|
],
|
||||||
"bugs": "https://github.com/lodash/lodash-cli/issues",
|
|
||||||
"repository": "lodash/lodash",
|
|
||||||
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" }
|
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" }
|
||||||
}
|
}
|
||||||
|
|||||||
4
pick.js
4
pick.js
@@ -1,6 +1,8 @@
|
|||||||
|
import arrayMap from './_arrayMap';
|
||||||
import baseFlatten from './_baseFlatten';
|
import baseFlatten from './_baseFlatten';
|
||||||
import basePick from './_basePick';
|
import basePick from './_basePick';
|
||||||
import rest from './rest';
|
import rest from './rest';
|
||||||
|
import toKey from './_toKey';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an object composed of the picked `object` properties.
|
* Creates an object composed of the picked `object` properties.
|
||||||
@@ -20,7 +22,7 @@ import rest from './rest';
|
|||||||
* // => { 'a': 1, 'c': 3 }
|
* // => { 'a': 1, 'c': 3 }
|
||||||
*/
|
*/
|
||||||
var pick = rest(function(object, props) {
|
var pick = rest(function(object, props) {
|
||||||
return object == null ? {} : basePick(object, baseFlatten(props, 1));
|
return object == null ? {} : basePick(object, arrayMap(baseFlatten(props, 1), toKey));
|
||||||
});
|
});
|
||||||
|
|
||||||
export default pick;
|
export default pick;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import baseProperty from './_baseProperty';
|
import baseProperty from './_baseProperty';
|
||||||
import basePropertyDeep from './_basePropertyDeep';
|
import basePropertyDeep from './_basePropertyDeep';
|
||||||
import isKey from './_isKey';
|
import isKey from './_isKey';
|
||||||
|
import toKey from './_toKey';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function that returns the value at `path` of a given object.
|
* Creates a function that returns the value at `path` of a given object.
|
||||||
@@ -25,7 +26,7 @@ import isKey from './_isKey';
|
|||||||
* // => [1, 2]
|
* // => [1, 2]
|
||||||
*/
|
*/
|
||||||
function property(path) {
|
function property(path) {
|
||||||
return isKey(path) ? baseProperty(path) : basePropertyDeep(path);
|
return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default property;
|
export default property;
|
||||||
|
|||||||
12
pullAt.js
12
pullAt.js
@@ -3,6 +3,7 @@ import baseAt from './_baseAt';
|
|||||||
import baseFlatten from './_baseFlatten';
|
import baseFlatten from './_baseFlatten';
|
||||||
import basePullAt from './_basePullAt';
|
import basePullAt from './_basePullAt';
|
||||||
import compareAscending from './_compareAscending';
|
import compareAscending from './_compareAscending';
|
||||||
|
import isIndex from './_isIndex';
|
||||||
import rest from './rest';
|
import rest from './rest';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,10 +31,15 @@ import rest from './rest';
|
|||||||
* // => [10, 20]
|
* // => [10, 20]
|
||||||
*/
|
*/
|
||||||
var pullAt = rest(function(array, indexes) {
|
var pullAt = rest(function(array, indexes) {
|
||||||
indexes = arrayMap(baseFlatten(indexes, 1), String);
|
indexes = baseFlatten(indexes, 1);
|
||||||
|
|
||||||
|
var length = array ? array.length : 0,
|
||||||
|
result = baseAt(array, indexes);
|
||||||
|
|
||||||
|
basePullAt(array, arrayMap(indexes, function(index) {
|
||||||
|
return isIndex(index, length) ? +index : index;
|
||||||
|
}).sort(compareAscending));
|
||||||
|
|
||||||
var result = baseAt(array, indexes);
|
|
||||||
basePullAt(array, indexes.sort(compareAscending));
|
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
1
range.js
1
range.js
@@ -17,6 +17,7 @@ import createRange from './_createRange';
|
|||||||
* @param {number} end The end of the range.
|
* @param {number} end The end of the range.
|
||||||
* @param {number} [step=1] The value to increment or decrement by.
|
* @param {number} [step=1] The value to increment or decrement by.
|
||||||
* @returns {Array} Returns the new array of numbers.
|
* @returns {Array} Returns the new array of numbers.
|
||||||
|
* @see _.inRange, _.rangeRight
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.range(4);
|
* _.range(4);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import createRange from './_createRange';
|
|||||||
* @param {number} end The end of the range.
|
* @param {number} end The end of the range.
|
||||||
* @param {number} [step=1] The value to increment or decrement by.
|
* @param {number} [step=1] The value to increment or decrement by.
|
||||||
* @returns {Array} Returns the new array of numbers.
|
* @returns {Array} Returns the new array of numbers.
|
||||||
|
* @see _.inRange, _.range
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.rangeRight(4);
|
* _.rangeRight(4);
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import isArray from './isArray';
|
|||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||||||
* @param {*} [accumulator] The initial value.
|
* @param {*} [accumulator] The initial value.
|
||||||
* @returns {*} Returns the accumulated value.
|
* @returns {*} Returns the accumulated value.
|
||||||
|
* @see _.reduceRight
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _.reduce([1, 2], function(sum, n) {
|
* _.reduce([1, 2], function(sum, n) {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import isArray from './isArray';
|
|||||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||||||
* @param {*} [accumulator] The initial value.
|
* @param {*} [accumulator] The initial value.
|
||||||
* @returns {*} Returns the accumulated value.
|
* @returns {*} Returns the accumulated value.
|
||||||
|
* @see _.reduce
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* var array = [[0, 1], [2, 3], [4, 5]];
|
* var array = [[0, 1], [2, 3], [4, 5]];
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import isArray from './isArray';
|
|||||||
* @param {Array|Function|Object|string} [predicate=_.identity]
|
* @param {Array|Function|Object|string} [predicate=_.identity]
|
||||||
* The function invoked per iteration.
|
* The function invoked per iteration.
|
||||||
* @returns {Array} Returns the new filtered array.
|
* @returns {Array} Returns the new filtered array.
|
||||||
|
* @see _.filter
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* var users = [
|
* var users = [
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
import toString from './toString';
|
import toString from './toString';
|
||||||
|
|
||||||
|
/** Used for built-in method references. */
|
||||||
|
var stringProto = String.prototype;
|
||||||
|
|
||||||
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||||
|
var nativeReplace = stringProto.replace;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replaces matches for `pattern` in `string` with `replacement`.
|
* Replaces matches for `pattern` in `string` with `replacement`.
|
||||||
*
|
*
|
||||||
@@ -23,7 +29,7 @@ function replace() {
|
|||||||
var args = arguments,
|
var args = arguments,
|
||||||
string = toString(args[0]);
|
string = toString(args[0]);
|
||||||
|
|
||||||
return args.length < 3 ? string : string.replace(args[1], args[2]);
|
return args.length < 3 ? string : nativeReplace.call(string, args[1], args[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default replace;
|
export default replace;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import castPath from './_castPath';
|
import castPath from './_castPath';
|
||||||
import isFunction from './isFunction';
|
import isFunction from './isFunction';
|
||||||
import isKey from './_isKey';
|
import isKey from './_isKey';
|
||||||
|
import toKey from './_toKey';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.get` except that if the resolved value is a
|
* This method is like `_.get` except that if the resolved value is a
|
||||||
@@ -43,7 +44,7 @@ function result(object, path, defaultValue) {
|
|||||||
length = 1;
|
length = 1;
|
||||||
}
|
}
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var value = object == null ? undefined : object[path[index]];
|
var value = object == null ? undefined : object[toKey(path[index])];
|
||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
index = length;
|
index = length;
|
||||||
value = defaultValue;
|
value = defaultValue;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import baseFlatten from './_baseFlatten';
|
import baseFlatten from './_baseFlatten';
|
||||||
import baseOrderBy from './_baseOrderBy';
|
import baseOrderBy from './_baseOrderBy';
|
||||||
|
import isArray from './isArray';
|
||||||
|
import isFlattenableIteratee from './_isFlattenableIteratee';
|
||||||
import isIterateeCall from './_isIterateeCall';
|
import isIterateeCall from './_isIterateeCall';
|
||||||
import rest from './rest';
|
import rest from './rest';
|
||||||
|
|
||||||
@@ -47,7 +49,11 @@ var sortBy = rest(function(collection, iteratees) {
|
|||||||
} else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
|
} else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
|
||||||
iteratees = [iteratees[0]];
|
iteratees = [iteratees[0]];
|
||||||
}
|
}
|
||||||
return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
|
iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
|
||||||
|
? iteratees[0]
|
||||||
|
: baseFlatten(iteratees, 1, isFlattenableIteratee);
|
||||||
|
|
||||||
|
return baseOrderBy(collection, iteratees, []);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default sortBy;
|
export default sortBy;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import baseIteratee from './_baseIteratee';
|
import baseIteratee from './_baseIteratee';
|
||||||
import baseSortedUniqBy from './_baseSortedUniqBy';
|
import baseSortedUniq from './_baseSortedUniq';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.uniqBy` except that it's designed and optimized
|
* This method is like `_.uniqBy` except that it's designed and optimized
|
||||||
@@ -19,7 +19,7 @@ import baseSortedUniqBy from './_baseSortedUniqBy';
|
|||||||
*/
|
*/
|
||||||
function sortedUniqBy(array, iteratee) {
|
function sortedUniqBy(array, iteratee) {
|
||||||
return (array && array.length)
|
return (array && array.length)
|
||||||
? baseSortedUniqBy(array, baseIteratee(iteratee))
|
? baseSortedUniq(array, baseIteratee(iteratee))
|
||||||
: [];
|
: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
11
split.js
11
split.js
@@ -1,3 +1,4 @@
|
|||||||
|
import baseToString from './_baseToString';
|
||||||
import castSlice from './_castSlice';
|
import castSlice from './_castSlice';
|
||||||
import isIterateeCall from './_isIterateeCall';
|
import isIterateeCall from './_isIterateeCall';
|
||||||
import isRegExp from './isRegExp';
|
import isRegExp from './isRegExp';
|
||||||
@@ -8,6 +9,12 @@ import toString from './toString';
|
|||||||
/** Used as references for the maximum length and index of an array. */
|
/** Used as references for the maximum length and index of an array. */
|
||||||
var MAX_ARRAY_LENGTH = 4294967295;
|
var MAX_ARRAY_LENGTH = 4294967295;
|
||||||
|
|
||||||
|
/** Used for built-in method references. */
|
||||||
|
var stringProto = String.prototype;
|
||||||
|
|
||||||
|
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||||
|
var nativeSplit = stringProto.split;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Splits `string` by `separator`.
|
* Splits `string` by `separator`.
|
||||||
*
|
*
|
||||||
@@ -40,12 +47,12 @@ function split(string, separator, limit) {
|
|||||||
typeof separator == 'string' ||
|
typeof separator == 'string' ||
|
||||||
(separator != null && !isRegExp(separator))
|
(separator != null && !isRegExp(separator))
|
||||||
)) {
|
)) {
|
||||||
separator += '';
|
separator = baseToString(separator);
|
||||||
if (separator == '' && reHasComplexSymbol.test(string)) {
|
if (separator == '' && reHasComplexSymbol.test(string)) {
|
||||||
return castSlice(stringToArray(string), 0, limit);
|
return castSlice(stringToArray(string), 0, limit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return string.split(separator, limit);
|
return nativeSplit.call(string, separator, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default split;
|
export default split;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import baseClamp from './_baseClamp';
|
import baseClamp from './_baseClamp';
|
||||||
|
import baseToString from './_baseToString';
|
||||||
import toInteger from './toInteger';
|
import toInteger from './toInteger';
|
||||||
import toString from './toString';
|
import toString from './toString';
|
||||||
|
|
||||||
@@ -28,7 +29,7 @@ import toString from './toString';
|
|||||||
function startsWith(string, target, position) {
|
function startsWith(string, target, position) {
|
||||||
string = toString(string);
|
string = toString(string);
|
||||||
position = baseClamp(toInteger(position), 0, string.length);
|
position = baseClamp(toInteger(position), 0, string.length);
|
||||||
return string.lastIndexOf(target, position) == position;
|
return string.lastIndexOf(baseToString(target), position) == position;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default startsWith;
|
export default startsWith;
|
||||||
|
|||||||
23
toString.js
23
toString.js
@@ -1,12 +1,4 @@
|
|||||||
import Symbol from './_Symbol';
|
import baseToString from './_baseToString';
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts `value` to a string. An empty string is returned for `null`
|
* Converts `value` to a string. An empty string is returned for `null`
|
||||||
@@ -30,18 +22,7 @@ var symbolProto = Symbol ? Symbol.prototype : undefined,
|
|||||||
* // => '1,2,3'
|
* // => '1,2,3'
|
||||||
*/
|
*/
|
||||||
function toString(value) {
|
function toString(value) {
|
||||||
// Exit early for strings to avoid a performance hit in some environments.
|
return value == null ? '' : baseToString(value);
|
||||||
if (typeof value == 'string') {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
if (value == null) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
if (isSymbol(value)) {
|
|
||||||
return symbolToString ? symbolToString.call(value) : '';
|
|
||||||
}
|
|
||||||
var result = (value + '');
|
|
||||||
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default toString;
|
export default toString;
|
||||||
|
|||||||
8
trim.js
8
trim.js
@@ -1,3 +1,4 @@
|
|||||||
|
import baseToString from './_baseToString';
|
||||||
import castSlice from './_castSlice';
|
import castSlice from './_castSlice';
|
||||||
import charsEndIndex from './_charsEndIndex';
|
import charsEndIndex from './_charsEndIndex';
|
||||||
import charsStartIndex from './_charsStartIndex';
|
import charsStartIndex from './_charsStartIndex';
|
||||||
@@ -31,13 +32,10 @@ var reTrim = /^\s+|\s+$/g;
|
|||||||
*/
|
*/
|
||||||
function trim(string, chars, guard) {
|
function trim(string, chars, guard) {
|
||||||
string = toString(string);
|
string = toString(string);
|
||||||
if (!string) {
|
if (string && (guard || chars === undefined)) {
|
||||||
return string;
|
|
||||||
}
|
|
||||||
if (guard || chars === undefined) {
|
|
||||||
return string.replace(reTrim, '');
|
return string.replace(reTrim, '');
|
||||||
}
|
}
|
||||||
if (!(chars += '')) {
|
if (!string || !(chars = baseToString(chars))) {
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
var strSymbols = stringToArray(string),
|
var strSymbols = stringToArray(string),
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import baseToString from './_baseToString';
|
||||||
import castSlice from './_castSlice';
|
import castSlice from './_castSlice';
|
||||||
import charsEndIndex from './_charsEndIndex';
|
import charsEndIndex from './_charsEndIndex';
|
||||||
import stringToArray from './_stringToArray';
|
import stringToArray from './_stringToArray';
|
||||||
@@ -27,13 +28,10 @@ var reTrimEnd = /\s+$/;
|
|||||||
*/
|
*/
|
||||||
function trimEnd(string, chars, guard) {
|
function trimEnd(string, chars, guard) {
|
||||||
string = toString(string);
|
string = toString(string);
|
||||||
if (!string) {
|
if (string && (guard || chars === undefined)) {
|
||||||
return string;
|
|
||||||
}
|
|
||||||
if (guard || chars === undefined) {
|
|
||||||
return string.replace(reTrimEnd, '');
|
return string.replace(reTrimEnd, '');
|
||||||
}
|
}
|
||||||
if (!(chars += '')) {
|
if (!string || !(chars = baseToString(chars))) {
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
var strSymbols = stringToArray(string),
|
var strSymbols = stringToArray(string),
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user