Compare commits

...

4 Commits

Author SHA1 Message Date
John-David Dalton
cbf5cb1162 Bump to v4.14.2. 2016-08-07 21:23:34 -07:00
John-David Dalton
6d4f76888f Bump to v4.14.1. 2016-07-28 23:40:26 -07:00
John-David Dalton
51ed7e7707 Bump to v4.14.0. 2016-07-24 09:52:22 -07:00
John-David Dalton
6b3e0da93c Bump to v4.13.1. 2016-05-23 12:31:09 -07:00
273 changed files with 1413 additions and 1083 deletions

View File

@@ -1,4 +1,4 @@
# lodash-es v4.13.0 # lodash-es v4.14.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.13.0-es) for more details. See the [package source](https://github.com/lodash/lodash/tree/4.14.2-es) for more details.

View File

@@ -1,6 +0,0 @@
import root from './_root.js';
/** Built-in value references. */
var Reflect = root.Reflect;
export default Reflect;

View File

@@ -7,7 +7,7 @@
* @returns {Object} Returns `map`. * @returns {Object} Returns `map`.
*/ */
function addMapEntry(map, pair) { function addMapEntry(map, pair) {
// Don't return `Map#set` because it doesn't return the map instance in IE 11. // Don't return `map.set` because it's not chainable in IE 11.
map.set(pair[0], pair[1]); map.set(pair[0], pair[1]);
return map; return map;
} }

View File

@@ -7,6 +7,7 @@
* @returns {Object} Returns `set`. * @returns {Object} Returns `set`.
*/ */
function addSetEntry(set, value) { function addSetEntry(set, value) {
// Don't return `set.add` because it's not chainable in IE 11.
set.add(value); set.add(value);
return set; return set;
} }

View File

@@ -9,8 +9,7 @@
* @returns {*} Returns the result of `func`. * @returns {*} Returns the result of `func`.
*/ */
function apply(func, thisArg, args) { function apply(func, thisArg, args) {
var length = args.length; switch (args.length) {
switch (length) {
case 0: return func.call(thisArg); case 0: return func.call(thisArg);
case 1: return func.call(thisArg, args[0]); case 1: return func.call(thisArg, args[0]);
case 2: return func.call(thisArg, args[0], args[1]); case 2: return func.call(thisArg, args[0], args[1]);

38
_arrayLikeKeys.js Normal file
View File

@@ -0,0 +1,38 @@
import baseTimes from './_baseTimes.js';
import isArguments from './isArguments.js';
import isArray from './isArray.js';
import isIndex from './_isIndex.js';
import isString from './isString.js';
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Creates an array of the enumerable property names of the array-like `value`.
*
* @private
* @param {*} value The value to query.
* @param {boolean} inherited Specify returning inherited property names.
* @returns {Array} Returns the array of property names.
*/
function arrayLikeKeys(value, inherited) {
var result = (isArray(value) || isString(value) || isArguments(value))
? baseTimes(value.length, String)
: [];
var length = result.length,
skipIndexes = !!length;
for (var key in value) {
if ((inherited || hasOwnProperty.call(value, key)) &&
!(skipIndexes && (key == 'length' || isIndex(key, length)))) {
result.push(key);
}
}
return result;
}
export default arrayLikeKeys;

View File

@@ -8,7 +8,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
/** /**
* Assigns `value` to `key` of `object` if the existing value is not equivalent * Assigns `value` to `key` of `object` if the existing value is not equivalent
* using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons. * for equality comparisons.
* *
* @private * @private

View File

@@ -1,5 +1,5 @@
/** /**
* The base implementation of `_.clamp` which doesn't coerce arguments to numbers. * The base implementation of `_.clamp` which doesn't coerce arguments.
* *
* @private * @private
* @param {number} number The number to clamp. * @param {number} number The number to clamp.

View File

@@ -125,12 +125,12 @@ function baseClone(value, isDeep, isFull, customizer, key, object, stack) {
if (!isArr) { if (!isArr) {
var props = isFull ? getAllKeys(value) : keys(value); var props = isFull ? getAllKeys(value) : keys(value);
} }
// Recursively populate clone (susceptible to call stack limits).
arrayEach(props || value, function(subValue, key) { arrayEach(props || value, function(subValue, key) {
if (props) { if (props) {
key = subValue; key = subValue;
subValue = value[key]; subValue = value[key];
} }
// Recursively populate clone (susceptible to call stack limits).
assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack)); assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack));
}); });
return result; return result;

View File

@@ -1,3 +1,4 @@
import baseConformsTo from './_baseConformsTo.js';
import keys from './keys.js'; import keys from './keys.js';
/** /**
@@ -8,25 +9,9 @@ import keys from './keys.js';
* @returns {Function} Returns the new spec function. * @returns {Function} Returns the new spec function.
*/ */
function baseConforms(source) { function baseConforms(source) {
var props = keys(source), var props = keys(source);
length = props.length;
return function(object) { return function(object) {
if (object == null) { return baseConformsTo(object, source, props);
return !length;
}
var index = length;
while (index--) {
var key = props[index],
predicate = source[key],
value = object[key];
if ((value === undefined &&
!(key in Object(object))) || !predicate(value)) {
return false;
}
}
return true;
}; };
} }

27
_baseConformsTo.js Normal file
View File

@@ -0,0 +1,27 @@
/**
* The base implementation of `_.conformsTo` which accepts `props` to check.
*
* @private
* @param {Object} object The object to inspect.
* @param {Object} source The object of property predicates to conform to.
* @returns {boolean} Returns `true` if `object` conforms, else `false`.
*/
function baseConformsTo(object, source, props) {
var length = props.length;
if (object == null) {
return !length;
}
object = Object(object);
while (length--) {
var key = props[length],
predicate = source[key],
value = object[key];
if ((value === undefined && !(key in object)) || !predicate(value)) {
return false;
}
}
return true;
}
export default baseConformsTo;

View File

@@ -2,14 +2,14 @@
var FUNC_ERROR_TEXT = 'Expected a function'; var FUNC_ERROR_TEXT = 'Expected a function';
/** /**
* The base implementation of `_.delay` and `_.defer` which accepts an array * The base implementation of `_.delay` and `_.defer` which accepts `args`
* of `func` arguments. * to provide to `func`.
* *
* @private * @private
* @param {Function} func The function to delay. * @param {Function} func The function to delay.
* @param {number} wait The number of milliseconds to delay invocation. * @param {number} wait The number of milliseconds to delay invocation.
* @param {Object} args The arguments to provide to `func`. * @param {Array} args The arguments to provide to `func`.
* @returns {number} Returns the timer id. * @returns {number|Object} Returns the timer id or timeout object.
*/ */
function baseDelay(func, wait, args) { function baseDelay(func, wait, args) {
if (typeof func != 'function') { if (typeof func != 'function') {

22
_baseGetTag.js Normal file
View File

@@ -0,0 +1,22 @@
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/**
* The base implementation of `getTag`.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
function baseGetTag(value) {
return objectToString.call(value);
}
export default baseGetTag;

View File

@@ -1,5 +1,5 @@
/** /**
* The base implementation of `_.gt` which doesn't coerce arguments to numbers. * The base implementation of `_.gt` which doesn't coerce arguments.
* *
* @private * @private
* @param {*} value The value to compare. * @param {*} value The value to compare.

View File

@@ -1,5 +1,3 @@
import getPrototype from './_getPrototype.js';
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = Object.prototype; var objectProto = Object.prototype;
@@ -15,12 +13,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* @returns {boolean} Returns `true` if `key` exists, else `false`. * @returns {boolean} Returns `true` if `key` exists, else `false`.
*/ */
function baseHas(object, key) { function baseHas(object, key) {
// Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`, return object != null && hasOwnProperty.call(object, key);
// that are composed entirely of index properties, return `false` for
// `hasOwnProperty` checks of them.
return object != null &&
(hasOwnProperty.call(object, key) ||
(typeof object == 'object' && key in object && getPrototype(object) === null));
} }
export default baseHas; export default baseHas;

View File

@@ -3,7 +3,7 @@ var nativeMax = Math.max,
nativeMin = Math.min; nativeMin = Math.min;
/** /**
* The base implementation of `_.inRange` which doesn't coerce arguments to numbers. * The base implementation of `_.inRange` which doesn't coerce arguments.
* *
* @private * @private
* @param {number} number The number to check. * @param {number} number The number to check.

View File

@@ -1,4 +1,5 @@
import indexOfNaN from './_indexOfNaN.js'; import baseFindIndex from './_baseFindIndex.js';
import baseIsNaN from './_baseIsNaN.js';
/** /**
* The base implementation of `_.indexOf` without `fromIndex` bounds checks. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
@@ -11,7 +12,7 @@ import indexOfNaN from './_indexOfNaN.js';
*/ */
function baseIndexOf(array, value, fromIndex) { function baseIndexOf(array, value, fromIndex) {
if (value !== value) { if (value !== value) {
return indexOfNaN(array, fromIndex); return baseFindIndex(array, baseIsNaN, fromIndex);
} }
var index = fromIndex - 1, var index = fromIndex - 1,
length = array.length; length = array.length;

26
_baseIsArrayBuffer.js Normal file
View File

@@ -0,0 +1,26 @@
import isObjectLike from './isObjectLike.js';
var arrayBufferTag = '[object ArrayBuffer]';
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/**
* The base implementation of `_.isArrayBuffer` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
*/
function baseIsArrayBuffer(value) {
return isObjectLike(value) && objectToString.call(value) == arrayBufferTag;
}
export default baseIsArrayBuffer;

27
_baseIsDate.js Normal file
View File

@@ -0,0 +1,27 @@
import isObjectLike from './isObjectLike.js';
/** `Object#toString` result references. */
var dateTag = '[object Date]';
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/**
* The base implementation of `_.isDate` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a date object, else `false`.
*/
function baseIsDate(value) {
return isObjectLike(value) && objectToString.call(value) == dateTag;
}
export default baseIsDate;

18
_baseIsMap.js Normal file
View File

@@ -0,0 +1,18 @@
import getTag from './_getTag.js';
import isObjectLike from './isObjectLike.js';
/** `Object#toString` result references. */
var mapTag = '[object Map]';
/**
* The base implementation of `_.isMap` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a map, else `false`.
*/
function baseIsMap(value) {
return isObjectLike(value) && getTag(value) == mapTag;
}
export default baseIsMap;

12
_baseIsNaN.js Normal file
View File

@@ -0,0 +1,12 @@
/**
* The base implementation of `_.isNaN` without support for number objects.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
*/
function baseIsNaN(value) {
return value !== value;
}
export default baseIsNaN;

View File

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

27
_baseIsRegExp.js Normal file
View File

@@ -0,0 +1,27 @@
import isObject from './isObject.js';
/** `Object#toString` result references. */
var regexpTag = '[object RegExp]';
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/**
* The base implementation of `_.isRegExp` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
*/
function baseIsRegExp(value) {
return isObject(value) && objectToString.call(value) == regexpTag;
}
export default baseIsRegExp;

18
_baseIsSet.js Normal file
View File

@@ -0,0 +1,18 @@
import getTag from './_getTag.js';
import isObjectLike from './isObjectLike.js';
/** `Object#toString` result references. */
var setTag = '[object Set]';
/**
* The base implementation of `_.isSet` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a set, else `false`.
*/
function baseIsSet(value) {
return isObjectLike(value) && getTag(value) == setTag;
}
export default baseIsSet;

69
_baseIsTypedArray.js Normal file
View File

@@ -0,0 +1,69 @@
import isLength from './isLength.js';
import isObjectLike from './isObjectLike.js';
/** `Object#toString` result references. */
var argsTag = '[object Arguments]',
arrayTag = '[object Array]',
boolTag = '[object Boolean]',
dateTag = '[object Date]',
errorTag = '[object Error]',
funcTag = '[object Function]',
mapTag = '[object Map]',
numberTag = '[object Number]',
objectTag = '[object Object]',
regexpTag = '[object RegExp]',
setTag = '[object Set]',
stringTag = '[object String]',
weakMapTag = '[object WeakMap]';
var arrayBufferTag = '[object ArrayBuffer]',
dataViewTag = '[object DataView]',
float32Tag = '[object Float32Array]',
float64Tag = '[object Float64Array]',
int8Tag = '[object Int8Array]',
int16Tag = '[object Int16Array]',
int32Tag = '[object Int32Array]',
uint8Tag = '[object Uint8Array]',
uint8ClampedTag = '[object Uint8ClampedArray]',
uint16Tag = '[object Uint16Array]',
uint32Tag = '[object Uint32Array]';
/** Used to identify `toStringTag` values of typed arrays. */
var typedArrayTags = {};
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
typedArrayTags[uint32Tag] = true;
typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
typedArrayTags[errorTag] = typedArrayTags[funcTag] =
typedArrayTags[mapTag] = typedArrayTags[numberTag] =
typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
typedArrayTags[setTag] = typedArrayTags[stringTag] =
typedArrayTags[weakMapTag] = false;
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/**
* The base implementation of `_.isTypedArray` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
*/
function baseIsTypedArray(value) {
return isObjectLike(value) &&
isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
}
export default baseIsTypedArray;

View File

@@ -1,16 +1,30 @@
/* Built-in method references for those with the same name as other `lodash` methods. */ import isPrototype from './_isPrototype.js';
var nativeKeys = Object.keys; import nativeKeys from './_nativeKeys.js';
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/** /**
* The base implementation of `_.keys` which doesn't skip the constructor * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
* property of prototypes or treat sparse arrays as dense.
* *
* @private * @private
* @param {Object} object The object to query. * @param {Object} object The object to query.
* @returns {Array} Returns the array of property names. * @returns {Array} Returns the array of property names.
*/ */
function baseKeys(object) { function baseKeys(object) {
return nativeKeys(Object(object)); if (!isPrototype(object)) {
return nativeKeys(object);
}
var result = [];
for (var key in Object(object)) {
if (hasOwnProperty.call(object, key) && key != 'constructor') {
result.push(key);
}
}
return result;
} }
export default baseKeys; export default baseKeys;

View File

@@ -1,36 +1,33 @@
import Reflect from './_Reflect.js'; import isObject from './isObject.js';
import iteratorToArray from './_iteratorToArray.js'; import isPrototype from './_isPrototype.js';
import nativeKeysIn from './_nativeKeysIn.js';
/** Used for built-in method references. */ /** Used for built-in method references. */
var objectProto = Object.prototype; var objectProto = Object.prototype;
/** Built-in value references. */ /** Used to check objects for own properties. */
var enumerate = Reflect ? Reflect.enumerate : undefined, var hasOwnProperty = objectProto.hasOwnProperty;
propertyIsEnumerable = objectProto.propertyIsEnumerable;
/** /**
* The base implementation of `_.keysIn` which doesn't skip the constructor * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
* property of prototypes or treat sparse arrays as dense.
* *
* @private * @private
* @param {Object} object The object to query. * @param {Object} object The object to query.
* @returns {Array} Returns the array of property names. * @returns {Array} Returns the array of property names.
*/ */
function baseKeysIn(object) { function baseKeysIn(object) {
object = object == null ? object : Object(object); if (!isObject(object)) {
return nativeKeysIn(object);
}
var isProto = isPrototype(object),
result = [];
var result = [];
for (var key in object) { for (var key in object) {
result.push(key); if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
result.push(key);
}
} }
return result; return result;
} }
// Fallback for IE < 9 with es6-shim.
if (enumerate && !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf')) {
baseKeysIn = function(object) {
return iteratorToArray(enumerate(object));
};
}
export default baseKeysIn; export default baseKeysIn;

View File

@@ -1,5 +1,5 @@
/** /**
* The base implementation of `_.lt` which doesn't coerce arguments to numbers. * The base implementation of `_.lt` which doesn't coerce arguments.
* *
* @private * @private
* @param {*} value The value to compare. * @param {*} value The value to compare.

View File

@@ -1,11 +1,11 @@
import Stack from './_Stack.js'; import Stack from './_Stack.js';
import arrayEach from './_arrayEach.js'; import arrayEach from './_arrayEach.js';
import assignMergeValue from './_assignMergeValue.js'; import assignMergeValue from './_assignMergeValue.js';
import baseKeysIn from './_baseKeysIn.js';
import baseMergeDeep from './_baseMergeDeep.js'; import baseMergeDeep from './_baseMergeDeep.js';
import isArray from './isArray.js'; import isArray from './isArray.js';
import isObject from './isObject.js'; import isObject from './isObject.js';
import isTypedArray from './isTypedArray.js'; import isTypedArray from './isTypedArray.js';
import keysIn from './keysIn.js';
/** /**
* The base implementation of `_.merge` without support for multiple sources. * The base implementation of `_.merge` without support for multiple sources.
@@ -23,7 +23,7 @@ function baseMerge(object, source, srcIndex, customizer, stack) {
return; return;
} }
if (!(isArray(source) || isTypedArray(source))) { if (!(isArray(source) || isTypedArray(source))) {
var props = keysIn(source); var props = baseKeysIn(source);
} }
arrayEach(props || source, function(srcValue, key) { arrayEach(props || source, function(srcValue, key) {
if (props) { if (props) {

View File

@@ -70,13 +70,12 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
isCommon = false; isCommon = false;
} }
} }
stack.set(srcValue, newValue);
if (isCommon) { if (isCommon) {
// Recursively merge objects and arrays (susceptible to call stack limits). // Recursively merge objects and arrays (susceptible to call stack limits).
stack.set(srcValue, newValue);
mergeFunc(newValue, srcValue, srcIndex, customizer, stack); mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
stack['delete'](srcValue);
} }
stack['delete'](srcValue);
assignMergeValue(object, key, newValue); assignMergeValue(object, key, newValue);
} }

View File

@@ -1,7 +1,7 @@
import isIndex from './_isIndex.js'; import isIndex from './_isIndex.js';
/** /**
* The base implementation of `_.nth` which doesn't coerce `n` to an integer. * The base implementation of `_.nth` which doesn't coerce arguments.
* *
* @private * @private
* @param {Array} array The array to query. * @param {Array} array The array to query.

View File

@@ -1,4 +1,4 @@
import arrayReduce from './_arrayReduce.js'; import basePickBy from './_basePickBy.js';
/** /**
* The base implementation of `_.pick` without support for individual * The base implementation of `_.pick` without support for individual
@@ -11,12 +11,9 @@ import arrayReduce from './_arrayReduce.js';
*/ */
function basePick(object, props) { function basePick(object, props) {
object = Object(object); object = Object(object);
return arrayReduce(props, function(result, key) { return basePickBy(object, props, function(value, key) {
if (key in object) { return key in object;
result[key] = object[key]; });
}
return result;
}, {});
} }
export default basePick; export default basePick;

View File

@@ -1,16 +1,14 @@
import getAllKeysIn from './_getAllKeysIn.js';
/** /**
* The base implementation of `_.pickBy` without support for iteratee shorthands. * The base implementation of `_.pickBy` without support for iteratee shorthands.
* *
* @private * @private
* @param {Object} object The source object. * @param {Object} object The source object.
* @param {string[]} props The property identifiers to pick from.
* @param {Function} predicate The function invoked per property. * @param {Function} predicate The function invoked per property.
* @returns {Object} Returns the new object. * @returns {Object} Returns the new object.
*/ */
function basePickBy(object, predicate) { function basePickBy(object, props, predicate) {
var index = -1, var index = -1,
props = getAllKeysIn(object),
length = props.length, length = props.length,
result = {}; result = {};

14
_basePropertyOf.js Normal file
View File

@@ -0,0 +1,14 @@
/**
* The base implementation of `_.propertyOf` without support for deep paths.
*
* @private
* @param {Object} object The object to query.
* @returns {Function} Returns the new accessor function.
*/
function basePropertyOf(object) {
return function(key) {
return object == null ? undefined : object[key];
};
}
export default basePropertyOf;

View File

@@ -4,7 +4,7 @@ var nativeCeil = Math.ceil,
/** /**
* The base implementation of `_.range` and `_.rangeRight` which doesn't * The base implementation of `_.range` and `_.rangeRight` which doesn't
* coerce arguments to numbers. * coerce arguments.
* *
* @private * @private
* @param {number} start The start of the range. * @param {number} start The start of the range.

35
_baseRest.js Normal file
View File

@@ -0,0 +1,35 @@
import apply from './_apply.js';
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max;
/**
* The base implementation of `_.rest` which doesn't validate or coerce arguments.
*
* @private
* @param {Function} func The function to apply a rest parameter to.
* @param {number} [start=func.length-1] The start position of the rest parameter.
* @returns {Function} Returns the new function.
*/
function baseRest(func, start) {
start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
return function() {
var args = arguments,
index = -1,
length = nativeMax(args.length - start, 0),
array = Array(length);
while (++index < length) {
array[index] = args[start + index];
}
index = -1;
var otherArgs = Array(start + 1);
while (++index < start) {
otherArgs[index] = args[index];
}
otherArgs[start] = array;
return apply(func, this, otherArgs);
};
}
export default baseRest;

View File

@@ -16,6 +16,9 @@ import toKey from './_toKey.js';
* @returns {Object} Returns `object`. * @returns {Object} Returns `object`.
*/ */
function baseSet(object, path, value, customizer) { function baseSet(object, path, value, customizer) {
if (!isObject(object)) {
return object;
}
path = isKey(path, object) ? [path] : castPath(path); path = isKey(path, object) ? [path] : castPath(path);
var index = -1, var index = -1,
@@ -24,20 +27,19 @@ function baseSet(object, path, value, customizer) {
nested = object; nested = object;
while (nested != null && ++index < length) { while (nested != null && ++index < length) {
var key = toKey(path[index]); var key = toKey(path[index]),
if (isObject(nested)) { newValue = value;
var newValue = value;
if (index != lastIndex) { if (index != lastIndex) {
var objValue = nested[key]; var objValue = nested[key];
newValue = customizer ? customizer(objValue, key, nested) : undefined; newValue = customizer ? customizer(objValue, key, nested) : undefined;
if (newValue === undefined) { if (newValue === undefined) {
newValue = objValue == null newValue = isObject(objValue)
? (isIndex(path[index + 1]) ? [] : {}) ? objValue
: objValue; : (isIndex(path[index + 1]) ? [] : {});
}
} }
assignValue(nested, key, newValue);
} }
assignValue(nested, key, newValue);
nested = nested[key]; nested = nested[key];
} }
return object; return object;

View File

@@ -1,5 +1,5 @@
/** /**
* The base implementation of `_.unary` without support for storing wrapper metadata. * The base implementation of `_.unary` without support for storing metadata.
* *
* @private * @private
* @param {Function} func The function to cap arguments for. * @param {Function} func The function to cap arguments for.

View File

@@ -1,10 +1,15 @@
import baseHas from './_baseHas.js';
import castPath from './_castPath.js'; import castPath from './_castPath.js';
import isKey from './_isKey.js'; import isKey from './_isKey.js';
import last from './last.js'; import last from './last.js';
import parent from './_parent.js'; import parent from './_parent.js';
import toKey from './_toKey.js'; import toKey from './_toKey.js';
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/** /**
* The base implementation of `_.unset`. * The base implementation of `_.unset`.
* *
@@ -18,7 +23,7 @@ function baseUnset(object, path) {
object = parent(object, path); object = parent(object, path);
var key = toKey(last(path)); var key = toKey(last(path));
return !(object != null && baseHas(object, key)) || delete object[key]; return !(object != null && hasOwnProperty.call(object, key)) || delete object[key];
} }
export default baseUnset; export default baseUnset;

View File

@@ -1,12 +0,0 @@
/**
* Checks if `value` is a global object.
*
* @private
* @param {*} value The value to check.
* @returns {null|Object} Returns `value` if it's a global object, else `null`.
*/
function checkGlobal(value) {
return (value && value.Object === Object) ? value : null;
}
export default checkGlobal;

View File

@@ -21,9 +21,9 @@ function copyObject(source, props, object, customizer) {
var newValue = customizer var newValue = customizer
? customizer(object[key], source[key], key, object, source) ? customizer(object[key], source[key], key, object, source)
: source[key]; : undefined;
assignValue(object, key, newValue); assignValue(object, key, newValue === undefined ? source[key] : newValue);
} }
return object; return object;
} }

View File

@@ -16,7 +16,7 @@ function createAggregator(setter, initializer) {
var func = isArray(collection) ? arrayAggregator : baseAggregator, var func = isArray(collection) ? arrayAggregator : baseAggregator,
accumulator = initializer ? initializer() : {}; accumulator = initializer ? initializer() : {};
return func(collection, setter, baseIteratee(iteratee), accumulator); return func(collection, setter, baseIteratee(iteratee, 2), accumulator);
}; };
} }

View File

@@ -1,5 +1,5 @@
import baseRest from './_baseRest.js';
import isIterateeCall from './_isIterateeCall.js'; import isIterateeCall from './_isIterateeCall.js';
import rest from './rest.js';
/** /**
* Creates a function like `_.assign`. * Creates a function like `_.assign`.
@@ -9,7 +9,7 @@ import rest from './rest.js';
* @returns {Function} Returns the new assigner function. * @returns {Function} Returns the new assigner function.
*/ */
function createAssigner(assigner) { function createAssigner(assigner) {
return rest(function(object, sources) { return baseRest(function(object, sources) {
var index = -1, var index = -1,
length = sources.length, length = sources.length,
customizer = length > 1 ? sources[length - 1] : undefined, customizer = length > 1 ? sources[length - 1] : undefined,

View File

@@ -1,7 +1,7 @@
import createCtorWrapper from './_createCtorWrapper.js'; import createCtor from './_createCtor.js';
import root from './_root.js'; import root from './_root.js';
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for function metadata. */
var BIND_FLAG = 1; var BIND_FLAG = 1;
/** /**
@@ -10,14 +10,13 @@ var BIND_FLAG = 1;
* *
* @private * @private
* @param {Function} func The function to wrap. * @param {Function} func The function to wrap.
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
* for more details.
* @param {*} [thisArg] The `this` binding of `func`. * @param {*} [thisArg] The `this` binding of `func`.
* @returns {Function} Returns the new wrapped function. * @returns {Function} Returns the new wrapped function.
*/ */
function createBaseWrapper(func, bitmask, thisArg) { function createBind(func, bitmask, thisArg) {
var isBind = bitmask & BIND_FLAG, var isBind = bitmask & BIND_FLAG,
Ctor = createCtorWrapper(func); Ctor = createCtor(func);
function wrapper() { function wrapper() {
var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
@@ -26,4 +25,4 @@ function createBaseWrapper(func, bitmask, thisArg) {
return wrapper; return wrapper;
} }
export default createBaseWrapper; export default createBind;

View File

@@ -9,10 +9,10 @@ import isObject from './isObject.js';
* @param {Function} Ctor The constructor to wrap. * @param {Function} Ctor The constructor to wrap.
* @returns {Function} Returns the new wrapped function. * @returns {Function} Returns the new wrapped function.
*/ */
function createCtorWrapper(Ctor) { function createCtor(Ctor) {
return function() { return function() {
// Use a `switch` statement to work with class constructors. See // Use a `switch` statement to work with class constructors. See
// http://ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
// for more details. // for more details.
var args = arguments; var args = arguments;
switch (args.length) { switch (args.length) {
@@ -34,4 +34,4 @@ function createCtorWrapper(Ctor) {
}; };
} }
export default createCtorWrapper; export default createCtor;

View File

@@ -1,7 +1,7 @@
import apply from './_apply.js'; import apply from './_apply.js';
import createCtorWrapper from './_createCtorWrapper.js'; import createCtor from './_createCtor.js';
import createHybridWrapper from './_createHybridWrapper.js'; import createHybrid from './_createHybrid.js';
import createRecurryWrapper from './_createRecurryWrapper.js'; import createRecurry from './_createRecurry.js';
import getHolder from './_getHolder.js'; import getHolder from './_getHolder.js';
import replaceHolders from './_replaceHolders.js'; import replaceHolders from './_replaceHolders.js';
import root from './_root.js'; import root from './_root.js';
@@ -11,13 +11,12 @@ import root from './_root.js';
* *
* @private * @private
* @param {Function} func The function to wrap. * @param {Function} func The function to wrap.
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
* for more details.
* @param {number} arity The arity of `func`. * @param {number} arity The arity of `func`.
* @returns {Function} Returns the new wrapped function. * @returns {Function} Returns the new wrapped function.
*/ */
function createCurryWrapper(func, bitmask, arity) { function createCurry(func, bitmask, arity) {
var Ctor = createCtorWrapper(func); var Ctor = createCtor(func);
function wrapper() { function wrapper() {
var length = arguments.length, var length = arguments.length,
@@ -34,8 +33,8 @@ function createCurryWrapper(func, bitmask, arity) {
length -= holders.length; length -= holders.length;
if (length < arity) { if (length < arity) {
return createRecurryWrapper( return createRecurry(
func, bitmask, createHybridWrapper, wrapper.placeholder, undefined, func, bitmask, createHybrid, wrapper.placeholder, undefined,
args, holders, undefined, undefined, arity - length); args, holders, undefined, undefined, arity - length);
} }
var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
@@ -44,4 +43,4 @@ function createCurryWrapper(func, bitmask, arity) {
return wrapper; return wrapper;
} }
export default createCurryWrapper; export default createCurry;

25
_createFind.js Normal file
View File

@@ -0,0 +1,25 @@
import baseIteratee from './_baseIteratee.js';
import isArrayLike from './isArrayLike.js';
import keys from './keys.js';
/**
* Creates a `_.find` or `_.findLast` function.
*
* @private
* @param {Function} findIndexFunc The function to find the collection index.
* @returns {Function} Returns the new find function.
*/
function createFind(findIndexFunc) {
return function(collection, predicate, fromIndex) {
var iterable = Object(collection);
if (!isArrayLike(collection)) {
var iteratee = baseIteratee(predicate, 3);
collection = keys(collection);
predicate = function(key) { return iteratee(iterable[key], key, iterable); };
}
var index = findIndexFunc(collection, predicate, fromIndex);
return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
};
}
export default createFind;

View File

@@ -1,10 +1,10 @@
import LodashWrapper from './_LodashWrapper.js'; import LodashWrapper from './_LodashWrapper.js';
import baseFlatten from './_baseFlatten.js'; import baseFlatten from './_baseFlatten.js';
import baseRest from './_baseRest.js';
import getData from './_getData.js'; import getData from './_getData.js';
import getFuncName from './_getFuncName.js'; import getFuncName from './_getFuncName.js';
import isArray from './isArray.js'; import isArray from './isArray.js';
import isLaziable from './_isLaziable.js'; import isLaziable from './_isLaziable.js';
import rest from './rest.js';
/** Used as the size to enable large array optimizations. */ /** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200; var LARGE_ARRAY_SIZE = 200;
@@ -12,7 +12,7 @@ var LARGE_ARRAY_SIZE = 200;
/** Used as the `TypeError` message for "Functions" methods. */ /** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function'; var FUNC_ERROR_TEXT = 'Expected a function';
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for function metadata. */
var CURRY_FLAG = 8, var CURRY_FLAG = 8,
PARTIAL_FLAG = 32, PARTIAL_FLAG = 32,
ARY_FLAG = 128, ARY_FLAG = 128,
@@ -26,7 +26,7 @@ var CURRY_FLAG = 8,
* @returns {Function} Returns the new flow function. * @returns {Function} Returns the new flow function.
*/ */
function createFlow(fromRight) { function createFlow(fromRight) {
return rest(function(funcs) { return baseRest(function(funcs) {
funcs = baseFlatten(funcs, 1); funcs = baseFlatten(funcs, 1);
var length = funcs.length, var length = funcs.length,

View File

@@ -1,14 +1,14 @@
import composeArgs from './_composeArgs.js'; import composeArgs from './_composeArgs.js';
import composeArgsRight from './_composeArgsRight.js'; import composeArgsRight from './_composeArgsRight.js';
import countHolders from './_countHolders.js'; import countHolders from './_countHolders.js';
import createCtorWrapper from './_createCtorWrapper.js'; import createCtor from './_createCtor.js';
import createRecurryWrapper from './_createRecurryWrapper.js'; import createRecurry from './_createRecurry.js';
import getHolder from './_getHolder.js'; import getHolder from './_getHolder.js';
import reorder from './_reorder.js'; import reorder from './_reorder.js';
import replaceHolders from './_replaceHolders.js'; import replaceHolders from './_replaceHolders.js';
import root from './_root.js'; import root from './_root.js';
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for function metadata. */
var BIND_FLAG = 1, var BIND_FLAG = 1,
BIND_KEY_FLAG = 2, BIND_KEY_FLAG = 2,
CURRY_FLAG = 8, CURRY_FLAG = 8,
@@ -22,8 +22,7 @@ var BIND_FLAG = 1,
* *
* @private * @private
* @param {Function|string} func The function or method name to wrap. * @param {Function|string} func The function or method name to wrap.
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
* for more details.
* @param {*} [thisArg] The `this` binding of `func`. * @param {*} [thisArg] The `this` binding of `func`.
* @param {Array} [partials] The arguments to prepend to those provided to * @param {Array} [partials] The arguments to prepend to those provided to
* the new function. * the new function.
@@ -36,13 +35,13 @@ var BIND_FLAG = 1,
* @param {number} [arity] The arity of `func`. * @param {number} [arity] The arity of `func`.
* @returns {Function} Returns the new wrapped function. * @returns {Function} Returns the new wrapped function.
*/ */
function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
var isAry = bitmask & ARY_FLAG, var isAry = bitmask & ARY_FLAG,
isBind = bitmask & BIND_FLAG, isBind = bitmask & BIND_FLAG,
isBindKey = bitmask & BIND_KEY_FLAG, isBindKey = bitmask & BIND_KEY_FLAG,
isCurried = bitmask & (CURRY_FLAG | CURRY_RIGHT_FLAG), isCurried = bitmask & (CURRY_FLAG | CURRY_RIGHT_FLAG),
isFlip = bitmask & FLIP_FLAG, isFlip = bitmask & FLIP_FLAG,
Ctor = isBindKey ? undefined : createCtorWrapper(func); Ctor = isBindKey ? undefined : createCtor(func);
function wrapper() { function wrapper() {
var length = arguments.length, var length = arguments.length,
@@ -65,8 +64,8 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials
length -= holdersCount; length -= holdersCount;
if (isCurried && length < arity) { if (isCurried && length < arity) {
var newHolders = replaceHolders(args, placeholder); var newHolders = replaceHolders(args, placeholder);
return createRecurryWrapper( return createRecurry(
func, bitmask, createHybridWrapper, wrapper.placeholder, thisArg, func, bitmask, createHybrid, wrapper.placeholder, thisArg,
args, newHolders, argPos, ary, arity - length args, newHolders, argPos, ary, arity - length
); );
} }
@@ -83,11 +82,11 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials
args.length = ary; args.length = ary;
} }
if (this && this !== root && this instanceof wrapper) { if (this && this !== root && this instanceof wrapper) {
fn = Ctor || createCtorWrapper(fn); fn = Ctor || createCtor(fn);
} }
return fn.apply(thisBinding, args); return fn.apply(thisBinding, args);
} }
return wrapper; return wrapper;
} }
export default createHybridWrapper; export default createHybrid;

View File

@@ -6,13 +6,14 @@ import baseToString from './_baseToString.js';
* *
* @private * @private
* @param {Function} operator The function to perform the operation. * @param {Function} operator The function to perform the operation.
* @param {number} [defaultValue] The value used for `undefined` arguments.
* @returns {Function} Returns the new mathematical operation function. * @returns {Function} Returns the new mathematical operation function.
*/ */
function createMathOperation(operator) { function createMathOperation(operator, defaultValue) {
return function(value, other) { return function(value, other) {
var result; var result;
if (value === undefined && other === undefined) { if (value === undefined && other === undefined) {
return 0; return defaultValue;
} }
if (value !== undefined) { if (value !== undefined) {
result = value; result = value;

View File

@@ -2,10 +2,9 @@ import apply from './_apply.js';
import arrayMap from './_arrayMap.js'; import arrayMap from './_arrayMap.js';
import baseFlatten from './_baseFlatten.js'; import baseFlatten from './_baseFlatten.js';
import baseIteratee from './_baseIteratee.js'; import baseIteratee from './_baseIteratee.js';
import baseRest from './_baseRest.js';
import baseUnary from './_baseUnary.js'; import baseUnary from './_baseUnary.js';
import isArray from './isArray.js'; import isArray from './isArray.js';
import isFlattenableIteratee from './_isFlattenableIteratee.js';
import rest from './rest.js';
/** /**
* Creates a function like `_.over`. * Creates a function like `_.over`.
@@ -15,12 +14,12 @@ import rest from './rest.js';
* @returns {Function} Returns the new over function. * @returns {Function} Returns the new over function.
*/ */
function createOver(arrayFunc) { function createOver(arrayFunc) {
return rest(function(iteratees) { return baseRest(function(iteratees) {
iteratees = (iteratees.length == 1 && isArray(iteratees[0])) iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
? arrayMap(iteratees[0], baseUnary(baseIteratee)) ? arrayMap(iteratees[0], baseUnary(baseIteratee))
: arrayMap(baseFlatten(iteratees, 1, isFlattenableIteratee), baseUnary(baseIteratee)); : arrayMap(baseFlatten(iteratees, 1), baseUnary(baseIteratee));
return rest(function(args) { return baseRest(function(args) {
var thisArg = this; var thisArg = this;
return arrayFunc(iteratees, function(iteratee) { return arrayFunc(iteratees, function(iteratee) {
return apply(iteratee, thisArg, args); return apply(iteratee, thisArg, args);

View File

@@ -1,8 +1,8 @@
import apply from './_apply.js'; import apply from './_apply.js';
import createCtorWrapper from './_createCtorWrapper.js'; import createCtor from './_createCtor.js';
import root from './_root.js'; import root from './_root.js';
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for function metadata. */
var BIND_FLAG = 1; var BIND_FLAG = 1;
/** /**
@@ -11,16 +11,15 @@ var BIND_FLAG = 1;
* *
* @private * @private
* @param {Function} func The function to wrap. * @param {Function} func The function to wrap.
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
* for more details.
* @param {*} thisArg The `this` binding of `func`. * @param {*} thisArg The `this` binding of `func`.
* @param {Array} partials The arguments to prepend to those provided to * @param {Array} partials The arguments to prepend to those provided to
* the new function. * the new function.
* @returns {Function} Returns the new wrapped function. * @returns {Function} Returns the new wrapped function.
*/ */
function createPartialWrapper(func, bitmask, thisArg, partials) { function createPartial(func, bitmask, thisArg, partials) {
var isBind = bitmask & BIND_FLAG, var isBind = bitmask & BIND_FLAG,
Ctor = createCtorWrapper(func); Ctor = createCtor(func);
function wrapper() { function wrapper() {
var argsIndex = -1, var argsIndex = -1,
@@ -41,4 +40,4 @@ function createPartialWrapper(func, bitmask, thisArg, partials) {
return wrapper; return wrapper;
} }
export default createPartialWrapper; export default createPartial;

View File

@@ -1,6 +1,6 @@
import baseRange from './_baseRange.js'; import baseRange from './_baseRange.js';
import isIterateeCall from './_isIterateeCall.js'; import isIterateeCall from './_isIterateeCall.js';
import toNumber from './toNumber.js'; import toFinite from './toFinite.js';
/** /**
* Creates a `_.range` or `_.rangeRight` function. * Creates a `_.range` or `_.rangeRight` function.
@@ -15,15 +15,14 @@ function createRange(fromRight) {
end = step = undefined; end = step = undefined;
} }
// Ensure the sign of `-0` is preserved. // Ensure the sign of `-0` is preserved.
start = toNumber(start); start = toFinite(start);
start = start === start ? start : 0;
if (end === undefined) { if (end === undefined) {
end = start; end = start;
start = 0; start = 0;
} else { } else {
end = toNumber(end) || 0; end = toFinite(end);
} }
step = step === undefined ? (start < end ? 1 : -1) : (toNumber(step) || 0); step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
return baseRange(start, end, step, fromRight); return baseRange(start, end, step, fromRight);
}; };
} }

View File

@@ -1,7 +1,8 @@
import isLaziable from './_isLaziable.js'; import isLaziable from './_isLaziable.js';
import setData from './_setData.js'; import setData from './_setData.js';
import setWrapToString from './_setWrapToString.js';
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for function metadata. */
var BIND_FLAG = 1, var BIND_FLAG = 1,
BIND_KEY_FLAG = 2, BIND_KEY_FLAG = 2,
CURRY_BOUND_FLAG = 4, CURRY_BOUND_FLAG = 4,
@@ -14,8 +15,7 @@ var BIND_FLAG = 1,
* *
* @private * @private
* @param {Function} func The function to wrap. * @param {Function} func The function to wrap.
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
* for more details.
* @param {Function} wrapFunc The function to create the `func` wrapper. * @param {Function} wrapFunc The function to create the `func` wrapper.
* @param {*} placeholder The placeholder value. * @param {*} placeholder The placeholder value.
* @param {*} [thisArg] The `this` binding of `func`. * @param {*} [thisArg] The `this` binding of `func`.
@@ -27,7 +27,7 @@ var BIND_FLAG = 1,
* @param {number} [arity] The arity of `func`. * @param {number} [arity] The arity of `func`.
* @returns {Function} Returns the new wrapped function. * @returns {Function} Returns the new wrapped function.
*/ */
function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
var isCurry = bitmask & CURRY_FLAG, var isCurry = bitmask & CURRY_FLAG,
newHolders = isCurry ? holders : undefined, newHolders = isCurry ? holders : undefined,
newHoldersRight = isCurry ? undefined : holders, newHoldersRight = isCurry ? undefined : holders,
@@ -50,7 +50,7 @@ function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, par
setData(result, newData); setData(result, newData);
} }
result.placeholder = placeholder; result.placeholder = placeholder;
return result; return setWrapToString(result, func, bitmask);
} }
export default createRecurryWrapper; export default createRecurry;

View File

@@ -6,7 +6,7 @@ import setToArray from './_setToArray.js';
var INFINITY = 1 / 0; var INFINITY = 1 / 0;
/** /**
* Creates a set of `values`. * Creates a set object of `values`.
* *
* @private * @private
* @param {Array} values The values to add to the set. * @param {Array} values The values to add to the set.

View File

@@ -1,17 +1,18 @@
import baseSetData from './_baseSetData.js'; import baseSetData from './_baseSetData.js';
import createBaseWrapper from './_createBaseWrapper.js'; import createBind from './_createBind.js';
import createCurryWrapper from './_createCurryWrapper.js'; import createCurry from './_createCurry.js';
import createHybridWrapper from './_createHybridWrapper.js'; import createHybrid from './_createHybrid.js';
import createPartialWrapper from './_createPartialWrapper.js'; import createPartial from './_createPartial.js';
import getData from './_getData.js'; import getData from './_getData.js';
import mergeData from './_mergeData.js'; import mergeData from './_mergeData.js';
import setData from './_setData.js'; import setData from './_setData.js';
import setWrapToString from './_setWrapToString.js';
import toInteger from './toInteger.js'; import toInteger from './toInteger.js';
/** Used as the `TypeError` message for "Functions" methods. */ /** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function'; var FUNC_ERROR_TEXT = 'Expected a function';
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for function metadata. */
var BIND_FLAG = 1, var BIND_FLAG = 1,
BIND_KEY_FLAG = 2, BIND_KEY_FLAG = 2,
CURRY_FLAG = 8, CURRY_FLAG = 8,
@@ -28,7 +29,7 @@ var nativeMax = Math.max;
* *
* @private * @private
* @param {Function|string} func The function or method name to wrap. * @param {Function|string} func The function or method name to wrap.
* @param {number} bitmask The bitmask of wrapper flags. * @param {number} bitmask The bitmask flags.
* The bitmask may be composed of the following flags: * The bitmask may be composed of the following flags:
* 1 - `_.bind` * 1 - `_.bind`
* 2 - `_.bindKey` * 2 - `_.bindKey`
@@ -48,7 +49,7 @@ var nativeMax = Math.max;
* @param {number} [arity] The arity of `func`. * @param {number} [arity] The arity of `func`.
* @returns {Function} Returns the new wrapped function. * @returns {Function} Returns the new wrapped function.
*/ */
function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
var isBindKey = bitmask & BIND_KEY_FLAG; var isBindKey = bitmask & BIND_KEY_FLAG;
if (!isBindKey && typeof func != 'function') { if (!isBindKey && typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT); throw new TypeError(FUNC_ERROR_TEXT);
@@ -91,16 +92,16 @@ function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, a
bitmask &= ~(CURRY_FLAG | CURRY_RIGHT_FLAG); bitmask &= ~(CURRY_FLAG | CURRY_RIGHT_FLAG);
} }
if (!bitmask || bitmask == BIND_FLAG) { if (!bitmask || bitmask == BIND_FLAG) {
var result = createBaseWrapper(func, bitmask, thisArg); var result = createBind(func, bitmask, thisArg);
} else if (bitmask == CURRY_FLAG || bitmask == CURRY_RIGHT_FLAG) { } else if (bitmask == CURRY_FLAG || bitmask == CURRY_RIGHT_FLAG) {
result = createCurryWrapper(func, bitmask, arity); result = createCurry(func, bitmask, arity);
} else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !holders.length) { } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !holders.length) {
result = createPartialWrapper(func, bitmask, thisArg, partials); result = createPartial(func, bitmask, thisArg, partials);
} else { } else {
result = createHybridWrapper.apply(undefined, newData); result = createHybrid.apply(undefined, newData);
} }
var setter = data ? baseSetData : setData; var setter = data ? baseSetData : setData;
return setter(result, newData); return setWrapToString(setter(result, newData), func, bitmask);
} }
export default createWrapper; export default createWrap;

View File

@@ -1,3 +1,5 @@
import basePropertyOf from './_basePropertyOf.js';
/** Used to map latin-1 supplementary letters to basic latin letters. */ /** Used to map latin-1 supplementary letters to basic latin letters. */
var deburredLetters = { var deburredLetters = {
'\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
@@ -26,8 +28,6 @@ var deburredLetters = {
* @param {string} letter The matched letter to deburr. * @param {string} letter The matched letter to deburr.
* @returns {string} Returns the deburred letter. * @returns {string} Returns the deburred letter.
*/ */
function deburrLetter(letter) { var deburrLetter = basePropertyOf(deburredLetters);
return deburredLetters[letter];
}
export default deburrLetter; export default deburrLetter;

11
_defineProperty.js Normal file
View File

@@ -0,0 +1,11 @@
import getNative from './_getNative.js';
/* Used to set `toString` methods. */
var defineProperty = (function() {
var func = getNative(Object, 'defineProperty'),
name = getNative.name;
return (name && name.length > 2) ? func : undefined;
}());
export default defineProperty;

View File

@@ -29,7 +29,7 @@ function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
} }
// Assume cyclic values are equal. // Assume cyclic values are equal.
var stacked = stack.get(array); var stacked = stack.get(array);
if (stacked) { if (stacked && stack.get(other)) {
return stacked == other; return stacked == other;
} }
var index = -1, var index = -1,
@@ -37,6 +37,7 @@ function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined; seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined;
stack.set(array, other); stack.set(array, other);
stack.set(other, array);
// Ignore non-index properties. // Ignore non-index properties.
while (++index < arrLength) { while (++index < arrLength) {
@@ -75,6 +76,7 @@ function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
} }
} }
stack['delete'](array); stack['delete'](array);
stack['delete'](other);
return result; return result;
} }

View File

@@ -1,5 +1,6 @@
import Symbol from './_Symbol.js'; import Symbol from './_Symbol.js';
import Uint8Array from './_Uint8Array.js'; import Uint8Array from './_Uint8Array.js';
import eq from './eq.js';
import equalArrays from './_equalArrays.js'; import equalArrays from './_equalArrays.js';
import mapToArray from './_mapToArray.js'; import mapToArray from './_mapToArray.js';
import setToArray from './_setToArray.js'; import setToArray from './_setToArray.js';
@@ -63,22 +64,18 @@ function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
case boolTag: case boolTag:
case dateTag: case dateTag:
// Coerce dates and booleans to numbers, dates to milliseconds and case numberTag:
// booleans to `1` or `0` treating invalid dates coerced to `NaN` as // Coerce booleans to `1` or `0` and dates to milliseconds.
// not equal. // Invalid dates are coerced to `NaN`.
return +object == +other; return eq(+object, +other);
case errorTag: case errorTag:
return object.name == other.name && object.message == other.message; return object.name == other.name && object.message == other.message;
case numberTag:
// Treat `NaN` vs. `NaN` as equal.
return (object != +object) ? other != +other : object == +other;
case regexpTag: case regexpTag:
case stringTag: case stringTag:
// Coerce regexes to strings and treat strings, primitives and objects, // Coerce regexes to strings and treat strings, primitives and objects,
// as equal. See http://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype.tostring // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
// for more details. // for more details.
return object == (other + ''); return object == (other + '');
@@ -98,10 +95,12 @@ function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
return stacked == other; return stacked == other;
} }
bitmask |= UNORDERED_COMPARE_FLAG; bitmask |= UNORDERED_COMPARE_FLAG;
stack.set(object, other);
// Recursively compare objects (susceptible to call stack limits). // Recursively compare objects (susceptible to call stack limits).
return equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack); stack.set(object, other);
var result = equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
stack['delete'](object);
return result;
case symbolTag: case symbolTag:
if (symbolValueOf) { if (symbolValueOf) {

View File

@@ -1,9 +1,14 @@
import baseHas from './_baseHas.js';
import keys from './keys.js'; import keys from './keys.js';
/** Used to compose bitmasks for comparison styles. */ /** Used to compose bitmasks for comparison styles. */
var PARTIAL_COMPARE_FLAG = 2; var PARTIAL_COMPARE_FLAG = 2;
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/** /**
* A specialized version of `baseIsEqualDeep` for objects with support for * A specialized version of `baseIsEqualDeep` for objects with support for
* partial deep comparisons. * partial deep comparisons.
@@ -31,17 +36,18 @@ function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
var index = objLength; var index = objLength;
while (index--) { while (index--) {
var key = objProps[index]; var key = objProps[index];
if (!(isPartial ? key in other : baseHas(other, key))) { if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
return false; return false;
} }
} }
// Assume cyclic values are equal. // Assume cyclic values are equal.
var stacked = stack.get(object); var stacked = stack.get(object);
if (stacked) { if (stacked && stack.get(other)) {
return stacked == other; return stacked == other;
} }
var result = true; var result = true;
stack.set(object, other); stack.set(object, other);
stack.set(other, object);
var skipCtor = isPartial; var skipCtor = isPartial;
while (++index < objLength) { while (++index < objLength) {
@@ -77,6 +83,7 @@ function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
} }
} }
stack['delete'](object); stack['delete'](object);
stack['delete'](other);
return result; return result;
} }

View File

@@ -1,3 +1,5 @@
import basePropertyOf from './_basePropertyOf.js';
/** Used to map characters to HTML entities. */ /** Used to map characters to HTML entities. */
var htmlEscapes = { var htmlEscapes = {
'&': '&amp;', '&': '&amp;',
@@ -15,8 +17,6 @@ var htmlEscapes = {
* @param {string} chr The matched character to escape. * @param {string} chr The matched character to escape.
* @returns {string} Returns the escaped character. * @returns {string} Returns the escaped character.
*/ */
function escapeHtmlChar(chr) { var escapeHtmlChar = basePropertyOf(htmlEscapes);
return htmlEscapes[chr];
}
export default escapeHtmlChar; export default escapeHtmlChar;

4
_freeGlobal.js Normal file
View File

@@ -0,0 +1,4 @@
/** Detect free variable `global` from Node.js. */
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
export default freeGlobal;

View File

@@ -1,16 +0,0 @@
import baseProperty from './_baseProperty.js';
/**
* Gets the "length" property value of `object`.
*
* **Note:** This function is used to avoid a
* [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects
* Safari on at least iOS 8.1-8.3 ARM64.
*
* @private
* @param {Object} object The object to query.
* @returns {*} Returns the "length" value.
*/
var getLength = baseProperty('length');
export default getLength;

View File

@@ -1,15 +1,6 @@
/* Built-in method references for those with the same name as other `lodash` methods. */ import overArg from './_overArg.js';
var nativeGetPrototype = Object.getPrototypeOf;
/** /** Built-in value references. */
* Gets the `[[Prototype]]` of `value`. var getPrototype = overArg(Object.getPrototypeOf, Object);
*
* @private
* @param {*} value The value to query.
* @returns {null|Object} Returns the `[[Prototype]]`.
*/
function getPrototype(value) {
return nativeGetPrototype(Object(value));
}
export default getPrototype; export default getPrototype;

View File

@@ -1,7 +1,8 @@
import overArg from './_overArg.js';
import stubArray from './stubArray.js'; import stubArray from './stubArray.js';
/** Built-in value references. */ /* Built-in method references for those with the same name as other `lodash` methods. */
var getOwnPropertySymbols = Object.getOwnPropertySymbols; var nativeGetSymbols = Object.getOwnPropertySymbols;
/** /**
* Creates an array of the own enumerable symbol properties of `object`. * Creates an array of the own enumerable symbol properties of `object`.
@@ -10,15 +11,6 @@ var getOwnPropertySymbols = Object.getOwnPropertySymbols;
* @param {Object} object The object to query. * @param {Object} object The object to query.
* @returns {Array} Returns the array of symbols. * @returns {Array} Returns the array of symbols.
*/ */
function getSymbols(object) { var getSymbols = nativeGetSymbols ? overArg(nativeGetSymbols, Object) : stubArray;
// Coerce `object` to an object to avoid non-object errors in V8.
// See https://bugs.chromium.org/p/v8/issues/detail?id=3443 for more details.
return getOwnPropertySymbols(Object(object));
}
// Fallback for IE < 11.
if (!getOwnPropertySymbols) {
getSymbols = stubArray;
}
export default getSymbols; export default getSymbols;

View File

@@ -1,9 +1,10 @@
import arrayPush from './_arrayPush.js'; import arrayPush from './_arrayPush.js';
import getPrototype from './_getPrototype.js'; import getPrototype from './_getPrototype.js';
import getSymbols from './_getSymbols.js'; import getSymbols from './_getSymbols.js';
import stubArray from './stubArray.js';
/** Built-in value references. */ /* Built-in method references for those with the same name as other `lodash` methods. */
var getOwnPropertySymbols = Object.getOwnPropertySymbols; var nativeGetSymbols = Object.getOwnPropertySymbols;
/** /**
* Creates an array of the own and inherited enumerable symbol properties * Creates an array of the own and inherited enumerable symbol properties
@@ -13,7 +14,7 @@ var getOwnPropertySymbols = Object.getOwnPropertySymbols;
* @param {Object} object The object to query. * @param {Object} object The object to query.
* @returns {Array} Returns the array of symbols. * @returns {Array} Returns the array of symbols.
*/ */
var getSymbolsIn = !getOwnPropertySymbols ? getSymbols : function(object) { var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
var result = []; var result = [];
while (object) { while (object) {
arrayPush(result, getSymbols(object)); arrayPush(result, getSymbols(object));

View File

@@ -3,6 +3,7 @@ import Map from './_Map.js';
import Promise from './_Promise.js'; import Promise from './_Promise.js';
import Set from './_Set.js'; import Set from './_Set.js';
import WeakMap from './_WeakMap.js'; import WeakMap from './_WeakMap.js';
import baseGetTag from './_baseGetTag.js';
import toSource from './_toSource.js'; import toSource from './_toSource.js';
/** `Object#toString` result references. */ /** `Object#toString` result references. */
@@ -19,7 +20,7 @@ var objectProto = Object.prototype;
/** /**
* Used to resolve the * Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values. * of values.
*/ */
var objectToString = objectProto.toString; var objectToString = objectProto.toString;
@@ -38,9 +39,7 @@ var dataViewCtorString = toSource(DataView),
* @param {*} value The value to query. * @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`. * @returns {string} Returns the `toStringTag`.
*/ */
function getTag(value) { var getTag = baseGetTag;
return objectToString.call(value);
}
// Fallback for data views, maps, sets, and weak maps in IE 11, // Fallback for data views, maps, sets, and weak maps in IE 11,
// for data views in Edge, and promises in Node.js. // for data views in Edge, and promises in Node.js.

17
_getWrapDetails.js Normal file
View File

@@ -0,0 +1,17 @@
/** Used to match wrap detail comments. */
var reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
reSplitDetails = /,? & /;
/**
* Extracts wrapper details from the `source` body comment.
*
* @private
* @param {string} source The source to inspect.
* @returns {Array} Returns the wrapper details.
*/
function getWrapDetails(source) {
var match = source.match(reWrapDetails);
return match ? match[1].split(reSplitDetails) : [];
}
export default getWrapDetails;

View File

@@ -1,24 +0,0 @@
import baseTimes from './_baseTimes.js';
import isArguments from './isArguments.js';
import isArray from './isArray.js';
import isLength from './isLength.js';
import isString from './isString.js';
/**
* Creates an array of index keys for `object` values of arrays,
* `arguments` objects, and strings, otherwise `null` is returned.
*
* @private
* @param {Object} object The object to query.
* @returns {Array|null} Returns index keys, else `null`.
*/
function indexKeys(object) {
var length = object ? object.length : undefined;
if (isLength(length) &&
(isArray(object) || isString(object) || isArguments(object))) {
return baseTimes(length, String);
}
return null;
}
export default indexKeys;

View File

@@ -1,23 +0,0 @@
/**
* Gets the index at which the first occurrence of `NaN` is found in `array`.
*
* @private
* @param {Array} array The array to search.
* @param {number} fromIndex The index to search from.
* @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {number} Returns the index of the matched `NaN`, else `-1`.
*/
function indexOfNaN(array, fromIndex, fromRight) {
var length = array.length,
index = fromIndex + (fromRight ? 1 : -1);
while ((fromRight ? index-- : ++index < length)) {
var other = array[index];
if (other !== other) {
return index;
}
}
return -1;
}
export default indexOfNaN;

21
_insertWrapDetails.js Normal file
View File

@@ -0,0 +1,21 @@
/** Used to match wrap detail comments. */
var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/;
/**
* Inserts wrapper `details` in a comment at the top of the `source` body.
*
* @private
* @param {string} source The source to modify.
* @returns {Array} details The details to insert.
* @returns {string} Returns the modified source.
*/
function insertWrapDetails(source, details) {
var length = details.length,
lastIndex = length - 1;
details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
details = details.join(length > 2 ? ', ' : ' ');
return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
}
export default insertWrapDetails;

View File

@@ -1,6 +1,10 @@
import Symbol from './_Symbol.js';
import isArguments from './isArguments.js'; import isArguments from './isArguments.js';
import isArray from './isArray.js'; import isArray from './isArray.js';
/** Built-in value references. */
var spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
/** /**
* Checks if `value` is a flattenable `arguments` object or array. * Checks if `value` is a flattenable `arguments` object or array.
* *
@@ -9,7 +13,8 @@ import isArray from './isArray.js';
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
*/ */
function isFlattenable(value) { function isFlattenable(value) {
return isArray(value) || isArguments(value); return isArray(value) || isArguments(value) ||
!!(spreadableSymbol && value && value[spreadableSymbol]);
} }
export default isFlattenable; export default isFlattenable;

View File

@@ -1,16 +0,0 @@
import isArray from './isArray.js';
import isFunction from './isFunction.js';
/**
* Checks if `value` is a flattenable array and not a `_.matchesProperty`
* iteratee shorthand.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
*/
function isFlattenableIteratee(value) {
return isArray(value) && !(value.length == 2 && !isFunction(value[0]));
}
export default isFlattenableIteratee;

View File

@@ -9,6 +9,6 @@ import stubFalse from './stubFalse.js';
* @param {*} value The value to check. * @param {*} value The value to check.
* @returns {boolean} Returns `true` if `func` is maskable, else `false`. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
*/ */
var isMaskable = !coreJsData ? stubFalse : isFunction; var isMaskable = coreJsData ? isFunction : stubFalse;
export default isMaskable; export default isMaskable;

View File

@@ -5,7 +5,7 @@ import replaceHolders from './_replaceHolders.js';
/** Used as the internal argument placeholder. */ /** Used as the internal argument placeholder. */
var PLACEHOLDER = '__lodash_placeholder__'; var PLACEHOLDER = '__lodash_placeholder__';
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for function metadata. */
var BIND_FLAG = 1, var BIND_FLAG = 1,
BIND_KEY_FLAG = 2, BIND_KEY_FLAG = 2,
CURRY_BOUND_FLAG = 4, CURRY_BOUND_FLAG = 4,

View File

@@ -16,7 +16,10 @@ import isObject from './isObject.js';
*/ */
function mergeDefaults(objValue, srcValue, key, object, source, stack) { function mergeDefaults(objValue, srcValue, key, object, source, stack) {
if (isObject(objValue) && isObject(srcValue)) { if (isObject(objValue) && isObject(srcValue)) {
baseMerge(objValue, srcValue, undefined, mergeDefaults, stack.set(srcValue, objValue)); // Recursively merge objects and arrays (susceptible to call stack limits).
stack.set(srcValue, objValue);
baseMerge(objValue, srcValue, undefined, mergeDefaults, stack);
stack['delete'](srcValue);
} }
return objValue; return objValue;
} }

6
_nativeKeys.js Normal file
View File

@@ -0,0 +1,6 @@
import overArg from './_overArg.js';
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeKeys = overArg(Object.keys, Object);
export default nativeKeys;

20
_nativeKeysIn.js Normal file
View File

@@ -0,0 +1,20 @@
/**
* This function is like
* [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
* except that it includes inherited enumerable properties.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
*/
function nativeKeysIn(object) {
var result = [];
if (object != null) {
for (var key in Object(object)) {
result.push(key);
}
}
return result;
}
export default nativeKeysIn;

22
_nodeUtil.js Normal file
View File

@@ -0,0 +1,22 @@
import freeGlobal from './_freeGlobal.js';
/** Detect free variable `exports`. */
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
/** Detect free variable `module`. */
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
/** Detect the popular CommonJS extension `module.exports`. */
var moduleExports = freeModule && freeModule.exports === freeExports;
/** Detect free variable `process` from Node.js. */
var freeProcess = moduleExports && freeGlobal.process;
/** Used to access faster Node.js helpers. */
var nodeUtil = (function() {
try {
return freeProcess && freeProcess.binding('util');
} catch (e) {}
}());
export default nodeUtil;

15
_overArg.js Normal file
View File

@@ -0,0 +1,15 @@
/**
* Creates a unary function that invokes `func` with its argument transformed.
*
* @private
* @param {Function} func The function to wrap.
* @param {Function} transform The argument transform.
* @returns {Function} Returns the new function.
*/
function overArg(func, transform) {
return function(arg) {
return func(transform(arg));
};
}
export default overArg;

View File

@@ -1,15 +1,9 @@
import checkGlobal from './_checkGlobal.js'; import freeGlobal from './_freeGlobal.js';
/** Detect free variable `global` from Node.js. */
var freeGlobal = checkGlobal(typeof global == 'object' && global);
/** Detect free variable `self`. */ /** Detect free variable `self`. */
var freeSelf = checkGlobal(typeof self == 'object' && self); var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
/** Detect `this` as the global object. */
var thisGlobal = checkGlobal(typeof this == 'object' && this);
/** Used as a reference to the global object. */ /** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || thisGlobal || Function('return this')(); var root = freeGlobal || freeSelf || Function('return this')();
export default root; export default root;

27
_setWrapToString.js Normal file
View File

@@ -0,0 +1,27 @@
import constant from './constant.js';
import defineProperty from './_defineProperty.js';
import getWrapDetails from './_getWrapDetails.js';
import identity from './identity.js';
import insertWrapDetails from './_insertWrapDetails.js';
import updateWrapDetails from './_updateWrapDetails.js';
/**
* Sets the `toString` method of `wrapper` to mimic the source of `reference`
* with wrapper details in a comment at the top of the source body.
*
* @private
* @param {Function} wrapper The function to modify.
* @param {Function} reference The reference function.
* @param {number} bitmask The bitmask flags. See `createWrap` for more details.
* @returns {Function} Returns `wrapper`.
*/
var setWrapToString = !defineProperty ? identity : function(wrapper, reference, bitmask) {
var source = (reference + '');
return defineProperty(wrapper, 'toString', {
'configurable': true,
'enumerable': false,
'value': constant(insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)))
});
};
export default setWrapToString;

View File

@@ -1,4 +1,5 @@
import ListCache from './_ListCache.js'; import ListCache from './_ListCache.js';
import Map from './_Map.js';
import MapCache from './_MapCache.js'; import MapCache from './_MapCache.js';
/** Used as the size to enable large array optimizations. */ /** Used as the size to enable large array optimizations. */
@@ -16,8 +17,13 @@ var LARGE_ARRAY_SIZE = 200;
*/ */
function stackSet(key, value) { function stackSet(key, value) {
var cache = this.__data__; var cache = this.__data__;
if (cache instanceof ListCache && cache.__data__.length == LARGE_ARRAY_SIZE) { if (cache instanceof ListCache) {
cache = this.__data__ = new MapCache(cache.__data__); var pairs = cache.__data__;
if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
pairs.push([key, value]);
return this;
}
cache = this.__data__ = new MapCache(pairs);
} }
cache.set(key, value); cache.set(key, value);
return this; return this;

View File

@@ -2,7 +2,8 @@ import memoize from './memoize.js';
import toString from './toString.js'; import toString from './toString.js';
/** Used to match property names within property paths. */ /** Used to match property names within property paths. */
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(\.|\[\])(?:\4|$))/g; var reLeadingDot = /^\./,
rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
/** Used to match backslashes in property paths. */ /** Used to match backslashes in property paths. */
var reEscapeChar = /\\(\\)?/g; var reEscapeChar = /\\(\\)?/g;
@@ -15,8 +16,13 @@ var reEscapeChar = /\\(\\)?/g;
* @returns {Array} Returns the property path array. * @returns {Array} Returns the property path array.
*/ */
var stringToPath = memoize(function(string) { var stringToPath = memoize(function(string) {
string = toString(string);
var result = []; var result = [];
toString(string).replace(rePropName, function(match, number, quote, string) { if (reLeadingDot.test(string)) {
result.push('');
}
string.replace(rePropName, function(match, number, quote, string) {
result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
}); });
return result; return result;

View File

@@ -1,3 +1,5 @@
import basePropertyOf from './_basePropertyOf.js';
/** Used to map HTML entities to characters. */ /** Used to map HTML entities to characters. */
var htmlUnescapes = { var htmlUnescapes = {
'&amp;': '&', '&amp;': '&',
@@ -15,8 +17,6 @@ var htmlUnescapes = {
* @param {string} chr The matched character to unescape. * @param {string} chr The matched character to unescape.
* @returns {string} Returns the unescaped character. * @returns {string} Returns the unescaped character.
*/ */
function unescapeHtmlChar(chr) { var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
return htmlUnescapes[chr];
}
export default unescapeHtmlChar; export default unescapeHtmlChar;

46
_updateWrapDetails.js Normal file
View File

@@ -0,0 +1,46 @@
import arrayEach from './_arrayEach.js';
import arrayIncludes from './_arrayIncludes.js';
/** Used to compose bitmasks for function metadata. */
var BIND_FLAG = 1,
BIND_KEY_FLAG = 2,
CURRY_FLAG = 8,
CURRY_RIGHT_FLAG = 16,
PARTIAL_FLAG = 32,
PARTIAL_RIGHT_FLAG = 64,
ARY_FLAG = 128,
REARG_FLAG = 256,
FLIP_FLAG = 512;
/** Used to associate wrap methods with their bit flags. */
var wrapFlags = [
['ary', ARY_FLAG],
['bind', BIND_FLAG],
['bindKey', BIND_KEY_FLAG],
['curry', CURRY_FLAG],
['curryRight', CURRY_RIGHT_FLAG],
['flip', FLIP_FLAG],
['partial', PARTIAL_FLAG],
['partialRight', PARTIAL_RIGHT_FLAG],
['rearg', REARG_FLAG]
];
/**
* Updates wrapper `details` based on `bitmask` flags.
*
* @private
* @returns {Array} details The details to modify.
* @param {number} bitmask The bitmask flags. See `createWrap` for more details.
* @returns {Array} Returns `details`.
*/
function updateWrapDetails(details, bitmask) {
arrayEach(wrapFlags, function(pair) {
var value = '_.' + pair[0];
if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
details.push(value);
}
});
return details.sort();
}
export default updateWrapDetails;

2
add.js
View File

@@ -17,6 +17,6 @@ import createMathOperation from './_createMathOperation.js';
*/ */
var add = createMathOperation(function(augend, addend) { var add = createMathOperation(function(augend, addend) {
return augend + addend; return augend + addend;
}); }, 0);
export default add; export default add;

View File

@@ -63,4 +63,4 @@ export { default as zip } from './zip.js';
export { default as zipObject } from './zipObject.js'; export { default as zipObject } from './zipObject.js';
export { default as zipObjectDeep } from './zipObjectDeep.js'; export { default as zipObjectDeep } from './zipObjectDeep.js';
export { default as zipWith } from './zipWith.js'; export { default as zipWith } from './zipWith.js';
export { default as default } from './array.default'; export { default } from './array.default.js';

6
ary.js
View File

@@ -1,6 +1,6 @@
import createWrapper from './_createWrapper.js'; import createWrap from './_createWrap.js';
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for function metadata. */
var ARY_FLAG = 128; var ARY_FLAG = 128;
/** /**
@@ -23,7 +23,7 @@ var ARY_FLAG = 128;
function ary(func, n, guard) { function ary(func, n, guard) {
n = guard ? undefined : n; n = guard ? undefined : n;
n = (func && n == null) ? func.length : n; n = (func && n == null) ? func.length : n;
return createWrapper(func, ARY_FLAG, undefined, undefined, undefined, undefined, n); return createWrap(func, ARY_FLAG, undefined, undefined, undefined, undefined, n);
} }
export default ary; export default ary;

View File

@@ -36,18 +36,18 @@ var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
* @example * @example
* *
* function Foo() { * function Foo() {
* this.c = 3; * this.a = 1;
* } * }
* *
* function Bar() { * function Bar() {
* this.e = 5; * this.c = 3;
* } * }
* *
* Foo.prototype.d = 4; * Foo.prototype.b = 2;
* Bar.prototype.f = 6; * Bar.prototype.d = 4;
* *
* _.assign({ 'a': 1 }, new Foo, new Bar); * _.assign({ 'a': 0 }, new Foo, new Bar);
* // => { 'a': 1, 'c': 3, 'e': 5 } * // => { 'a': 1, 'c': 3 }
*/ */
var assign = createAssigner(function(object, source) { var assign = createAssigner(function(object, source) {
if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) { if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {

View File

@@ -1,19 +1,7 @@
import assignValue from './_assignValue.js';
import copyObject from './_copyObject.js'; import copyObject from './_copyObject.js';
import createAssigner from './_createAssigner.js'; import createAssigner from './_createAssigner.js';
import isArrayLike from './isArrayLike.js';
import isPrototype from './_isPrototype.js';
import keysIn from './keysIn.js'; import keysIn from './keysIn.js';
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Built-in value references. */
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
/** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
/** /**
* This method is like `_.assign` except that it iterates over own and * This method is like `_.assign` except that it iterates over own and
* inherited source properties. * inherited source properties.
@@ -32,27 +20,21 @@ var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
* @example * @example
* *
* function Foo() { * function Foo() {
* this.b = 2; * this.a = 1;
* } * }
* *
* function Bar() { * function Bar() {
* this.d = 4; * this.c = 3;
* } * }
* *
* Foo.prototype.c = 3; * Foo.prototype.b = 2;
* Bar.prototype.e = 5; * Bar.prototype.d = 4;
* *
* _.assignIn({ 'a': 1 }, new Foo, new Bar); * _.assignIn({ 'a': 0 }, new Foo, new Bar);
* // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5 } * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
*/ */
var assignIn = createAssigner(function(object, source) { var assignIn = createAssigner(function(object, source) {
if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) { copyObject(source, keysIn(source), object);
copyObject(source, keysIn(source), object);
return;
}
for (var key in source) {
assignValue(object, key, source[key]);
}
}); });
export default assignIn; export default assignIn;

4
at.js
View File

@@ -1,6 +1,6 @@
import baseAt from './_baseAt.js'; import baseAt from './_baseAt.js';
import baseFlatten from './_baseFlatten.js'; import baseFlatten from './_baseFlatten.js';
import rest from './rest.js'; import baseRest from './_baseRest.js';
/** /**
* Creates an array of values corresponding to `paths` of `object`. * Creates an array of values corresponding to `paths` of `object`.
@@ -19,7 +19,7 @@ import rest from './rest.js';
* _.at(object, ['a[0].b.c', 'a[1]']); * _.at(object, ['a[0].b.c', 'a[1]']);
* // => [3, 4] * // => [3, 4]
*/ */
var at = rest(function(object, paths) { var at = baseRest(function(object, paths) {
return baseAt(object, baseFlatten(paths, 1)); return baseAt(object, baseFlatten(paths, 1));
}); });

View File

@@ -1,6 +1,6 @@
import apply from './_apply.js'; import apply from './_apply.js';
import baseRest from './_baseRest.js';
import isError from './isError.js'; import isError from './isError.js';
import rest from './rest.js';
/** /**
* Attempts to invoke `func`, returning either the result or the caught error * Attempts to invoke `func`, returning either the result or the caught error
@@ -24,7 +24,7 @@ import rest from './rest.js';
* elements = []; * elements = [];
* } * }
*/ */
var attempt = rest(function(func, args) { var attempt = baseRest(function(func, args) {
try { try {
return apply(func, undefined, args); return apply(func, undefined, args);
} catch (e) { } catch (e) {

View File

@@ -18,7 +18,7 @@ var FUNC_ERROR_TEXT = 'Expected a function';
* @example * @example
* *
* jQuery(element).on('click', _.before(5, addContactToList)); * jQuery(element).on('click', _.before(5, addContactToList));
* // => allows adding up to 4 contacts to the list * // => Allows adding up to 4 contacts to the list.
*/ */
function before(n, func) { function before(n, func) {
var result; var result;

14
bind.js
View File

@@ -1,9 +1,9 @@
import createWrapper from './_createWrapper.js'; import baseRest from './_baseRest.js';
import createWrap from './_createWrap.js';
import getHolder from './_getHolder.js'; import getHolder from './_getHolder.js';
import replaceHolders from './_replaceHolders.js'; import replaceHolders from './_replaceHolders.js';
import rest from './rest.js';
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for function metadata. */
var BIND_FLAG = 1, var BIND_FLAG = 1,
PARTIAL_FLAG = 32; PARTIAL_FLAG = 32;
@@ -27,9 +27,9 @@ var BIND_FLAG = 1,
* @returns {Function} Returns the new bound function. * @returns {Function} Returns the new bound function.
* @example * @example
* *
* var greet = function(greeting, punctuation) { * function greet(greeting, punctuation) {
* return greeting + ' ' + this.user + punctuation; * return greeting + ' ' + this.user + punctuation;
* }; * }
* *
* var object = { 'user': 'fred' }; * var object = { 'user': 'fred' };
* *
@@ -42,13 +42,13 @@ var BIND_FLAG = 1,
* bound('hi'); * bound('hi');
* // => 'hi fred!' * // => 'hi fred!'
*/ */
var bind = rest(function(func, thisArg, partials) { var bind = baseRest(function(func, thisArg, partials) {
var bitmask = BIND_FLAG; var bitmask = BIND_FLAG;
if (partials.length) { if (partials.length) {
var holders = replaceHolders(partials, getHolder(bind)); var holders = replaceHolders(partials, getHolder(bind));
bitmask |= PARTIAL_FLAG; bitmask |= PARTIAL_FLAG;
} }
return createWrapper(func, bitmask, thisArg, partials, holders); return createWrap(func, bitmask, thisArg, partials, holders);
}); });
// Assign default placeholders. // Assign default placeholders.

View File

@@ -1,7 +1,7 @@
import arrayEach from './_arrayEach.js'; import arrayEach from './_arrayEach.js';
import baseFlatten from './_baseFlatten.js'; import baseFlatten from './_baseFlatten.js';
import baseRest from './_baseRest.js';
import bind from './bind.js'; import bind from './bind.js';
import rest from './rest.js';
import toKey from './_toKey.js'; import toKey from './_toKey.js';
/** /**
@@ -21,16 +21,16 @@ import toKey from './_toKey.js';
* *
* var view = { * var view = {
* 'label': 'docs', * 'label': 'docs',
* 'onClick': function() { * 'click': function() {
* console.log('clicked ' + this.label); * console.log('clicked ' + this.label);
* } * }
* }; * };
* *
* _.bindAll(view, ['onClick']); * _.bindAll(view, ['click']);
* jQuery(element).on('click', view.onClick); * jQuery(element).on('click', view.click);
* // => Logs 'clicked docs' when clicked. * // => Logs 'clicked docs' when clicked.
*/ */
var bindAll = rest(function(object, methodNames) { var bindAll = baseRest(function(object, methodNames) {
arrayEach(baseFlatten(methodNames, 1), function(key) { arrayEach(baseFlatten(methodNames, 1), function(key) {
key = toKey(key); key = toKey(key);
object[key] = bind(object[key], object); object[key] = bind(object[key], object);

View File

@@ -1,9 +1,9 @@
import createWrapper from './_createWrapper.js'; import baseRest from './_baseRest.js';
import createWrap from './_createWrap.js';
import getHolder from './_getHolder.js'; import getHolder from './_getHolder.js';
import replaceHolders from './_replaceHolders.js'; import replaceHolders from './_replaceHolders.js';
import rest from './rest.js';
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for function metadata. */
var BIND_FLAG = 1, var BIND_FLAG = 1,
BIND_KEY_FLAG = 2, BIND_KEY_FLAG = 2,
PARTIAL_FLAG = 32; PARTIAL_FLAG = 32;
@@ -53,13 +53,13 @@ var BIND_FLAG = 1,
* bound('hi'); * bound('hi');
* // => 'hiya fred!' * // => 'hiya fred!'
*/ */
var bindKey = rest(function(object, key, partials) { var bindKey = baseRest(function(object, key, partials) {
var bitmask = BIND_FLAG | BIND_KEY_FLAG; var bitmask = BIND_FLAG | BIND_KEY_FLAG;
if (partials.length) { if (partials.length) {
var holders = replaceHolders(partials, getHolder(bindKey)); var holders = replaceHolders(partials, getHolder(bindKey));
bitmask |= PARTIAL_FLAG; bitmask |= PARTIAL_FLAG;
} }
return createWrapper(key, bitmask, object, partials, holders); return createWrap(key, bitmask, object, partials, holders);
}); });
// Assign default placeholders. // Assign default placeholders.

View File

@@ -1,4 +1,3 @@
import at from './at.js';
import countBy from './countBy.js'; import countBy from './countBy.js';
import each from './each.js'; import each from './each.js';
import eachRight from './eachRight.js'; import eachRight from './eachRight.js';
@@ -29,10 +28,10 @@ import some from './some.js';
import sortBy from './sortBy.js'; import sortBy from './sortBy.js';
export default { export default {
at, countBy, each, eachRight, every, countBy, each, eachRight, every, filter,
filter, find, findLast, flatMap, flatMapDeep, find, findLast, flatMap, flatMapDeep, flatMapDepth,
flatMapDepth, forEach, forEachRight, groupBy, includes, forEach, forEachRight, groupBy, includes, invokeMap,
invokeMap, keyBy, map, orderBy, partition, keyBy, map, orderBy, partition, reduce,
reduce, reduceRight, reject, sample, sampleSize, reduceRight, reject, sample, sampleSize, shuffle,
shuffle, size, some, sortBy size, some, sortBy
}; };

View File

@@ -1,4 +1,3 @@
export { default as at } from './at.js';
export { default as countBy } from './countBy.js'; export { default as countBy } from './countBy.js';
export { default as each } from './each.js'; export { default as each } from './each.js';
export { default as eachRight } from './eachRight.js'; export { default as eachRight } from './eachRight.js';
@@ -27,4 +26,4 @@ export { default as shuffle } from './shuffle.js';
export { default as size } from './size.js'; export { default as size } from './size.js';
export { default as some } from './some.js'; export { default as some } from './some.js';
export { default as sortBy } from './sortBy.js'; export { default as sortBy } from './sortBy.js';
export { default as default } from './collection.default'; export { default } from './collection.default.js';

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