mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
Compare commits
6 Commits
4.8.0-amd
...
4.11.2-amd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ccdfca5392 | ||
|
|
29c408ee8a | ||
|
|
63d9a3fc42 | ||
|
|
76b289fe6e | ||
|
|
57f1942947 | ||
|
|
8349627be6 |
@@ -1,4 +1,4 @@
|
||||
# lodash-amd v4.8.0
|
||||
# lodash-amd v4.11.2
|
||||
|
||||
The [Lodash](https://lodash.com/) library exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules.
|
||||
|
||||
@@ -27,4 +27,4 @@ require({
|
||||
});
|
||||
```
|
||||
|
||||
See the [package source](https://github.com/lodash/lodash/tree/4.8.0-amd) for more details.
|
||||
See the [package source](https://github.com/lodash/lodash/tree/4.11.2-amd) for more details.
|
||||
|
||||
2
_Hash.js
2
_Hash.js
@@ -4,7 +4,7 @@ define(['./_nativeCreate'], function(nativeCreate) {
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/**
|
||||
* Creates an hash object.
|
||||
* Creates a hash object.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
define(['./isSymbol'], function(isSymbol) {
|
||||
|
||||
/**
|
||||
* Casts `value` to a string if it's not a string or symbol.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to inspect.
|
||||
* @returns {string|symbol} Returns the cast key.
|
||||
*/
|
||||
function baseCastKey(key) {
|
||||
return (typeof key == 'string' || isSymbol(key)) ? key : (key + '');
|
||||
}
|
||||
|
||||
return baseCastKey;
|
||||
});
|
||||
@@ -42,6 +42,7 @@ define(['./_SetCache', './_arrayIncludes', './_arrayIncludesWith', './_arrayMap'
|
||||
var value = array[index],
|
||||
computed = iteratee ? iteratee(value) : value;
|
||||
|
||||
value = (comparator || value !== 0) ? value : 0;
|
||||
if (isCommon && computed === computed) {
|
||||
var valuesIndex = valuesLength;
|
||||
while (valuesIndex--) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define([], function() {
|
||||
define(['./isSymbol'], function(isSymbol) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -22,7 +22,7 @@ define([], function() {
|
||||
current = iteratee(value);
|
||||
|
||||
if (current != null && (computed === undefined
|
||||
? current === current
|
||||
? (current === current && !isSymbol(current))
|
||||
: comparator(current, computed)
|
||||
)) {
|
||||
var computed = current,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_arrayPush', './isArguments', './isArray', './isArrayLikeObject'], function(arrayPush, isArguments, isArray, isArrayLikeObject) {
|
||||
define(['./_arrayPush', './_isFlattenable'], function(arrayPush, isFlattenable) {
|
||||
|
||||
/**
|
||||
* The base implementation of `_.flatten` with support for restricting flattening.
|
||||
@@ -6,23 +6,24 @@ define(['./_arrayPush', './isArguments', './isArray', './isArrayLikeObject'], fu
|
||||
* @private
|
||||
* @param {Array} array The array to flatten.
|
||||
* @param {number} depth The maximum recursion depth.
|
||||
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
|
||||
* @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
|
||||
* @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
|
||||
* @param {Array} [result=[]] The initial result value.
|
||||
* @returns {Array} Returns the new flattened array.
|
||||
*/
|
||||
function baseFlatten(array, depth, isStrict, result) {
|
||||
result || (result = []);
|
||||
|
||||
function baseFlatten(array, depth, predicate, isStrict, result) {
|
||||
var index = -1,
|
||||
length = array.length;
|
||||
|
||||
predicate || (predicate = isFlattenable);
|
||||
result || (result = []);
|
||||
|
||||
while (++index < length) {
|
||||
var value = array[index];
|
||||
if (depth > 0 && isArrayLikeObject(value) &&
|
||||
(isStrict || isArray(value) || isArguments(value))) {
|
||||
if (depth > 0 && predicate(value)) {
|
||||
if (depth > 1) {
|
||||
// Recursively flatten arrays (susceptible to call stack limits).
|
||||
baseFlatten(value, depth - 1, isStrict, result);
|
||||
baseFlatten(value, depth - 1, predicate, isStrict, result);
|
||||
} else {
|
||||
arrayPush(result, value);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ define(['./_createBaseFor'], function(createBaseFor) {
|
||||
|
||||
/**
|
||||
* The base implementation of `baseForOwn` which iterates over `object`
|
||||
* properties returned by `keysFunc` invoking `iteratee` for each property.
|
||||
* properties returned by `keysFunc` and invokes `iteratee` for each property.
|
||||
* Iteratee functions may exit iteration early by explicitly returning `false`.
|
||||
*
|
||||
* @private
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_baseCastPath', './_isKey'], function(baseCastPath, isKey) {
|
||||
define(['./_castPath', './_isKey', './_toKey'], function(castPath, isKey, toKey) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -12,13 +12,13 @@ define(['./_baseCastPath', './_isKey'], function(baseCastPath, isKey) {
|
||||
* @returns {*} Returns the resolved value.
|
||||
*/
|
||||
function baseGet(object, path) {
|
||||
path = isKey(path, object) ? [path] : baseCastPath(path);
|
||||
path = isKey(path, object) ? [path] : castPath(path);
|
||||
|
||||
var index = 0,
|
||||
length = path.length;
|
||||
|
||||
while (object != null && index < length) {
|
||||
object = object[path[index++]];
|
||||
object = object[toKey(path[index++])];
|
||||
}
|
||||
return (index && index == length) ? object : undefined;
|
||||
}
|
||||
|
||||
17
_baseGt.js
Normal file
17
_baseGt.js
Normal file
@@ -0,0 +1,17 @@
|
||||
define([], function() {
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
return baseGt;
|
||||
});
|
||||
@@ -45,6 +45,7 @@ define(['./_SetCache', './_arrayIncludes', './_arrayIncludesWith', './_arrayMap'
|
||||
var value = array[index],
|
||||
computed = iteratee ? iteratee(value) : value;
|
||||
|
||||
value = (comparator || value !== 0) ? value : 0;
|
||||
if (!(seen
|
||||
? cacheHas(seen, computed)
|
||||
: includes(result, computed, comparator)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_apply', './_baseCastPath', './_isKey', './last', './_parent'], function(apply, baseCastPath, isKey, last, parent) {
|
||||
define(['./_apply', './_castPath', './_isKey', './last', './_parent', './_toKey'], function(apply, castPath, isKey, last, parent, toKey) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -15,11 +15,11 @@ define(['./_apply', './_baseCastPath', './_isKey', './last', './_parent'], funct
|
||||
*/
|
||||
function baseInvoke(object, path, args) {
|
||||
if (!isKey(path, object)) {
|
||||
path = baseCastPath(path);
|
||||
path = castPath(path);
|
||||
object = parent(object, path);
|
||||
path = last(path);
|
||||
}
|
||||
var func = object == null ? object : object[path];
|
||||
var func = object == null ? object : object[toKey(path)];
|
||||
return func == null ? undefined : apply(func, object, args);
|
||||
}
|
||||
|
||||
|
||||
17
_baseLt.js
Normal file
17
_baseLt.js
Normal file
@@ -0,0 +1,17 @@
|
||||
define([], function() {
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
return baseLt;
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_baseIsEqual', './get', './hasIn', './_isKey', './_isStrictComparable', './_matchesStrictComparable'], function(baseIsEqual, get, hasIn, isKey, isStrictComparable, matchesStrictComparable) {
|
||||
define(['./_baseIsEqual', './get', './hasIn', './_isKey', './_isStrictComparable', './_matchesStrictComparable', './_toKey'], function(baseIsEqual, get, hasIn, isKey, isStrictComparable, matchesStrictComparable, toKey) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -17,7 +17,7 @@ define(['./_baseIsEqual', './get', './hasIn', './_isKey', './_isStrictComparable
|
||||
*/
|
||||
function baseMatchesProperty(path, srcValue) {
|
||||
if (isKey(path) && isStrictComparable(srcValue)) {
|
||||
return matchesStrictComparable(path, srcValue);
|
||||
return matchesStrictComparable(toKey(path), srcValue);
|
||||
}
|
||||
return function(object) {
|
||||
var objValue = get(object, path);
|
||||
|
||||
24
_baseNth.js
Normal file
24
_baseNth.js
Normal file
@@ -0,0 +1,24 @@
|
||||
define(['./_isIndex'], function(isIndex) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
return baseNth;
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_arrayMap', './_baseIteratee', './_baseMap', './_baseSortBy', './_compareMultiple', './identity'], function(arrayMap, baseIteratee, baseMap, baseSortBy, compareMultiple, identity) {
|
||||
define(['./_arrayMap', './_baseIteratee', './_baseMap', './_baseSortBy', './_baseUnary', './_compareMultiple', './identity'], function(arrayMap, baseIteratee, baseMap, baseSortBy, baseUnary, compareMultiple, identity) {
|
||||
|
||||
/**
|
||||
* The base implementation of `_.orderBy` without param guards.
|
||||
@@ -11,7 +11,7 @@ define(['./_arrayMap', './_baseIteratee', './_baseMap', './_baseSortBy', './_com
|
||||
*/
|
||||
function baseOrderBy(collection, iteratees, orders) {
|
||||
var index = -1;
|
||||
iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseIteratee);
|
||||
iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(baseIteratee));
|
||||
|
||||
var result = baseMap(collection, function(value, key, collection) {
|
||||
var criteria = arrayMap(iteratees, function(iteratee) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_baseCastPath', './_isIndex', './_isKey', './last', './_parent'], function(baseCastPath, isIndex, isKey, last, parent) {
|
||||
define(['./_castPath', './_isIndex', './_isKey', './last', './_parent', './_toKey'], function(castPath, isIndex, isKey, last, parent, toKey) {
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var arrayProto = Array.prototype;
|
||||
@@ -21,21 +21,21 @@ define(['./_baseCastPath', './_isIndex', './_isKey', './last', './_parent'], fun
|
||||
|
||||
while (length--) {
|
||||
var index = indexes[length];
|
||||
if (lastIndex == length || index != previous) {
|
||||
if (length == lastIndex || index !== previous) {
|
||||
var previous = index;
|
||||
if (isIndex(index)) {
|
||||
splice.call(array, index, 1);
|
||||
}
|
||||
else if (!isKey(index, array)) {
|
||||
var path = baseCastPath(index),
|
||||
var path = castPath(index),
|
||||
object = parent(array, path);
|
||||
|
||||
if (object != null) {
|
||||
delete object[last(path)];
|
||||
delete object[toKey(last(path))];
|
||||
}
|
||||
}
|
||||
else {
|
||||
delete array[index];
|
||||
delete array[toKey(index)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_assignValue', './_baseCastPath', './_isIndex', './_isKey', './isObject'], function(assignValue, baseCastPath, isIndex, isKey, isObject) {
|
||||
define(['./_assignValue', './_castPath', './_isIndex', './_isKey', './isObject', './_toKey'], function(assignValue, castPath, isIndex, isKey, isObject, toKey) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -14,7 +14,7 @@ define(['./_assignValue', './_baseCastPath', './_isIndex', './_isKey', './isObje
|
||||
* @returns {Object} Returns `object`.
|
||||
*/
|
||||
function baseSet(object, path, value, customizer) {
|
||||
path = isKey(path, object) ? [path] : baseCastPath(path);
|
||||
path = isKey(path, object) ? [path] : castPath(path);
|
||||
|
||||
var index = -1,
|
||||
length = path.length,
|
||||
@@ -22,7 +22,7 @@ define(['./_assignValue', './_baseCastPath', './_isIndex', './_isKey', './isObje
|
||||
nested = object;
|
||||
|
||||
while (nested != null && ++index < length) {
|
||||
var key = path[index];
|
||||
var key = toKey(path[index]);
|
||||
if (isObject(nested)) {
|
||||
var newValue = value;
|
||||
if (index != lastIndex) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_baseSortedIndexBy', './identity'], function(baseSortedIndexBy, identity) {
|
||||
define(['./_baseSortedIndexBy', './identity', './isSymbol'], function(baseSortedIndexBy, identity, isSymbol) {
|
||||
|
||||
/** Used as references for the maximum length and index of an array. */
|
||||
var MAX_ARRAY_LENGTH = 4294967295,
|
||||
@@ -25,7 +25,8 @@ define(['./_baseSortedIndexBy', './identity'], function(baseSortedIndexBy, ident
|
||||
var mid = (low + high) >>> 1,
|
||||
computed = array[mid];
|
||||
|
||||
if ((retHighest ? (computed <= value) : (computed < value)) && computed !== null) {
|
||||
if (computed !== null && !isSymbol(computed) &&
|
||||
(retHighest ? (computed <= value) : (computed < value))) {
|
||||
low = mid + 1;
|
||||
} else {
|
||||
high = mid;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define([], function() {
|
||||
define(['./isSymbol'], function(isSymbol) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -31,21 +31,26 @@ define([], function() {
|
||||
high = array ? array.length : 0,
|
||||
valIsNaN = value !== value,
|
||||
valIsNull = value === null,
|
||||
valIsUndef = value === undefined;
|
||||
valIsSymbol = isSymbol(value),
|
||||
valIsUndefined = value === undefined;
|
||||
|
||||
while (low < high) {
|
||||
var mid = nativeFloor((low + high) / 2),
|
||||
computed = iteratee(array[mid]),
|
||||
isDef = computed !== undefined,
|
||||
isReflexive = computed === computed;
|
||||
othIsDefined = computed !== undefined,
|
||||
othIsNull = computed === null,
|
||||
othIsReflexive = computed === computed,
|
||||
othIsSymbol = isSymbol(computed);
|
||||
|
||||
if (valIsNaN) {
|
||||
var setLow = isReflexive || retHighest;
|
||||
var setLow = retHighest || othIsReflexive;
|
||||
} else if (valIsUndefined) {
|
||||
setLow = othIsReflexive && (retHighest || othIsDefined);
|
||||
} else if (valIsNull) {
|
||||
setLow = isReflexive && isDef && (retHighest || computed != null);
|
||||
} else if (valIsUndef) {
|
||||
setLow = isReflexive && (retHighest || isDef);
|
||||
} else if (computed == null) {
|
||||
setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
|
||||
} else if (valIsSymbol) {
|
||||
setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
|
||||
} else if (othIsNull || othIsSymbol) {
|
||||
setLow = false;
|
||||
} else {
|
||||
setLow = retHighest ? (computed <= value) : (computed < value);
|
||||
|
||||
@@ -1,14 +1,30 @@
|
||||
define(['./_baseSortedUniqBy'], function(baseSortedUniqBy) {
|
||||
define(['./eq'], function(eq) {
|
||||
|
||||
/**
|
||||
* The base implementation of `_.sortedUniq`.
|
||||
* The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
|
||||
* support for iteratee shorthands.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to inspect.
|
||||
* @param {Function} [iteratee] The iteratee invoked per element.
|
||||
* @returns {Array} Returns the new duplicate free array.
|
||||
*/
|
||||
function baseSortedUniq(array) {
|
||||
return baseSortedUniqBy(array);
|
||||
function baseSortedUniq(array, iteratee) {
|
||||
var index = -1,
|
||||
length = array.length,
|
||||
resIndex = 0,
|
||||
result = [];
|
||||
|
||||
while (++index < length) {
|
||||
var value = array[index],
|
||||
computed = iteratee ? iteratee(value) : value;
|
||||
|
||||
if (!index || !eq(computed, seen)) {
|
||||
var seen = computed;
|
||||
result[resIndex++] = value === 0 ? 0 : value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return baseSortedUniq;
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
define(['./eq'], function(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;
|
||||
}
|
||||
|
||||
return baseSortedUniqBy;
|
||||
});
|
||||
25
_baseToNumber.js
Normal file
25
_baseToNumber.js
Normal file
@@ -0,0 +1,25 @@
|
||||
define(['./isSymbol'], function(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;
|
||||
}
|
||||
|
||||
return baseToNumber;
|
||||
});
|
||||
34
_baseToString.js
Normal file
34
_baseToString.js
Normal file
@@ -0,0 +1,34 @@
|
||||
define(['./_Symbol', './isSymbol'], function(Symbol, isSymbol) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/** 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;
|
||||
}
|
||||
|
||||
return baseToString;
|
||||
});
|
||||
@@ -41,6 +41,7 @@ define(['./_SetCache', './_arrayIncludes', './_arrayIncludesWith', './_cacheHas'
|
||||
var value = array[index],
|
||||
computed = iteratee ? iteratee(value) : value;
|
||||
|
||||
value = (comparator || value !== 0) ? value : 0;
|
||||
if (isCommon && computed === computed) {
|
||||
var seenIndex = seen.length;
|
||||
while (seenIndex--) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_baseCastPath', './has', './_isKey', './last', './_parent'], function(baseCastPath, has, isKey, last, parent) {
|
||||
define(['./_baseHas', './_castPath', './_isKey', './last', './_parent', './_toKey'], function(baseHas, castPath, isKey, last, parent, toKey) {
|
||||
|
||||
/**
|
||||
* The base implementation of `_.unset`.
|
||||
@@ -9,10 +9,11 @@ define(['./_baseCastPath', './has', './_isKey', './last', './_parent'], function
|
||||
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
|
||||
*/
|
||||
function baseUnset(object, path) {
|
||||
path = isKey(path, object) ? [path] : baseCastPath(path);
|
||||
path = isKey(path, object) ? [path] : castPath(path);
|
||||
object = parent(object, path);
|
||||
var key = last(path);
|
||||
return (object != null && has(object, key)) ? delete object[key] : true;
|
||||
|
||||
var key = toKey(last(path));
|
||||
return !(object != null && baseHas(object, key)) || delete object[key];
|
||||
}
|
||||
|
||||
return baseUnset;
|
||||
|
||||
@@ -7,9 +7,9 @@ define(['./isArrayLikeObject'], function(isArrayLikeObject) {
|
||||
* @param {*} value The value to inspect.
|
||||
* @returns {Array|Object} Returns the cast array-like object.
|
||||
*/
|
||||
function baseCastArrayLikeObject(value) {
|
||||
function castArrayLikeObject(value) {
|
||||
return isArrayLikeObject(value) ? value : [];
|
||||
}
|
||||
|
||||
return baseCastArrayLikeObject;
|
||||
return castArrayLikeObject;
|
||||
});
|
||||
@@ -7,9 +7,9 @@ define(['./identity'], function(identity) {
|
||||
* @param {*} value The value to inspect.
|
||||
* @returns {Function} Returns cast function.
|
||||
*/
|
||||
function baseCastFunction(value) {
|
||||
function castFunction(value) {
|
||||
return typeof value == 'function' ? value : identity;
|
||||
}
|
||||
|
||||
return baseCastFunction;
|
||||
return castFunction;
|
||||
});
|
||||
@@ -7,9 +7,9 @@ define(['./isArray', './_stringToPath'], function(isArray, stringToPath) {
|
||||
* @param {*} value The value to inspect.
|
||||
* @returns {Array} Returns the cast property path array.
|
||||
*/
|
||||
function baseCastPath(value) {
|
||||
function castPath(value) {
|
||||
return isArray(value) ? value : stringToPath(value);
|
||||
}
|
||||
|
||||
return baseCastPath;
|
||||
return castPath;
|
||||
});
|
||||
22
_castSlice.js
Normal file
22
_castSlice.js
Normal file
@@ -0,0 +1,22 @@
|
||||
define(['./_baseSlice'], function(baseSlice) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/**
|
||||
* Casts `array` to a slice if it's needed.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to inspect.
|
||||
* @param {number} start The start position.
|
||||
* @param {number} [end=array.length] The end position.
|
||||
* @returns {Array} Returns the cast slice.
|
||||
*/
|
||||
function castSlice(array, start, end) {
|
||||
var length = array.length;
|
||||
end = end === undefined ? length : end;
|
||||
return (!start && end >= length) ? array : baseSlice(array, start, end);
|
||||
}
|
||||
|
||||
return castSlice;
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
define([], function() {
|
||||
define(['./isSymbol'], function(isSymbol) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -13,22 +13,28 @@ define([], function() {
|
||||
*/
|
||||
function compareAscending(value, other) {
|
||||
if (value !== other) {
|
||||
var valIsNull = value === null,
|
||||
valIsUndef = value === undefined,
|
||||
valIsReflexive = value === value;
|
||||
var valIsDefined = value !== undefined,
|
||||
valIsNull = value === null,
|
||||
valIsReflexive = value === value,
|
||||
valIsSymbol = isSymbol(value);
|
||||
|
||||
var othIsNull = other === null,
|
||||
othIsUndef = other === undefined,
|
||||
othIsReflexive = other === other;
|
||||
var othIsDefined = other !== undefined,
|
||||
othIsNull = other === null,
|
||||
othIsReflexive = other === other,
|
||||
othIsSymbol = isSymbol(other);
|
||||
|
||||
if ((value > other && !othIsNull) || !valIsReflexive ||
|
||||
(valIsNull && !othIsUndef && othIsReflexive) ||
|
||||
(valIsUndef && othIsReflexive)) {
|
||||
if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
|
||||
(valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
|
||||
(valIsNull && othIsDefined && othIsReflexive) ||
|
||||
(!valIsDefined && othIsReflexive) ||
|
||||
!valIsReflexive) {
|
||||
return 1;
|
||||
}
|
||||
if ((value < other && !valIsNull) || !othIsReflexive ||
|
||||
(othIsNull && !valIsUndef && valIsReflexive) ||
|
||||
(othIsUndef && valIsReflexive)) {
|
||||
if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
|
||||
(othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
|
||||
(othIsNull && valIsDefined && valIsReflexive) ||
|
||||
(!othIsDefined && valIsReflexive) ||
|
||||
!othIsReflexive) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_copyObjectWith'], function(copyObjectWith) {
|
||||
define(['./_assignValue'], function(assignValue) {
|
||||
|
||||
/**
|
||||
* Copies properties of `source` to `object`.
|
||||
@@ -7,10 +7,25 @@ define(['./_copyObjectWith'], function(copyObjectWith) {
|
||||
* @param {Object} source The object to copy properties from.
|
||||
* @param {Array} props The property identifiers to copy.
|
||||
* @param {Object} [object={}] The object to copy properties to.
|
||||
* @param {Function} [customizer] The function to customize copied values.
|
||||
* @returns {Object} Returns `object`.
|
||||
*/
|
||||
function copyObject(source, props, object) {
|
||||
return copyObjectWith(source, props, object);
|
||||
function copyObject(source, props, object, customizer) {
|
||||
object || (object = {});
|
||||
|
||||
var index = -1,
|
||||
length = props.length;
|
||||
|
||||
while (++index < length) {
|
||||
var key = props[index];
|
||||
|
||||
var newValue = customizer
|
||||
? customizer(object[key], source[key], key, object, source)
|
||||
: source[key];
|
||||
|
||||
assignValue(object, key, newValue);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
return copyObject;
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
define(['./_assignValue'], function(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;
|
||||
}
|
||||
|
||||
return copyObjectWith;
|
||||
});
|
||||
@@ -1,20 +1,8 @@
|
||||
define(['./_stringToArray', './toString'], function(stringToArray, toString) {
|
||||
define(['./_castSlice', './_reHasComplexSymbol', './_stringToArray', './toString'], function(castSlice, reHasComplexSymbol, stringToArray, toString) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/** Used to compose unicode character classes. */
|
||||
var rsAstralRange = '\\ud800-\\udfff',
|
||||
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
|
||||
rsComboSymbolsRange = '\\u20d0-\\u20f0',
|
||||
rsVarRange = '\\ufe0e\\ufe0f';
|
||||
|
||||
/** Used to compose unicode capture groups. */
|
||||
var rsZWJ = '\\u200d';
|
||||
|
||||
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
|
||||
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
|
||||
|
||||
/**
|
||||
* Creates a function like `_.lowerFirst`.
|
||||
*
|
||||
@@ -30,8 +18,13 @@ define(['./_stringToArray', './toString'], function(stringToArray, toString) {
|
||||
? stringToArray(string)
|
||||
: undefined;
|
||||
|
||||
var chr = strSymbols ? strSymbols[0] : string.charAt(0),
|
||||
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
|
||||
var chr = strSymbols
|
||||
? strSymbols[0]
|
||||
: string.charAt(0);
|
||||
|
||||
var trailing = strSymbols
|
||||
? castSlice(strSymbols, 1).join('')
|
||||
: string.slice(1);
|
||||
|
||||
return chr[methodName]() + trailing;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
define(['./_arrayReduce', './deburr', './words'], function(arrayReduce, deburr, words) {
|
||||
|
||||
/** Used to compose unicode capture groups. */
|
||||
var rsApos = "['\u2019]";
|
||||
|
||||
/** Used to match apostrophes. */
|
||||
var reApos = RegExp(rsApos, 'g');
|
||||
|
||||
/**
|
||||
* Creates a function like `_.camelCase`.
|
||||
*
|
||||
@@ -9,7 +15,7 @@ define(['./_arrayReduce', './deburr', './words'], function(arrayReduce, deburr,
|
||||
*/
|
||||
function createCompounder(callback) {
|
||||
return function(string) {
|
||||
return arrayReduce(words(deburr(string)), callback, '');
|
||||
return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define([], function() {
|
||||
define(['./_baseToNumber', './_baseToString'], function(baseToNumber, baseToString) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -20,7 +20,17 @@ define([], function() {
|
||||
result = value;
|
||||
}
|
||||
if (other !== undefined) {
|
||||
result = result === undefined ? other : operator(result, other);
|
||||
if (result === undefined) {
|
||||
return other;
|
||||
}
|
||||
if (typeof value == 'string' || typeof other == 'string') {
|
||||
value = baseToString(value);
|
||||
other = baseToString(other);
|
||||
} else {
|
||||
value = baseToNumber(value);
|
||||
other = baseToNumber(other);
|
||||
}
|
||||
result = operator(value, other);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_apply', './_arrayMap', './_baseIteratee', './rest'], function(apply, arrayMap, baseIteratee, rest) {
|
||||
define(['./_apply', './_arrayMap', './_baseFlatten', './_baseIteratee', './_baseUnary', './isArray', './_isFlattenableIteratee', './rest'], function(apply, arrayMap, baseFlatten, baseIteratee, baseUnary, isArray, isFlattenableIteratee, rest) {
|
||||
|
||||
/**
|
||||
* Creates a function like `_.over`.
|
||||
@@ -9,7 +9,10 @@ define(['./_apply', './_arrayMap', './_baseIteratee', './rest'], function(apply,
|
||||
*/
|
||||
function createOver(arrayFunc) {
|
||||
return rest(function(iteratees) {
|
||||
iteratees = arrayMap(iteratees, baseIteratee);
|
||||
iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
|
||||
? arrayMap(iteratees[0], baseUnary(baseIteratee))
|
||||
: arrayMap(baseFlatten(iteratees, 1, isFlattenableIteratee), baseUnary(baseIteratee));
|
||||
|
||||
return rest(function(args) {
|
||||
var thisArg = this;
|
||||
return arrayFunc(iteratees, function(iteratee) {
|
||||
|
||||
@@ -1,20 +1,8 @@
|
||||
define(['./_baseRepeat', './_stringSize', './_stringToArray'], function(baseRepeat, stringSize, stringToArray) {
|
||||
define(['./_baseRepeat', './_baseToString', './_castSlice', './_reHasComplexSymbol', './_stringSize', './_stringToArray'], function(baseRepeat, baseToString, castSlice, reHasComplexSymbol, stringSize, stringToArray) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/** Used to compose unicode character classes. */
|
||||
var rsAstralRange = '\\ud800-\\udfff',
|
||||
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
|
||||
rsComboSymbolsRange = '\\u20d0-\\u20f0',
|
||||
rsVarRange = '\\ufe0e\\ufe0f';
|
||||
|
||||
/** Used to compose unicode capture groups. */
|
||||
var rsZWJ = '\\u200d';
|
||||
|
||||
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
|
||||
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
var nativeCeil = Math.ceil;
|
||||
|
||||
@@ -28,7 +16,7 @@ define(['./_baseRepeat', './_stringSize', './_stringToArray'], function(baseRepe
|
||||
* @returns {string} Returns the padding for `string`.
|
||||
*/
|
||||
function createPadding(length, chars) {
|
||||
chars = chars === undefined ? ' ' : (chars + '');
|
||||
chars = chars === undefined ? ' ' : baseToString(chars);
|
||||
|
||||
var charsLength = chars.length;
|
||||
if (charsLength < 2) {
|
||||
@@ -36,7 +24,7 @@ define(['./_baseRepeat', './_stringSize', './_stringToArray'], function(baseRepe
|
||||
}
|
||||
var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
|
||||
return reHasComplexSymbol.test(chars)
|
||||
? stringToArray(result).slice(0, length).join('')
|
||||
? castSlice(stringToArray(result), 0, length).join('')
|
||||
: result.slice(0, length);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_copyArray', './_isLaziable', './_setData'], function(copyArray, isLaziable, setData) {
|
||||
define(['./_isLaziable', './_setData'], function(isLaziable, setData) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -31,7 +31,6 @@ define(['./_copyArray', './_isLaziable', './_setData'], function(copyArray, isLa
|
||||
*/
|
||||
function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
|
||||
var isCurry = bitmask & CURRY_FLAG,
|
||||
newArgPos = argPos ? copyArray(argPos) : undefined,
|
||||
newHolders = isCurry ? holders : undefined,
|
||||
newHoldersRight = isCurry ? undefined : holders,
|
||||
newPartials = isCurry ? partials : undefined,
|
||||
@@ -45,7 +44,7 @@ define(['./_copyArray', './_isLaziable', './_setData'], function(copyArray, isLa
|
||||
}
|
||||
var newData = [
|
||||
func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
|
||||
newHoldersRight, newArgPos, ary, arity
|
||||
newHoldersRight, argPos, ary, arity
|
||||
];
|
||||
|
||||
var result = wrapFunc.apply(undefined, newData);
|
||||
|
||||
21
_createRelationalOperation.js
Normal file
21
_createRelationalOperation.js
Normal file
@@ -0,0 +1,21 @@
|
||||
define(['./toNumber'], function(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);
|
||||
};
|
||||
}
|
||||
|
||||
return createRelationalOperation;
|
||||
});
|
||||
@@ -1,4 +1,7 @@
|
||||
define(['./_Set', './noop'], function(Set, noop) {
|
||||
define(['./_Set', './noop', './_setToArray'], function(Set, noop, setToArray) {
|
||||
|
||||
/** Used as references for various `Number` constants. */
|
||||
var INFINITY = 1 / 0;
|
||||
|
||||
/**
|
||||
* Creates a set of `values`.
|
||||
@@ -7,7 +10,7 @@ define(['./_Set', './noop'], function(Set, noop) {
|
||||
* @param {Array} values The values to add to the set.
|
||||
* @returns {Object} Returns the new set.
|
||||
*/
|
||||
var createSet = !(Set && new Set([1, 2]).size === 2) ? noop : function(values) {
|
||||
var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
|
||||
return new Set(values);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
define(['./_DataView', './_Map', './_Promise', './_Set', './_WeakMap', './_toSource'], function(DataView, Map, Promise, Set, WeakMap, toSource) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var mapTag = '[object Map]',
|
||||
objectTag = '[object Object]',
|
||||
@@ -46,8 +49,8 @@ define(['./_DataView', './_Map', './_Promise', './_Set', './_WeakMap', './_toSou
|
||||
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
|
||||
getTag = function(value) {
|
||||
var result = objectToString.call(value),
|
||||
Ctor = result == objectTag ? value.constructor : null,
|
||||
ctorString = toSource(Ctor);
|
||||
Ctor = result == objectTag ? value.constructor : undefined,
|
||||
ctorString = Ctor ? toSource(Ctor) : undefined;
|
||||
|
||||
if (ctorString) {
|
||||
switch (ctorString) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_baseCastPath', './isArguments', './isArray', './_isIndex', './_isKey', './isLength', './isString'], function(baseCastPath, isArguments, isArray, isIndex, isKey, isLength, isString) {
|
||||
define(['./_castPath', './isArguments', './isArray', './_isIndex', './_isKey', './isLength', './isString', './_toKey'], function(castPath, isArguments, isArray, isIndex, isKey, isLength, isString, toKey) {
|
||||
|
||||
/**
|
||||
* Checks if `path` exists on `object`.
|
||||
@@ -10,14 +10,14 @@ define(['./_baseCastPath', './isArguments', './isArray', './_isIndex', './_isKey
|
||||
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
||||
*/
|
||||
function hasPath(object, path, hasFunc) {
|
||||
path = isKey(path, object) ? [path] : baseCastPath(path);
|
||||
path = isKey(path, object) ? [path] : castPath(path);
|
||||
|
||||
var result,
|
||||
index = -1,
|
||||
length = path.length;
|
||||
|
||||
while (++index < length) {
|
||||
var key = path[index];
|
||||
var key = toKey(path[index]);
|
||||
if (!(result = object != null && hasFunc(object, key))) {
|
||||
break;
|
||||
}
|
||||
|
||||
15
_isFlattenable.js
Normal file
15
_isFlattenable.js
Normal file
@@ -0,0 +1,15 @@
|
||||
define(['./isArguments', './isArray', './isArrayLikeObject'], function(isArguments, isArray, isArrayLikeObject) {
|
||||
|
||||
/**
|
||||
* Checks if `value` is a flattenable `arguments` object or array.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
|
||||
*/
|
||||
function isFlattenable(value) {
|
||||
return isArrayLikeObject(value) && (isArray(value) || isArguments(value));
|
||||
}
|
||||
|
||||
return isFlattenable;
|
||||
});
|
||||
16
_isFlattenableIteratee.js
Normal file
16
_isFlattenableIteratee.js
Normal file
@@ -0,0 +1,16 @@
|
||||
define(['./isArray', './isFunction'], function(isArray, isFunction) {
|
||||
|
||||
/**
|
||||
* Checks if `value` is a flattenable array and not a `_.matchesProperty`
|
||||
* iteratee shorthand.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
|
||||
*/
|
||||
function isFlattenableIteratee(value) {
|
||||
return isArray(value) && !(value.length == 2 && !isFunction(value[0]));
|
||||
}
|
||||
|
||||
return isFlattenableIteratee;
|
||||
});
|
||||
@@ -15,9 +15,10 @@ define([], function() {
|
||||
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
||||
*/
|
||||
function isIndex(value, length) {
|
||||
value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
|
||||
length = length == null ? MAX_SAFE_INTEGER : length;
|
||||
return value > -1 && value % 1 == 0 && value < length;
|
||||
return !!length &&
|
||||
(typeof value == 'number' || reIsUint.test(value)) &&
|
||||
(value > -1 && value % 1 == 0 && value < length);
|
||||
}
|
||||
|
||||
return isIndex;
|
||||
|
||||
11
_isKey.js
11
_isKey.js
@@ -13,13 +13,16 @@ define(['./isArray', './isSymbol'], function(isArray, isSymbol) {
|
||||
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
|
||||
*/
|
||||
function isKey(value, object) {
|
||||
if (isArray(value)) {
|
||||
return false;
|
||||
}
|
||||
var type = typeof value;
|
||||
if (type == 'number' || type == 'symbol') {
|
||||
if (type == 'number' || type == 'symbol' || type == 'boolean' ||
|
||||
value == null || isSymbol(value)) {
|
||||
return true;
|
||||
}
|
||||
return !isArray(value) &&
|
||||
(isSymbol(value) || reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
|
||||
(object != null && value in Object(object)));
|
||||
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
|
||||
(object != null && value in Object(object));
|
||||
}
|
||||
|
||||
return isKey;
|
||||
|
||||
@@ -9,8 +9,9 @@ define([], function() {
|
||||
*/
|
||||
function isKeyable(value) {
|
||||
var type = typeof value;
|
||||
return type == 'number' || type == 'boolean' ||
|
||||
(type == 'string' && value != '__proto__') || value == null;
|
||||
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
|
||||
? (value !== '__proto__')
|
||||
: (value === null);
|
||||
}
|
||||
|
||||
return isKeyable;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_composeArgs', './_composeArgsRight', './_copyArray', './_replaceHolders'], function(composeArgs, composeArgsRight, copyArray, replaceHolders) {
|
||||
define(['./_composeArgs', './_composeArgsRight', './_replaceHolders'], function(composeArgs, composeArgsRight, replaceHolders) {
|
||||
|
||||
/** Used as the internal argument placeholder. */
|
||||
var PLACEHOLDER = '__lodash_placeholder__';
|
||||
@@ -55,20 +55,20 @@ define(['./_composeArgs', './_composeArgsRight', './_copyArray', './_replaceHold
|
||||
var value = source[3];
|
||||
if (value) {
|
||||
var partials = data[3];
|
||||
data[3] = partials ? composeArgs(partials, value, source[4]) : copyArray(value);
|
||||
data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : copyArray(source[4]);
|
||||
data[3] = partials ? composeArgs(partials, value, source[4]) : value;
|
||||
data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
|
||||
}
|
||||
// Compose partial right arguments.
|
||||
value = source[5];
|
||||
if (value) {
|
||||
partials = data[5];
|
||||
data[5] = partials ? composeArgsRight(partials, value, source[6]) : copyArray(value);
|
||||
data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : copyArray(source[6]);
|
||||
data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
|
||||
data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
|
||||
}
|
||||
// Use source `argPos` if available.
|
||||
value = source[7];
|
||||
if (value) {
|
||||
data[7] = copyArray(value);
|
||||
data[7] = value;
|
||||
}
|
||||
// Use source `ary` if it's smaller.
|
||||
if (srcBitmask & ARY_FLAG) {
|
||||
|
||||
16
_reHasComplexSymbol.js
Normal file
16
_reHasComplexSymbol.js
Normal file
@@ -0,0 +1,16 @@
|
||||
define([], function() {
|
||||
|
||||
/** Used to compose unicode character classes. */
|
||||
var rsAstralRange = '\\ud800-\\udfff',
|
||||
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
|
||||
rsComboSymbolsRange = '\\u20d0-\\u20f0',
|
||||
rsVarRange = '\\ufe0e\\ufe0f';
|
||||
|
||||
/** Used to compose unicode capture groups. */
|
||||
var rsZWJ = '\\u200d';
|
||||
|
||||
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
|
||||
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
|
||||
|
||||
return reHasComplexSymbol;
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
define([], function() {
|
||||
define(['./_reHasComplexSymbol'], function(reHasComplexSymbol) {
|
||||
|
||||
/** Used to compose unicode character classes. */
|
||||
var rsAstralRange = '\\ud800-\\udfff',
|
||||
@@ -26,9 +26,6 @@ define([], function() {
|
||||
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
|
||||
var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
|
||||
|
||||
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
|
||||
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
|
||||
|
||||
/**
|
||||
* Gets the number of symbols in `string`.
|
||||
*
|
||||
|
||||
22
_toKey.js
Normal file
22
_toKey.js
Normal file
@@ -0,0 +1,22 @@
|
||||
define(['./isSymbol'], function(isSymbol) {
|
||||
|
||||
/** Used as references for various `Number` constants. */
|
||||
var INFINITY = 1 / 0;
|
||||
|
||||
/**
|
||||
* Converts `value` to a string key if it's not a string or symbol.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to inspect.
|
||||
* @returns {string|symbol} Returns the key.
|
||||
*/
|
||||
function toKey(value) {
|
||||
if (typeof value == 'string' || isSymbol(value)) {
|
||||
return value;
|
||||
}
|
||||
var result = (value + '');
|
||||
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
||||
}
|
||||
|
||||
return toKey;
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./isFunction', './toString'], function(isFunction, toString) {
|
||||
define([], function() {
|
||||
|
||||
/** Used to resolve the decompiled source of functions. */
|
||||
var funcToString = Function.prototype.toString;
|
||||
@@ -11,12 +11,15 @@ define(['./isFunction', './toString'], function(isFunction, toString) {
|
||||
* @returns {string} Returns the source code.
|
||||
*/
|
||||
function toSource(func) {
|
||||
if (isFunction(func)) {
|
||||
if (func != null) {
|
||||
try {
|
||||
return funcToString.call(func);
|
||||
} catch (e) {}
|
||||
try {
|
||||
return (func + '');
|
||||
} catch (e) {}
|
||||
}
|
||||
return toString(func);
|
||||
return '';
|
||||
}
|
||||
|
||||
return toSource;
|
||||
|
||||
3
array.js
3
array.js
@@ -1,4 +1,4 @@
|
||||
define(['./chunk', './compact', './concat', './difference', './differenceBy', './differenceWith', './drop', './dropRight', './dropRightWhile', './dropWhile', './fill', './findIndex', './findLastIndex', './flatten', './flattenDeep', './flattenDepth', './fromPairs', './head', './indexOf', './initial', './intersection', './intersectionBy', './intersectionWith', './join', './last', './lastIndexOf', './pull', './pullAll', './pullAllBy', './pullAllWith', './pullAt', './remove', './reverse', './slice', './sortedIndex', './sortedIndexBy', './sortedIndexOf', './sortedLastIndex', './sortedLastIndexBy', './sortedLastIndexOf', './sortedUniq', './sortedUniqBy', './tail', './take', './takeRight', './takeRightWhile', './takeWhile', './union', './unionBy', './unionWith', './uniq', './uniqBy', './uniqWith', './unzip', './unzipWith', './without', './xor', './xorBy', './xorWith', './zip', './zipObject', './zipObjectDeep', './zipWith'], function(chunk, compact, concat, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, fill, findIndex, findLastIndex, flatten, flattenDeep, flattenDepth, fromPairs, head, indexOf, initial, intersection, intersectionBy, intersectionWith, join, last, lastIndexOf, pull, pullAll, pullAllBy, pullAllWith, pullAt, remove, reverse, slice, sortedIndex, sortedIndexBy, sortedIndexOf, sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf, sortedUniq, sortedUniqBy, tail, take, takeRight, takeRightWhile, takeWhile, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, without, xor, xorBy, xorWith, zip, zipObject, zipObjectDeep, zipWith) {
|
||||
define(['./chunk', './compact', './concat', './difference', './differenceBy', './differenceWith', './drop', './dropRight', './dropRightWhile', './dropWhile', './fill', './findIndex', './findLastIndex', './flatten', './flattenDeep', './flattenDepth', './fromPairs', './head', './indexOf', './initial', './intersection', './intersectionBy', './intersectionWith', './join', './last', './lastIndexOf', './nth', './pull', './pullAll', './pullAllBy', './pullAllWith', './pullAt', './remove', './reverse', './slice', './sortedIndex', './sortedIndexBy', './sortedIndexOf', './sortedLastIndex', './sortedLastIndexBy', './sortedLastIndexOf', './sortedUniq', './sortedUniqBy', './tail', './take', './takeRight', './takeRightWhile', './takeWhile', './union', './unionBy', './unionWith', './uniq', './uniqBy', './uniqWith', './unzip', './unzipWith', './without', './xor', './xorBy', './xorWith', './zip', './zipObject', './zipObjectDeep', './zipWith'], function(chunk, compact, concat, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, fill, findIndex, findLastIndex, flatten, flattenDeep, flattenDepth, fromPairs, head, indexOf, initial, intersection, intersectionBy, intersectionWith, join, last, lastIndexOf, nth, pull, pullAll, pullAllBy, pullAllWith, pullAt, remove, reverse, slice, sortedIndex, sortedIndexBy, sortedIndexOf, sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf, sortedUniq, sortedUniqBy, tail, take, takeRight, takeRightWhile, takeWhile, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, without, xor, xorBy, xorWith, zip, zipObject, zipObjectDeep, zipWith) {
|
||||
return {
|
||||
'chunk': chunk,
|
||||
'compact': compact,
|
||||
@@ -26,6 +26,7 @@ define(['./chunk', './compact', './concat', './difference', './differenceBy', '.
|
||||
'join': join,
|
||||
'last': last,
|
||||
'lastIndexOf': lastIndexOf,
|
||||
'nth': nth,
|
||||
'pull': pull,
|
||||
'pullAll': pullAll,
|
||||
'pullAllBy': pullAllBy,
|
||||
|
||||
@@ -27,6 +27,7 @@ define(['./_assignValue', './_copyObject', './_createAssigner', './isArrayLike',
|
||||
* @param {Object} object The destination object.
|
||||
* @param {...Object} [sources] The source objects.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @see _.assignIn
|
||||
* @example
|
||||
*
|
||||
* function Foo() {
|
||||
|
||||
@@ -23,6 +23,7 @@ define(['./_assignValue', './_copyObject', './_createAssigner', './isArrayLike',
|
||||
* @param {Object} object The destination object.
|
||||
* @param {...Object} [sources] The source objects.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @see _.assign
|
||||
* @example
|
||||
*
|
||||
* function Foo() {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
define(['./_copyObjectWith', './_createAssigner', './keysIn'], function(copyObjectWith, createAssigner, keysIn) {
|
||||
define(['./_copyObject', './_createAssigner', './keysIn'], function(copyObject, createAssigner, keysIn) {
|
||||
|
||||
/**
|
||||
* This method is like `_.assignIn` except that it accepts `customizer`
|
||||
* which is invoked to produce the assigned values. If `customizer` returns
|
||||
* `undefined` assignment is handled by the method instead. The `customizer`
|
||||
* `undefined`, assignment is handled by the method instead. The `customizer`
|
||||
* is invoked with five arguments: (objValue, srcValue, key, object, source).
|
||||
*
|
||||
* **Note:** This method mutates `object`.
|
||||
@@ -17,6 +17,7 @@ define(['./_copyObjectWith', './_createAssigner', './keysIn'], function(copyObje
|
||||
* @param {...Object} sources The source objects.
|
||||
* @param {Function} [customizer] The function to customize assigned values.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @see _.assignWith
|
||||
* @example
|
||||
*
|
||||
* function customizer(objValue, srcValue) {
|
||||
@@ -29,7 +30,7 @@ define(['./_copyObjectWith', './_createAssigner', './keysIn'], function(copyObje
|
||||
* // => { 'a': 1, 'b': 2 }
|
||||
*/
|
||||
var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
|
||||
copyObjectWith(source, keysIn(source), object, customizer);
|
||||
copyObject(source, keysIn(source), object, customizer);
|
||||
});
|
||||
|
||||
return assignInWith;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
define(['./_copyObjectWith', './_createAssigner', './keys'], function(copyObjectWith, createAssigner, keys) {
|
||||
define(['./_copyObject', './_createAssigner', './keys'], function(copyObject, createAssigner, keys) {
|
||||
|
||||
/**
|
||||
* This method is like `_.assign` except that it accepts `customizer`
|
||||
* which is invoked to produce the assigned values. If `customizer` returns
|
||||
* `undefined` assignment is handled by the method instead. The `customizer`
|
||||
* `undefined`, assignment is handled by the method instead. The `customizer`
|
||||
* is invoked with five arguments: (objValue, srcValue, key, object, source).
|
||||
*
|
||||
* **Note:** This method mutates `object`.
|
||||
@@ -16,6 +16,7 @@ define(['./_copyObjectWith', './_createAssigner', './keys'], function(copyObject
|
||||
* @param {...Object} sources The source objects.
|
||||
* @param {Function} [customizer] The function to customize assigned values.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @see _.assignInWith
|
||||
* @example
|
||||
*
|
||||
* function customizer(objValue, srcValue) {
|
||||
@@ -28,7 +29,7 @@ define(['./_copyObjectWith', './_createAssigner', './keys'], function(copyObject
|
||||
* // => { 'a': 1, 'b': 2 }
|
||||
*/
|
||||
var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
|
||||
copyObjectWith(source, keys(source), object, customizer);
|
||||
copyObject(source, keys(source), object, customizer);
|
||||
});
|
||||
|
||||
return assignWith;
|
||||
|
||||
3
at.js
3
at.js
@@ -8,8 +8,7 @@ define(['./_baseAt', './_baseFlatten', './rest'], function(baseAt, baseFlatten,
|
||||
* @since 1.0.0
|
||||
* @category Object
|
||||
* @param {Object} object The object to iterate over.
|
||||
* @param {...(string|string[])} [paths] The property paths of elements to pick,
|
||||
* specified individually or in arrays.
|
||||
* @param {...(string|string[])} [paths] The property paths of elements to pick.
|
||||
* @returns {Array} Returns the new array of picked elements.
|
||||
* @example
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_arrayEach', './_baseFlatten', './bind', './rest'], function(arrayEach, baseFlatten, bind, rest) {
|
||||
define(['./_arrayEach', './_baseFlatten', './bind', './rest', './_toKey'], function(arrayEach, baseFlatten, bind, rest, toKey) {
|
||||
|
||||
/**
|
||||
* Binds methods of an object to the object itself, overwriting the existing
|
||||
@@ -11,8 +11,7 @@ define(['./_arrayEach', './_baseFlatten', './bind', './rest'], function(arrayEac
|
||||
* @memberOf _
|
||||
* @category Util
|
||||
* @param {Object} object The object to bind and assign the bound methods to.
|
||||
* @param {...(string|string[])} methodNames The object method names to bind,
|
||||
* specified individually or in arrays.
|
||||
* @param {...(string|string[])} methodNames The object method names to bind.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @example
|
||||
*
|
||||
@@ -29,6 +28,7 @@ define(['./_arrayEach', './_baseFlatten', './bind', './rest'], function(arrayEac
|
||||
*/
|
||||
var bindAll = rest(function(object, methodNames) {
|
||||
arrayEach(baseFlatten(methodNames, 1), function(key) {
|
||||
key = toKey(key);
|
||||
object[key] = bind(object[key], object);
|
||||
});
|
||||
return object;
|
||||
|
||||
1
clone.js
1
clone.js
@@ -17,6 +17,7 @@ define(['./_baseClone'], function(baseClone) {
|
||||
* @category Lang
|
||||
* @param {*} value The value to clone.
|
||||
* @returns {*} Returns the cloned value.
|
||||
* @see _.cloneDeep
|
||||
* @example
|
||||
*
|
||||
* var objects = [{ 'a': 1 }, { 'b': 2 }];
|
||||
|
||||
@@ -9,6 +9,7 @@ define(['./_baseClone'], function(baseClone) {
|
||||
* @category Lang
|
||||
* @param {*} value The value to recursively clone.
|
||||
* @returns {*} Returns the deep cloned value.
|
||||
* @see _.clone
|
||||
* @example
|
||||
*
|
||||
* var objects = [{ 'a': 1 }, { 'b': 2 }];
|
||||
|
||||
@@ -10,6 +10,7 @@ define(['./_baseClone'], function(baseClone) {
|
||||
* @param {*} value The value to recursively clone.
|
||||
* @param {Function} [customizer] The function to customize cloning.
|
||||
* @returns {*} Returns the deep cloned value.
|
||||
* @see _.cloneWith
|
||||
* @example
|
||||
*
|
||||
* function customizer(value) {
|
||||
|
||||
@@ -2,7 +2,7 @@ define(['./_baseClone'], function(baseClone) {
|
||||
|
||||
/**
|
||||
* This method is like `_.clone` except that it accepts `customizer` which
|
||||
* is invoked to produce the cloned value. If `customizer` returns `undefined`
|
||||
* is invoked to produce the cloned value. If `customizer` returns `undefined`,
|
||||
* cloning is handled by the method instead. The `customizer` is invoked with
|
||||
* up to four arguments; (value [, index|key, object, stack]).
|
||||
*
|
||||
@@ -13,6 +13,7 @@ define(['./_baseClone'], function(baseClone) {
|
||||
* @param {*} value The value to clone.
|
||||
* @param {Function} [customizer] The function to customize cloning.
|
||||
* @returns {*} Returns the cloned value.
|
||||
* @see _.cloneDeepWith
|
||||
* @example
|
||||
*
|
||||
* function customizer(value) {
|
||||
|
||||
2
cond.js
2
cond.js
@@ -4,7 +4,7 @@ define(['./_apply', './_arrayMap', './_baseIteratee', './rest'], function(apply,
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/**
|
||||
* Creates a function that iterates over `pairs` invoking the corresponding
|
||||
* Creates a function that iterates over `pairs` and invokes the corresponding
|
||||
* function of the first predicate to return truthy. The predicate-function
|
||||
* pairs are invoked with the `this` binding and arguments of the created
|
||||
* function.
|
||||
|
||||
@@ -2,7 +2,7 @@ define(['./_baseAssign', './_baseCreate'], function(baseAssign, baseCreate) {
|
||||
|
||||
/**
|
||||
* Creates an object that inherits from the `prototype` object. If a
|
||||
* `properties` object is given its own enumerable string keyed properties
|
||||
* `properties` object is given, its own enumerable string keyed properties
|
||||
* are assigned to the created object.
|
||||
*
|
||||
* @static
|
||||
|
||||
23
debounce.js
23
debounce.js
@@ -24,7 +24,7 @@ define(['./isObject', './now', './toNumber'], function(isObject, now, toNumber)
|
||||
* on the trailing edge of the timeout only if the debounced function is
|
||||
* invoked more than once during the `wait` timeout.
|
||||
*
|
||||
* See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)
|
||||
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
||||
* for details over the differences between `_.debounce` and `_.throttle`.
|
||||
*
|
||||
* @static
|
||||
@@ -63,12 +63,13 @@ define(['./isObject', './now', './toNumber'], function(isObject, now, toNumber)
|
||||
function debounce(func, wait, options) {
|
||||
var lastArgs,
|
||||
lastThis,
|
||||
maxWait,
|
||||
result,
|
||||
timerId,
|
||||
lastCallTime = 0,
|
||||
lastInvokeTime = 0,
|
||||
leading = false,
|
||||
maxWait = false,
|
||||
maxing = false,
|
||||
trailing = true;
|
||||
|
||||
if (typeof func != 'function') {
|
||||
@@ -77,7 +78,8 @@ define(['./isObject', './now', './toNumber'], function(isObject, now, toNumber)
|
||||
wait = toNumber(wait) || 0;
|
||||
if (isObject(options)) {
|
||||
leading = !!options.leading;
|
||||
maxWait = 'maxWait' in options && nativeMax(toNumber(options.maxWait) || 0, wait);
|
||||
maxing = 'maxWait' in options;
|
||||
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
||||
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
||||
}
|
||||
|
||||
@@ -105,7 +107,7 @@ define(['./isObject', './now', './toNumber'], function(isObject, now, toNumber)
|
||||
timeSinceLastInvoke = time - lastInvokeTime,
|
||||
result = wait - timeSinceLastCall;
|
||||
|
||||
return maxWait === false ? result : nativeMin(result, maxWait - timeSinceLastInvoke);
|
||||
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
|
||||
}
|
||||
|
||||
function shouldInvoke(time) {
|
||||
@@ -116,7 +118,7 @@ define(['./isObject', './now', './toNumber'], function(isObject, now, toNumber)
|
||||
// trailing edge, the system time has gone backwards and we're treating
|
||||
// it as the trailing edge, or we've hit the `maxWait` limit.
|
||||
return (!lastCallTime || (timeSinceLastCall >= wait) ||
|
||||
(timeSinceLastCall < 0) || (maxWait !== false && timeSinceLastInvoke >= maxWait));
|
||||
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
|
||||
}
|
||||
|
||||
function timerExpired() {
|
||||
@@ -165,10 +167,15 @@ define(['./isObject', './now', './toNumber'], function(isObject, now, toNumber)
|
||||
if (timerId === undefined) {
|
||||
return leadingEdge(lastCallTime);
|
||||
}
|
||||
// Handle invocations in a tight loop.
|
||||
clearTimeout(timerId);
|
||||
if (maxing) {
|
||||
// Handle invocations in a tight loop.
|
||||
clearTimeout(timerId);
|
||||
timerId = setTimeout(timerExpired, wait);
|
||||
return invokeFunc(lastCallTime);
|
||||
}
|
||||
}
|
||||
if (timerId === undefined) {
|
||||
timerId = setTimeout(timerExpired, wait);
|
||||
return invokeFunc(lastCallTime);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ define(['./_apply', './_assignInDefaults', './assignInWith', './rest'], function
|
||||
* @param {Object} object The destination object.
|
||||
* @param {...Object} [sources] The source objects.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @see _.defaultsDeep
|
||||
* @example
|
||||
*
|
||||
* _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
|
||||
|
||||
@@ -16,6 +16,7 @@ define(['./_apply', './_mergeDefaults', './mergeWith', './rest'], function(apply
|
||||
* @param {Object} object The destination object.
|
||||
* @param {...Object} [sources] The source objects.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @see _.defaults
|
||||
* @example
|
||||
*
|
||||
* _.defaultsDeep({ 'user': { 'name': 'barney' } }, { 'user': { 'name': 'fred', 'age': 36 } });
|
||||
|
||||
@@ -13,6 +13,7 @@ define(['./_baseDifference', './_baseFlatten', './isArrayLikeObject', './rest'],
|
||||
* @param {Array} array The array to inspect.
|
||||
* @param {...Array} [values] The values to exclude.
|
||||
* @returns {Array} Returns the new array of filtered values.
|
||||
* @see _.without, _.xor
|
||||
* @example
|
||||
*
|
||||
* _.difference([3, 2, 1], [4, 2]);
|
||||
@@ -20,7 +21,7 @@ define(['./_baseDifference', './_baseFlatten', './isArrayLikeObject', './rest'],
|
||||
*/
|
||||
var difference = rest(function(array, values) {
|
||||
return isArrayLikeObject(array)
|
||||
? baseDifference(array, baseFlatten(values, 1, true))
|
||||
? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
|
||||
: [];
|
||||
});
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ define(['./_baseDifference', './_baseFlatten', './_baseIteratee', './isArrayLike
|
||||
iteratee = undefined;
|
||||
}
|
||||
return isArrayLikeObject(array)
|
||||
? baseDifference(array, baseFlatten(values, 1, true), baseIteratee(iteratee))
|
||||
? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), baseIteratee(iteratee))
|
||||
: [];
|
||||
});
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ define(['./_baseDifference', './_baseFlatten', './isArrayLikeObject', './last',
|
||||
comparator = undefined;
|
||||
}
|
||||
return isArrayLikeObject(array)
|
||||
? baseDifference(array, baseFlatten(values, 1, true), undefined, comparator)
|
||||
? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
|
||||
: [];
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_baseClamp', './toInteger', './toString'], function(baseClamp, toInteger, toString) {
|
||||
define(['./_baseClamp', './_baseToString', './toInteger', './toString'], function(baseClamp, baseToString, toInteger, toString) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -28,7 +28,7 @@ define(['./_baseClamp', './toInteger', './toString'], function(baseClamp, toInte
|
||||
*/
|
||||
function endsWith(string, target, position) {
|
||||
string = toString(string);
|
||||
target = typeof target == 'string' ? target : (target + '');
|
||||
target = baseToString(target);
|
||||
|
||||
var length = string.length;
|
||||
position = position === undefined
|
||||
|
||||
@@ -13,6 +13,7 @@ define(['./_arrayFilter', './_baseFilter', './_baseIteratee', './isArray'], func
|
||||
* @param {Array|Function|Object|string} [predicate=_.identity]
|
||||
* The function invoked per iteration.
|
||||
* @returns {Array} Returns the new filtered array.
|
||||
* @see _.reject
|
||||
* @example
|
||||
*
|
||||
* var users = [
|
||||
|
||||
1
flow.js
1
flow.js
@@ -11,6 +11,7 @@ define(['./_createFlow'], function(createFlow) {
|
||||
* @category Util
|
||||
* @param {...(Function|Function[])} [funcs] Functions to invoke.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @see _.flowRight
|
||||
* @example
|
||||
*
|
||||
* function square(n) {
|
||||
|
||||
@@ -5,11 +5,12 @@ define(['./_createFlow'], function(createFlow) {
|
||||
* invokes the given functions from right to left.
|
||||
*
|
||||
* @static
|
||||
* @since 0.1.0
|
||||
* @since 3.0.0
|
||||
* @memberOf _
|
||||
* @category Util
|
||||
* @param {...(Function|Function[])} [funcs] Functions to invoke.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @see _.flow
|
||||
* @example
|
||||
*
|
||||
* function square(n) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
define(['./_arrayEach', './_baseEach', './_baseIteratee', './isArray'], function(arrayEach, baseEach, baseIteratee, isArray) {
|
||||
|
||||
/**
|
||||
* Iterates over elements of `collection` invoking `iteratee` for each element.
|
||||
* Iterates over elements of `collection` and invokes `iteratee` for each element.
|
||||
* The iteratee is invoked with three arguments: (value, index|key, collection).
|
||||
* Iteratee functions may exit iteration early by explicitly returning `false`.
|
||||
*
|
||||
@@ -17,6 +17,7 @@ define(['./_arrayEach', './_baseEach', './_baseIteratee', './isArray'], function
|
||||
* @param {Array|Object} collection The collection to iterate over.
|
||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||||
* @returns {Array|Object} Returns `collection`.
|
||||
* @see _.forEachRight
|
||||
* @example
|
||||
*
|
||||
* _([1, 2]).forEach(function(value) {
|
||||
|
||||
@@ -12,6 +12,7 @@ define(['./_arrayEachRight', './_baseEachRight', './_baseIteratee', './isArray']
|
||||
* @param {Array|Object} collection The collection to iterate over.
|
||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||||
* @returns {Array|Object} Returns `collection`.
|
||||
* @see _.forEach
|
||||
* @example
|
||||
*
|
||||
* _.forEachRight([1, 2], function(value) {
|
||||
|
||||
7
forIn.js
7
forIn.js
@@ -2,9 +2,9 @@ define(['./_baseFor', './_baseIteratee', './keysIn'], function(baseFor, baseIter
|
||||
|
||||
/**
|
||||
* Iterates over own and inherited enumerable string keyed properties of an
|
||||
* object invoking `iteratee` for each property. The iteratee is invoked with
|
||||
* three arguments: (value, key, object). Iteratee functions may exit iteration
|
||||
* early by explicitly returning `false`.
|
||||
* object and invokes `iteratee` for each property. The iteratee is invoked
|
||||
* with three arguments: (value, key, object). Iteratee functions may exit
|
||||
* iteration early by explicitly returning `false`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -13,6 +13,7 @@ define(['./_baseFor', './_baseIteratee', './keysIn'], function(baseFor, baseIter
|
||||
* @param {Object} object The object to iterate over.
|
||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @see _.forInRight
|
||||
* @example
|
||||
*
|
||||
* function Foo() {
|
||||
|
||||
@@ -11,6 +11,7 @@ define(['./_baseForRight', './_baseIteratee', './keysIn'], function(baseForRight
|
||||
* @param {Object} object The object to iterate over.
|
||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @see _.forIn
|
||||
* @example
|
||||
*
|
||||
* function Foo() {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
define(['./_baseForOwn', './_baseIteratee'], function(baseForOwn, baseIteratee) {
|
||||
|
||||
/**
|
||||
* Iterates over own enumerable string keyed properties of an object invoking
|
||||
* `iteratee` for each property. The iteratee is invoked with three arguments:
|
||||
* (value, key, object). Iteratee functions may exit iteration early by
|
||||
* explicitly returning `false`.
|
||||
* Iterates over own enumerable string keyed properties of an object and
|
||||
* invokes `iteratee` for each property. The iteratee is invoked with three
|
||||
* arguments: (value, key, object). Iteratee functions may exit iteration
|
||||
* early by explicitly returning `false`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
@@ -13,6 +13,7 @@ define(['./_baseForOwn', './_baseIteratee'], function(baseForOwn, baseIteratee)
|
||||
* @param {Object} object The object to iterate over.
|
||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @see _.forOwnRight
|
||||
* @example
|
||||
*
|
||||
* function Foo() {
|
||||
|
||||
@@ -11,6 +11,7 @@ define(['./_baseForOwnRight', './_baseIteratee'], function(baseForOwnRight, base
|
||||
* @param {Object} object The object to iterate over.
|
||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @see _.forOwn
|
||||
* @example
|
||||
*
|
||||
* function Foo() {
|
||||
|
||||
@@ -10,6 +10,7 @@ define(['./_baseFunctions', './keys'], function(baseFunctions, keys) {
|
||||
* @category Object
|
||||
* @param {Object} object The object to inspect.
|
||||
* @returns {Array} Returns the new array of property names.
|
||||
* @see _.functionsIn
|
||||
* @example
|
||||
*
|
||||
* function Foo() {
|
||||
|
||||
@@ -10,6 +10,7 @@ define(['./_baseFunctions', './keysIn'], function(baseFunctions, keysIn) {
|
||||
* @category Object
|
||||
* @param {Object} object The object to inspect.
|
||||
* @returns {Array} Returns the new array of property names.
|
||||
* @see _.functions
|
||||
* @example
|
||||
*
|
||||
* function Foo() {
|
||||
|
||||
2
get.js
2
get.js
@@ -5,7 +5,7 @@ define(['./_baseGet'], function(baseGet) {
|
||||
|
||||
/**
|
||||
* Gets the value at `path` of `object`. If the resolved value is
|
||||
* `undefined` the `defaultValue` is used in its place.
|
||||
* `undefined`, the `defaultValue` is used in its place.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -8,9 +8,10 @@ define(['./_createAggregator'], function(createAggregator) {
|
||||
|
||||
/**
|
||||
* Creates an object composed of keys generated from the results of running
|
||||
* each element of `collection` thru `iteratee`. The corresponding value of
|
||||
* each key is an array of elements responsible for generating the key. The
|
||||
* iteratee is invoked with one argument: (value).
|
||||
* each element of `collection` thru `iteratee`. The order of grouped values
|
||||
* is determined by the order they occur in `collection`. The corresponding
|
||||
* value of each key is an array of elements responsible for generating the
|
||||
* key. The iteratee is invoked with one argument: (value).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
7
gt.js
7
gt.js
@@ -1,4 +1,4 @@
|
||||
define([], function() {
|
||||
define(['./_baseGt', './_createRelationalOperation'], function(baseGt, createRelationalOperation) {
|
||||
|
||||
/**
|
||||
* Checks if `value` is greater than `other`.
|
||||
@@ -11,6 +11,7 @@ define([], function() {
|
||||
* @param {*} other The other value to compare.
|
||||
* @returns {boolean} Returns `true` if `value` is greater than `other`,
|
||||
* else `false`.
|
||||
* @see _.lt
|
||||
* @example
|
||||
*
|
||||
* _.gt(3, 1);
|
||||
@@ -22,9 +23,7 @@ define([], function() {
|
||||
* _.gt(1, 3);
|
||||
* // => false
|
||||
*/
|
||||
function gt(value, other) {
|
||||
return value > other;
|
||||
}
|
||||
var gt = createRelationalOperation(baseGt);
|
||||
|
||||
return gt;
|
||||
});
|
||||
|
||||
7
gte.js
7
gte.js
@@ -1,4 +1,4 @@
|
||||
define([], function() {
|
||||
define(['./_createRelationalOperation'], function(createRelationalOperation) {
|
||||
|
||||
/**
|
||||
* Checks if `value` is greater than or equal to `other`.
|
||||
@@ -11,6 +11,7 @@ define([], function() {
|
||||
* @param {*} other The other value to compare.
|
||||
* @returns {boolean} Returns `true` if `value` is greater than or equal to
|
||||
* `other`, else `false`.
|
||||
* @see _.lte
|
||||
* @example
|
||||
*
|
||||
* _.gte(3, 1);
|
||||
@@ -22,9 +23,9 @@ define([], function() {
|
||||
* _.gte(1, 3);
|
||||
* // => false
|
||||
*/
|
||||
function gte(value, other) {
|
||||
var gte = createRelationalOperation(function(value, other) {
|
||||
return value >= other;
|
||||
}
|
||||
});
|
||||
|
||||
return gte;
|
||||
});
|
||||
|
||||
8
has.js
8
has.js
@@ -12,16 +12,16 @@ define(['./_baseHas', './_hasPath'], function(baseHas, hasPath) {
|
||||
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': { 'b': { 'c': 3 } } };
|
||||
* var other = _.create({ 'a': _.create({ 'b': _.create({ 'c': 3 }) }) });
|
||||
* var object = { 'a': { 'b': 2 } };
|
||||
* var other = _.create({ 'a': _.create({ 'b': 2 }) });
|
||||
*
|
||||
* _.has(object, 'a');
|
||||
* // => true
|
||||
*
|
||||
* _.has(object, 'a.b.c');
|
||||
* _.has(object, 'a.b');
|
||||
* // => true
|
||||
*
|
||||
* _.has(object, ['a', 'b', 'c']);
|
||||
* _.has(object, ['a', 'b']);
|
||||
* // => true
|
||||
*
|
||||
* _.has(other, 'a');
|
||||
|
||||
6
hasIn.js
6
hasIn.js
@@ -12,15 +12,15 @@ define(['./_baseHasIn', './_hasPath'], function(baseHasIn, hasPath) {
|
||||
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
||||
* @example
|
||||
*
|
||||
* var object = _.create({ 'a': _.create({ 'b': _.create({ 'c': 3 }) }) });
|
||||
* var object = _.create({ 'a': _.create({ 'b': 2 }) });
|
||||
*
|
||||
* _.hasIn(object, 'a');
|
||||
* // => true
|
||||
*
|
||||
* _.hasIn(object, 'a.b.c');
|
||||
* _.hasIn(object, 'a.b');
|
||||
* // => true
|
||||
*
|
||||
* _.hasIn(object, ['a', 'b', 'c']);
|
||||
* _.hasIn(object, ['a', 'b']);
|
||||
* // => true
|
||||
*
|
||||
* _.hasIn(object, 'b');
|
||||
|
||||
2
head.js
2
head.js
@@ -22,7 +22,7 @@ define([], function() {
|
||||
* // => undefined
|
||||
*/
|
||||
function head(array) {
|
||||
return array ? array[0] : undefined;
|
||||
return (array && array.length) ? array[0] : undefined;
|
||||
}
|
||||
|
||||
return head;
|
||||
|
||||
@@ -4,8 +4,8 @@ define(['./_baseInRange', './toNumber'], function(baseInRange, toNumber) {
|
||||
var undefined;
|
||||
|
||||
/**
|
||||
* 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`.
|
||||
* 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`.
|
||||
* If `start` is greater than `end` the params are swapped to support
|
||||
* negative ranges.
|
||||
*
|
||||
@@ -17,6 +17,7 @@ define(['./_baseInRange', './toNumber'], function(baseInRange, toNumber) {
|
||||
* @param {number} [start=0] The start of the range.
|
||||
* @param {number} end The end of the range.
|
||||
* @returns {boolean} Returns `true` if `number` is in the range, else `false`.
|
||||
* @see _.range, _.rangeRight
|
||||
* @example
|
||||
*
|
||||
* _.inRange(3, 2, 4);
|
||||
|
||||
@@ -4,7 +4,7 @@ define(['./_baseIndexOf', './isArrayLike', './isString', './toInteger', './value
|
||||
var nativeMax = Math.max;
|
||||
|
||||
/**
|
||||
* Checks if `value` is in `collection`. If `collection` is a string it's
|
||||
* Checks if `value` is in `collection`. If `collection` is a string, it's
|
||||
* checked for a substring of `value`, otherwise
|
||||
* [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
|
||||
* is used for equality comparisons. If `fromIndex` is negative, it's used as
|
||||
|
||||
@@ -6,8 +6,8 @@ define(['./_baseIndexOf', './toInteger'], function(baseIndexOf, toInteger) {
|
||||
/**
|
||||
* Gets the index at which the first occurrence of `value` is found in `array`
|
||||
* using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
|
||||
* for equality comparisons. If `fromIndex` is negative, it's used as the offset
|
||||
* from the end of `array`.
|
||||
* for equality comparisons. If `fromIndex` is negative, it's used as the
|
||||
* offset from the end of `array`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './rest'], function(arrayMap, baseCastArrayLikeObject, baseIntersection, rest) {
|
||||
define(['./_arrayMap', './_baseIntersection', './_castArrayLikeObject', './rest'], function(arrayMap, baseIntersection, castArrayLikeObject, rest) {
|
||||
|
||||
/**
|
||||
* Creates an array of unique values that are included in all given arrays
|
||||
@@ -18,7 +18,7 @@ define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './r
|
||||
* // => [2]
|
||||
*/
|
||||
var intersection = rest(function(arrays) {
|
||||
var mapped = arrayMap(arrays, baseCastArrayLikeObject);
|
||||
var mapped = arrayMap(arrays, castArrayLikeObject);
|
||||
return (mapped.length && mapped[0] === arrays[0])
|
||||
? baseIntersection(mapped)
|
||||
: [];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './_baseIteratee', './last', './rest'], function(arrayMap, baseCastArrayLikeObject, baseIntersection, baseIteratee, last, rest) {
|
||||
define(['./_arrayMap', './_baseIntersection', './_baseIteratee', './_castArrayLikeObject', './last', './rest'], function(arrayMap, baseIntersection, baseIteratee, castArrayLikeObject, last, rest) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -28,7 +28,7 @@ define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './_
|
||||
*/
|
||||
var intersectionBy = rest(function(arrays) {
|
||||
var iteratee = last(arrays),
|
||||
mapped = arrayMap(arrays, baseCastArrayLikeObject);
|
||||
mapped = arrayMap(arrays, castArrayLikeObject);
|
||||
|
||||
if (iteratee === last(mapped)) {
|
||||
iteratee = undefined;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './last', './rest'], function(arrayMap, baseCastArrayLikeObject, baseIntersection, last, rest) {
|
||||
define(['./_arrayMap', './_baseIntersection', './_castArrayLikeObject', './last', './rest'], function(arrayMap, baseIntersection, castArrayLikeObject, last, rest) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -26,7 +26,7 @@ define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './l
|
||||
*/
|
||||
var intersectionWith = rest(function(arrays) {
|
||||
var comparator = last(arrays),
|
||||
mapped = arrayMap(arrays, baseCastArrayLikeObject);
|
||||
mapped = arrayMap(arrays, castArrayLikeObject);
|
||||
|
||||
if (comparator === last(mapped)) {
|
||||
comparator = undefined;
|
||||
|
||||
@@ -6,8 +6,8 @@ define(['./_apply', './_baseEach', './_baseInvoke', './isArrayLike', './_isKey',
|
||||
/**
|
||||
* Invokes the method at `path` of each element in `collection`, returning
|
||||
* an array of the results of each invoked method. Any additional arguments
|
||||
* are provided to each invoked method. If `methodName` is a function it's
|
||||
* invoked for, and `this` bound to, each element in `collection`.
|
||||
* are provided to each invoked method. If `methodName` is a function, it's
|
||||
* invoked for and `this` bound to, each element in `collection`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
|
||||
@@ -5,7 +5,7 @@ define(['./_baseIsEqual'], function(baseIsEqual) {
|
||||
|
||||
/**
|
||||
* This method is like `_.isEqual` except that it accepts `customizer` which
|
||||
* is invoked to compare values. If `customizer` returns `undefined` comparisons
|
||||
* is invoked to compare values. If `customizer` returns `undefined`, comparisons
|
||||
* are handled by the method instead. The `customizer` is invoked with up to
|
||||
* six arguments: (objValue, othValue [, index|key, object, other, stack]).
|
||||
*
|
||||
|
||||
@@ -5,7 +5,7 @@ define(['./_baseIsMatch', './_getMatchData'], function(baseIsMatch, getMatchData
|
||||
|
||||
/**
|
||||
* This method is like `_.isMatch` except that it accepts `customizer` which
|
||||
* is invoked to compare values. If `customizer` returns `undefined` comparisons
|
||||
* is invoked to compare values. If `customizer` returns `undefined`, comparisons
|
||||
* are handled by the method instead. The `customizer` is invoked with five
|
||||
* arguments: (objValue, srcValue, index|key, object, source).
|
||||
*
|
||||
|
||||
@@ -2,8 +2,8 @@ define(['./_baseClone', './_baseIteratee'], function(baseClone, baseIteratee) {
|
||||
|
||||
/**
|
||||
* Creates a function that invokes `func` with the arguments of the created
|
||||
* function. If `func` is a property name the created function returns the
|
||||
* property value for a given element. If `func` is an array or object the
|
||||
* function. If `func` is a property name, the created function returns the
|
||||
* property value for a given element. If `func` is an array or object, the
|
||||
* created function returns `true` for elements that contain the equivalent
|
||||
* source properties, otherwise it returns `false`.
|
||||
*
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user