Compare commits

..

4 Commits

Author SHA1 Message Date
John-David Dalton
52a75b18e4 Bump to v4.16.4. 2016-10-05 19:29:32 -07:00
John-David Dalton
0961d6edde Bump to v4.16.3. 2016-10-02 21:51:40 -07:00
John-David Dalton
2f8450b523 Bump to v4.16.2. 2016-09-25 13:37:46 -07:00
John-David Dalton
81b88ae10c Bump to v4.16.1. 2016-09-20 09:47:40 -07:00
47 changed files with 438 additions and 223 deletions

View File

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

View File

@@ -1,4 +1,4 @@
define(['./_baseTimes', './isArguments', './isArray', './_isIndex'], function(baseTimes, isArguments, isArray, isIndex) {
define(['./_baseTimes', './isArguments', './isArray', './isBuffer', './_isIndex', './isTypedArray'], function(baseTimes, isArguments, isArray, isBuffer, isIndex, isTypedArray) {
/** Used for built-in method references. */
var objectProto = Object.prototype;
@@ -15,18 +15,26 @@ define(['./_baseTimes', './isArguments', './isArray', './_isIndex'], function(ba
* @returns {Array} Returns the array of property names.
*/
function arrayLikeKeys(value, inherited) {
// Safari 8.1 makes `arguments.callee` enumerable in strict mode.
// Safari 9 makes `arguments.length` enumerable in strict mode.
var result = (isArray(value) || isArguments(value))
? baseTimes(value.length, String)
: [];
var length = result.length,
skipIndexes = !!length;
var isArr = isArray(value),
isArg = !isArr && isArguments(value),
isBuff = !isArr && !isArg && isBuffer(value),
isType = !isArr && !isArg && !isBuff && isTypedArray(value),
skipIndexes = isArr || isArg || isBuff || isType,
result = skipIndexes ? baseTimes(value.length, String) : [],
length = result.length;
for (var key in value) {
if ((inherited || hasOwnProperty.call(value, key)) &&
!(skipIndexes && (key == 'length' || isIndex(key, length)))) {
!(skipIndexes && (
// Safari 9 has enumerable `arguments.length` in strict mode.
key == 'length' ||
// Node.js 0.10 has enumerable non-index properties on buffers.
(isBuff && (key == 'offset' || key == 'parent')) ||
// PhantomJS 2 has enumerable non-index properties on typed arrays.
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
// Skip index properties.
isIndex(key, length)
))) {
result.push(key);
}
}

View File

@@ -4,8 +4,7 @@ define(['./_baseRandom'], function(baseRandom) {
var undefined;
/**
* A specialized version of `_.sample` for arrays without support for iteratee
* shorthands.
* A specialized version of `_.sample` for arrays.
*
* @private
* @param {Array} array The array to sample.

View File

@@ -1,4 +1,4 @@
define(['./_arrayShuffle', './_baseClamp'], function(arrayShuffle, baseClamp) {
define(['./_baseClamp', './_copyArray', './_shuffleSelf'], function(baseClamp, copyArray, shuffleSelf) {
/**
* A specialized version of `_.sampleSize` for arrays.
@@ -9,9 +9,7 @@ define(['./_arrayShuffle', './_baseClamp'], function(arrayShuffle, baseClamp) {
* @returns {Array} Returns the random elements.
*/
function arraySampleSize(array, n) {
var result = arrayShuffle(array);
result.length = baseClamp(n, 0, result.length);
return result;
return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
}
return arraySampleSize;

View File

@@ -14,7 +14,7 @@ define(['./_baseAssignValue', './eq'], function(baseAssignValue, eq) {
*/
function assignMergeValue(object, key, value) {
if ((value !== undefined && !eq(object[key], value)) ||
(typeof key == 'number' && value === undefined && !(key in object))) {
(value === undefined && !(key in object))) {
baseAssignValue(object, key, value);
}
}

View File

@@ -1,7 +1,4 @@
define([], function() {
/** Built-in value references. */
var defineProperty = Object.defineProperty;
define(['./_defineProperty'], function(defineProperty) {
/**
* The base implementation of `assignValue` and `assignMergeValue` without

View File

@@ -106,9 +106,7 @@ define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_clone
}
stack.set(value, result);
if (!isArr) {
var props = isFull ? getAllKeys(value) : keys(value);
}
var props = isArr ? undefined : (isFull ? getAllKeys : keys)(value);
arrayEach(props || value, function(subValue, key) {
if (props) {
key = subValue;

View File

@@ -1,5 +1,8 @@
define(['./isObject'], function(isObject) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Built-in value references. */
var objectCreate = Object.create;
@@ -8,12 +11,24 @@ define(['./isObject'], function(isObject) {
* properties to the created object.
*
* @private
* @param {Object} prototype The object to inherit from.
* @param {Object} proto The object to inherit from.
* @returns {Object} Returns the new object.
*/
function baseCreate(proto) {
return isObject(proto) ? objectCreate(proto) : {};
}
var baseCreate = (function() {
function object() {}
return function(proto) {
if (!isObject(proto)) {
return {};
}
if (objectCreate) {
return objectCreate(proto);
}
object.prototype = proto;
var result = new object;
object.prototype = undefined;
return result;
};
}());
return baseCreate;
});

View File

@@ -3,7 +3,7 @@ define([], function() {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**

28
_baseIsArguments.js Normal file
View File

@@ -0,0 +1,28 @@
define(['./isObjectLike'], function(isObjectLike) {
/** `Object#toString` result references. */
var argsTag = '[object Arguments]';
/** 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 `_.isArguments`.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
*/
function baseIsArguments(value) {
return isObjectLike(value) && objectToString.call(value) == argsTag;
}
return baseIsArguments;
});

View File

@@ -1,4 +1,4 @@
define(['./_Stack', './_equalArrays', './_equalByTag', './_equalObjects', './_getTag', './isArray', './isTypedArray'], function(Stack, equalArrays, equalByTag, equalObjects, getTag, isArray, isTypedArray) {
define(['./_Stack', './_equalArrays', './_equalByTag', './_equalObjects', './_getTag', './isArray', './isBuffer', './isTypedArray'], function(Stack, equalArrays, equalByTag, equalObjects, getTag, isArray, isBuffer, isTypedArray) {
/** Used to compose bitmasks for comparison styles. */
var PARTIAL_COMPARE_FLAG = 2;
@@ -47,6 +47,13 @@ define(['./_Stack', './_equalArrays', './_equalByTag', './_equalObjects', './_ge
othIsObj = othTag == objectTag,
isSameTag = objTag == othTag;
if (isSameTag && isBuffer(object)) {
if (!isBuffer(other)) {
return false;
}
objIsArr = true;
objIsObj = false;
}
if (isSameTag && !objIsObj) {
stack || (stack = new Stack);
return (objIsArr || isTypedArray(object))

View File

@@ -1,4 +1,4 @@
define(['./_Stack', './_arrayEach', './_assignMergeValue', './_baseKeysIn', './_baseMergeDeep', './isArray', './isObject', './isTypedArray'], function(Stack, arrayEach, assignMergeValue, baseKeysIn, baseMergeDeep, isArray, isObject, isTypedArray) {
define(['./_Stack', './_assignMergeValue', './_baseFor', './_baseMergeDeep', './isObject', './keysIn'], function(Stack, assignMergeValue, baseFor, baseMergeDeep, isObject, keysIn) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -18,14 +18,7 @@ define(['./_Stack', './_arrayEach', './_assignMergeValue', './_baseKeysIn', './_
if (object === source) {
return;
}
if (!(isArray(source) || isTypedArray(source))) {
var props = baseKeysIn(source);
}
arrayEach(props || source, function(srcValue, key) {
if (props) {
key = srcValue;
srcValue = source[key];
}
baseFor(source, function(srcValue, key) {
if (isObject(srcValue)) {
stack || (stack = new Stack);
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
@@ -40,7 +33,7 @@ define(['./_Stack', './_arrayEach', './_assignMergeValue', './_baseKeysIn', './_
}
assignMergeValue(object, key, newValue);
}
});
}, keysIn);
}
return baseMerge;

View File

@@ -1,4 +1,4 @@
define(['./_assignMergeValue', './_baseClone', './_copyArray', './isArguments', './isArray', './isArrayLikeObject', './isFunction', './isObject', './isPlainObject', './isTypedArray', './toPlainObject'], function(assignMergeValue, baseClone, copyArray, isArguments, isArray, isArrayLikeObject, isFunction, isObject, isPlainObject, isTypedArray, toPlainObject) {
define(['./_assignMergeValue', './_cloneBuffer', './_cloneTypedArray', './_copyArray', './_initCloneObject', './isArguments', './isArray', './isArrayLikeObject', './isBuffer', './isFunction', './isObject', './isPlainObject', './isTypedArray', './toPlainObject'], function(assignMergeValue, cloneBuffer, cloneTypedArray, copyArray, initCloneObject, isArguments, isArray, isArrayLikeObject, isBuffer, isFunction, isObject, isPlainObject, isTypedArray, toPlainObject) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -34,29 +34,37 @@ define(['./_assignMergeValue', './_baseClone', './_copyArray', './isArguments',
var isCommon = newValue === undefined;
if (isCommon) {
var isArr = isArray(srcValue),
isBuff = !isArr && isBuffer(srcValue),
isTyped = !isArr && !isBuff && isTypedArray(srcValue);
newValue = srcValue;
if (isArray(srcValue) || isTypedArray(srcValue)) {
if (isArr || isBuff || isTyped) {
if (isArray(objValue)) {
newValue = objValue;
}
else if (isArrayLikeObject(objValue)) {
newValue = copyArray(objValue);
}
else {
else if (isBuff) {
isCommon = false;
newValue = baseClone(srcValue, true);
newValue = cloneBuffer(srcValue, true);
}
else if (isTyped) {
isCommon = false;
newValue = cloneTypedArray(srcValue, true);
}
else {
newValue = [];
}
}
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
newValue = objValue;
if (isArguments(objValue)) {
newValue = toPlainObject(objValue);
}
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
isCommon = false;
newValue = baseClone(srcValue, true);
}
else {
newValue = objValue;
newValue = initCloneObject(srcValue);
}
}
else {

15
_baseSample.js Normal file
View File

@@ -0,0 +1,15 @@
define(['./_arraySample', './values'], function(arraySample, values) {
/**
* The base implementation of `_.sample`.
*
* @private
* @param {Array|Object} collection The collection to sample.
* @returns {*} Returns the random element.
*/
function baseSample(collection) {
return arraySample(values(collection));
}
return baseSample;
});

17
_baseSampleSize.js Normal file
View File

@@ -0,0 +1,17 @@
define(['./_baseClamp', './_shuffleSelf', './values'], function(baseClamp, shuffleSelf, values) {
/**
* The base implementation of `_.sampleSize` without param guards.
*
* @private
* @param {Array|Object} collection The collection to sample.
* @param {number} n The number of elements to sample.
* @returns {Array} Returns the random elements.
*/
function baseSampleSize(collection, n) {
var array = values(collection);
return shuffleSelf(array, baseClamp(n, 0, array.length));
}
return baseSampleSize;
});

View File

@@ -1,4 +1,4 @@
define(['./constant', './identity', './_nativeDefineProperty'], function(constant, identity, nativeDefineProperty) {
define(['./constant', './_defineProperty', './identity'], function(constant, defineProperty, identity) {
/**
* The base implementation of `setToString` without support for hot loop shorting.
@@ -8,8 +8,8 @@ define(['./constant', './identity', './_nativeDefineProperty'], function(constan
* @param {Function} string The `toString` result.
* @returns {Function} Returns `func`.
*/
var baseSetToString = !nativeDefineProperty ? identity : function(func, string) {
return nativeDefineProperty(func, 'toString', {
var baseSetToString = !defineProperty ? identity : function(func, string) {
return defineProperty(func, 'toString', {
'configurable': true,
'enumerable': false,
'value': constant(string),

15
_baseShuffle.js Normal file
View File

@@ -0,0 +1,15 @@
define(['./_shuffleSelf', './values'], function(shuffleSelf, values) {
/**
* The base implementation of `_.shuffle`.
*
* @private
* @param {Array|Object} collection The collection to shuffle.
* @returns {Array} Returns the new shuffled array.
*/
function baseShuffle(collection) {
return shuffleSelf(values(collection));
}
return baseShuffle;
});

View File

@@ -1,4 +1,4 @@
define(['./_Symbol', './isSymbol'], function(Symbol, isSymbol) {
define(['./_Symbol', './_arrayMap', './isArray', './isSymbol'], function(Symbol, arrayMap, isArray, isSymbol) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -23,6 +23,10 @@ define(['./_Symbol', './isSymbol'], function(Symbol, isSymbol) {
if (typeof value == 'string') {
return value;
}
if (isArray(value)) {
// Recursively convert values (susceptible to call stack limits).
return arrayMap(value, baseToString) + '';
}
if (isSymbol(value)) {
return symbolToString ? symbolToString.call(value) : '';
}

View File

@@ -1,4 +1,20 @@
define([], function() {
define(['./_root'], function(root) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** 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;
/** Built-in value references. */
var Buffer = moduleExports ? root.Buffer : undefined,
allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
/**
* Creates a clone of `buffer`.
@@ -12,7 +28,9 @@ define([], function() {
if (isDeep) {
return buffer.slice();
}
var result = new buffer.constructor(buffer.length);
var length = buffer.length,
result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
buffer.copy(result);
return result;
}

View File

@@ -6,7 +6,7 @@ define(['./_LodashWrapper', './_flatRest', './_getData', './_getFuncName', './is
/** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200;
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/** Used to compose bitmasks for function metadata. */

View File

@@ -3,7 +3,7 @@ define(['./_baseSetData', './_createBind', './_createCurry', './_createHybrid',
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/** Used to compose bitmasks for function metadata. */

12
_defineProperty.js Normal file
View File

@@ -0,0 +1,12 @@
define(['./_getNative'], function(getNative) {
var defineProperty = (function() {
try {
var func = getNative(Object, 'defineProperty');
func({}, '', {});
return func;
} catch (e) {}
}());
return defineProperty;
});

View File

@@ -1,7 +0,0 @@
define(['./_getNative'], function(getNative) {
/* Built-in method references that are verified to be native. */
var nativeDefineProperty = getNative(Object, 'defineProperty');
return nativeDefineProperty;
});

View File

@@ -1,24 +1,30 @@
define(['./_baseRandom'], function(baseRandom) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* A specialized version of `arrayShuffle` which mutates `array`.
* A specialized version of `_.shuffle` which mutates and sets the size of `array`.
*
* @private
* @param {Array} array The array to shuffle.
* @param {number} [size=array.length] The size of `array`.
* @returns {Array} Returns `array`.
*/
function shuffleSelf(array) {
function shuffleSelf(array, size) {
var index = -1,
length = array.length,
lastIndex = length - 1;
while (++index < length) {
size = size === undefined ? length : size;
while (++index < size) {
var rand = baseRandom(index, lastIndex),
value = array[rand];
array[rand] = array[index];
array[index] = value;
}
array.length = size;
return array;
}

View File

@@ -1,6 +1,6 @@
define(['./toInteger'], function(toInteger) {
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**

View File

@@ -3,7 +3,7 @@ define(['./toInteger'], function(toInteger) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**

View File

@@ -1,6 +1,6 @@
define(['./_apply', './_arrayMap', './_baseIteratee', './_baseRest'], function(apply, arrayMap, baseIteratee, baseRest) {
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**

View File

@@ -3,7 +3,7 @@ define(['./isObject', './now', './toNumber'], function(isObject, now, toNumber)
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/* Built-in method references for those with the same name as other `lodash` methods. */

View File

@@ -1,7 +1,7 @@
define(['./_escapeHtmlChar', './toString'], function(escapeHtmlChar, toString) {
/** Used to match HTML entities and HTML characters. */
var reUnescapedHtml = /[&<>"'`]/g,
var reUnescapedHtml = /[&<>"']/g,
reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
/**

View File

@@ -1,7 +1,4 @@
define(['./isArrayLikeObject'], function(isArrayLikeObject) {
/** `Object#toString` result references. */
var argsTag = '[object Arguments]';
define(['./_baseIsArguments', './isObjectLike'], function(baseIsArguments, isObjectLike) {
/** Used for built-in method references. */
var objectProto = Object.prototype;
@@ -9,13 +6,6 @@ define(['./isArrayLikeObject'], function(isArrayLikeObject) {
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
/** Built-in value references. */
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
@@ -37,11 +27,10 @@ define(['./isArrayLikeObject'], function(isArrayLikeObject) {
* _.isArguments([1, 2, 3]);
* // => false
*/
function isArguments(value) {
// Safari 8.1 makes `arguments.callee` enumerable in strict mode.
return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
(!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
}
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
!propertyIsEnumerable.call(value, 'callee');
};
return isArguments;
});

View File

@@ -1,4 +1,4 @@
define(['./_getTag', './isArguments', './isArray', './isArrayLike', './isBuffer', './_isPrototype', './_nativeKeys'], function(getTag, isArguments, isArray, isArrayLike, isBuffer, isPrototype, nativeKeys) {
define(['./_baseKeys', './_getTag', './isArguments', './isArray', './isArrayLike', './isBuffer', './_isPrototype', './isTypedArray'], function(baseKeys, getTag, isArguments, isArray, isArrayLike, isBuffer, isPrototype, isTypedArray) {
/** `Object#toString` result references. */
var mapTag = '[object Map]',
@@ -45,8 +45,8 @@ define(['./_getTag', './isArguments', './isArray', './isArrayLike', './isBuffer'
*/
function isEmpty(value) {
if (isArrayLike(value) &&
(isArray(value) || typeof value == 'string' ||
typeof value.splice == 'function' || isBuffer(value) || isArguments(value))) {
(isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
isBuffer(value) || isTypedArray(value) || isArguments(value))) {
return !value.length;
}
var tag = getTag(value);
@@ -54,7 +54,7 @@ define(['./_getTag', './isArguments', './isArray', './isArrayLike', './isBuffer'
return !value.size;
}
if (isPrototype(value)) {
return !nativeKeys(value).length;
return !baseKeys(value).length;
}
for (var key in value) {
if (hasOwnProperty.call(value, key)) {

View File

@@ -2,7 +2,8 @@ define(['./isObject'], function(isObject) {
/** `Object#toString` result references. */
var funcTag = '[object Function]',
genTag = '[object GeneratorFunction]';
genTag = '[object GeneratorFunction]',
proxyTag = '[object Proxy]';
/** Used for built-in method references. */
var objectProto = Object.prototype;
@@ -33,9 +34,9 @@ define(['./isObject'], function(isObject) {
*/
function isFunction(value) {
// The use of `Object#toString` avoids issues with the `typeof` operator
// in Safari 8-9 which returns 'object' for typed array and other constructors.
// in Safari 9 which returns 'object' for typed array and other constructors.
var tag = isObject(value) ? objectToString.call(value) : '';
return tag == funcTag || tag == genTag;
return tag == funcTag || tag == genTag || tag == proxyTag;
}
return isFunction;

View File

@@ -1,5 +1,8 @@
define(['./_baseIsNative', './_isMaskable'], function(baseIsNative, isMaskable) {
/** Error message constants. */
var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://github.com/es-shims.';
/**
* Checks if `value` is a pristine native function.
*
@@ -28,7 +31,7 @@ define(['./_baseIsNative', './_isMaskable'], function(baseIsNative, isMaskable)
*/
function isNative(value) {
if (isMaskable(value)) {
throw new Error('This method is not supported with core-js. Try https://github.com/es-shims.');
throw new Error(CORE_ERROR_TEXT);
}
return baseIsNative(value);
}

275
main.js
View File

@@ -13,13 +13,14 @@
var undefined;
/** Used as the semantic version number. */
var VERSION = '4.16.0';
var VERSION = '4.16.4';
/** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200;
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/** Error message constants. */
var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://github.com/es-shims.',
FUNC_ERROR_TEXT = 'Expected a function';
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
@@ -95,6 +96,7 @@
numberTag = '[object Number]',
objectTag = '[object Object]',
promiseTag = '[object Promise]',
proxyTag = '[object Proxy]',
regexpTag = '[object RegExp]',
setTag = '[object Set]',
stringTag = '[object String]',
@@ -120,8 +122,8 @@
reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
/** Used to match HTML entities and HTML characters. */
var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g,
reUnescapedHtml = /[&<>"'`]/g,
var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
reUnescapedHtml = /[&<>"']/g,
reHasEscapedHtml = RegExp(reEscapedHtml.source),
reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
@@ -1408,7 +1410,7 @@
* // Create a suped-up `defer` in Node.js.
* var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
*/
function runInContext(context) {
var runInContext = (function runInContext(context) {
context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root;
/** Built-in constructor references. */
@@ -1468,7 +1470,7 @@
var Buffer = moduleExports ? context.Buffer : undefined,
Symbol = context.Symbol,
Uint8Array = context.Uint8Array,
defineProperty = Object.defineProperty,
allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
getPrototype = overArg(Object.getPrototypeOf, Object),
iteratorSymbol = Symbol ? Symbol.iterator : undefined,
objectCreate = Object.create,
@@ -1476,6 +1478,14 @@
splice = arrayProto.splice,
spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
var defineProperty = (function() {
try {
var func = getNative(Object, 'defineProperty');
func({}, '', {});
return func;
} catch (e) {}
}());
/** Mocked built-ins. */
var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
ctxNow = Date && Date.now !== root.Date.now && Date.now,
@@ -1502,8 +1512,7 @@
Promise = getNative(context, 'Promise'),
Set = getNative(context, 'Set'),
WeakMap = getNative(context, 'WeakMap'),
nativeCreate = getNative(Object, 'create'),
nativeDefineProperty = getNative(Object, 'defineProperty');
nativeCreate = getNative(Object, 'create');
/** Used to store function metadata. */
var metaMap = WeakMap && new WeakMap;
@@ -1654,6 +1663,30 @@
return new LodashWrapper(value);
}
/**
* The base implementation of `_.create` without support for assigning
* properties to the created object.
*
* @private
* @param {Object} proto The object to inherit from.
* @returns {Object} Returns the new object.
*/
var baseCreate = (function() {
function object() {}
return function(proto) {
if (!isObject(proto)) {
return {};
}
if (objectCreate) {
return objectCreate(proto);
}
object.prototype = proto;
var result = new object;
object.prototype = undefined;
return result;
};
}());
/**
* The function whose prototype chain sequence wrappers inherit from.
*
@@ -2355,18 +2388,26 @@
* @returns {Array} Returns the array of property names.
*/
function arrayLikeKeys(value, inherited) {
// Safari 8.1 makes `arguments.callee` enumerable in strict mode.
// Safari 9 makes `arguments.length` enumerable in strict mode.
var result = (isArray(value) || isArguments(value))
? baseTimes(value.length, String)
: [];
var length = result.length,
skipIndexes = !!length;
var isArr = isArray(value),
isArg = !isArr && isArguments(value),
isBuff = !isArr && !isArg && isBuffer(value),
isType = !isArr && !isArg && !isBuff && isTypedArray(value),
skipIndexes = isArr || isArg || isBuff || isType,
result = skipIndexes ? baseTimes(value.length, String) : [],
length = result.length;
for (var key in value) {
if ((inherited || hasOwnProperty.call(value, key)) &&
!(skipIndexes && (key == 'length' || isIndex(key, length)))) {
!(skipIndexes && (
// Safari 9 has enumerable `arguments.length` in strict mode.
key == 'length' ||
// Node.js 0.10 has enumerable non-index properties on buffers.
(isBuff && (key == 'offset' || key == 'parent')) ||
// PhantomJS 2 has enumerable non-index properties on typed arrays.
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
// Skip index properties.
isIndex(key, length)
))) {
result.push(key);
}
}
@@ -2374,8 +2415,7 @@
}
/**
* A specialized version of `_.sample` for arrays without support for iteratee
* shorthands.
* A specialized version of `_.sample` for arrays.
*
* @private
* @param {Array} array The array to sample.
@@ -2395,9 +2435,7 @@
* @returns {Array} Returns the random elements.
*/
function arraySampleSize(array, n) {
var result = arrayShuffle(array);
result.length = baseClamp(n, 0, result.length);
return result;
return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
}
/**
@@ -2440,7 +2478,7 @@
*/
function assignMergeValue(object, key, value) {
if ((value !== undefined && !eq(object[key], value)) ||
(typeof key == 'number' && value === undefined && !(key in object))) {
(value === undefined && !(key in object))) {
baseAssignValue(object, key, value);
}
}
@@ -2633,9 +2671,7 @@
}
stack.set(value, result);
if (!isArr) {
var props = isFull ? getAllKeys(value) : keys(value);
}
var props = isArr ? undefined : (isFull ? getAllKeys : keys)(value);
arrayEach(props || value, function(subValue, key) {
if (props) {
key = subValue;
@@ -2687,18 +2723,6 @@
return true;
}
/**
* The base implementation of `_.create` without support for assigning
* properties to the created object.
*
* @private
* @param {Object} prototype The object to inherit from.
* @returns {Object} Returns the new object.
*/
function baseCreate(proto) {
return isObject(proto) ? objectCreate(proto) : {};
}
/**
* The base implementation of `_.delay` and `_.defer` which accepts `args`
* to provide to `func`.
@@ -3181,6 +3205,17 @@
return func == null ? undefined : apply(func, object, args);
}
/**
* The base implementation of `_.isArguments`.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
*/
function baseIsArguments(value) {
return isObjectLike(value) && objectToString.call(value) == argsTag;
}
/**
* The base implementation of `_.isArrayBuffer` without Node.js optimizations.
*
@@ -3261,6 +3296,13 @@
othIsObj = othTag == objectTag,
isSameTag = objTag == othTag;
if (isSameTag && isBuffer(object)) {
if (!isBuffer(other)) {
return false;
}
objIsArr = true;
objIsObj = false;
}
if (isSameTag && !objIsObj) {
stack || (stack = new Stack);
return (objIsArr || isTypedArray(object))
@@ -3550,14 +3592,7 @@
if (object === source) {
return;
}
if (!(isArray(source) || isTypedArray(source))) {
var props = baseKeysIn(source);
}
arrayEach(props || source, function(srcValue, key) {
if (props) {
key = srcValue;
srcValue = source[key];
}
baseFor(source, function(srcValue, key) {
if (isObject(srcValue)) {
stack || (stack = new Stack);
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
@@ -3572,7 +3607,7 @@
}
assignMergeValue(object, key, newValue);
}
});
}, keysIn);
}
/**
@@ -3606,29 +3641,37 @@
var isCommon = newValue === undefined;
if (isCommon) {
var isArr = isArray(srcValue),
isBuff = !isArr && isBuffer(srcValue),
isTyped = !isArr && !isBuff && isTypedArray(srcValue);
newValue = srcValue;
if (isArray(srcValue) || isTypedArray(srcValue)) {
if (isArr || isBuff || isTyped) {
if (isArray(objValue)) {
newValue = objValue;
}
else if (isArrayLikeObject(objValue)) {
newValue = copyArray(objValue);
}
else {
else if (isBuff) {
isCommon = false;
newValue = baseClone(srcValue, true);
newValue = cloneBuffer(srcValue, true);
}
else if (isTyped) {
isCommon = false;
newValue = cloneTypedArray(srcValue, true);
}
else {
newValue = [];
}
}
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
newValue = objValue;
if (isArguments(objValue)) {
newValue = toPlainObject(objValue);
}
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
isCommon = false;
newValue = baseClone(srcValue, true);
}
else {
newValue = objValue;
newValue = initCloneObject(srcValue);
}
}
else {
@@ -3890,6 +3933,30 @@
return setToString(overRest(func, start, identity), func + '');
}
/**
* The base implementation of `_.sample`.
*
* @private
* @param {Array|Object} collection The collection to sample.
* @returns {*} Returns the random element.
*/
function baseSample(collection) {
return arraySample(values(collection));
}
/**
* The base implementation of `_.sampleSize` without param guards.
*
* @private
* @param {Array|Object} collection The collection to sample.
* @param {number} n The number of elements to sample.
* @returns {Array} Returns the random elements.
*/
function baseSampleSize(collection, n) {
var array = values(collection);
return shuffleSelf(array, baseClamp(n, 0, array.length));
}
/**
* The base implementation of `_.set`.
*
@@ -3951,8 +4018,8 @@
* @param {Function} string The `toString` result.
* @returns {Function} Returns `func`.
*/
var baseSetToString = !nativeDefineProperty ? identity : function(func, string) {
return nativeDefineProperty(func, 'toString', {
var baseSetToString = !defineProperty ? identity : function(func, string) {
return defineProperty(func, 'toString', {
'configurable': true,
'enumerable': false,
'value': constant(string),
@@ -3960,6 +4027,17 @@
});
};
/**
* The base implementation of `_.shuffle`.
*
* @private
* @param {Array|Object} collection The collection to shuffle.
* @returns {Array} Returns the new shuffled array.
*/
function baseShuffle(collection) {
return shuffleSelf(values(collection));
}
/**
* The base implementation of `_.slice` without an iteratee call guard.
*
@@ -4153,6 +4231,10 @@
if (typeof value == 'string') {
return value;
}
if (isArray(value)) {
// Recursively convert values (susceptible to call stack limits).
return arrayMap(value, baseToString) + '';
}
if (isSymbol(value)) {
return symbolToString ? symbolToString.call(value) : '';
}
@@ -4422,7 +4504,9 @@
if (isDeep) {
return buffer.slice();
}
var result = new buffer.constructor(buffer.length);
var length = buffer.length,
result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
buffer.copy(result);
return result;
}
@@ -6534,24 +6618,27 @@
}
/**
* A specialized version of `arrayShuffle` which mutates `array`.
* A specialized version of `_.shuffle` which mutates and sets the size of `array`.
*
* @private
* @param {Array} array The array to shuffle.
* @param {number} [size=array.length] The size of `array`.
* @returns {Array} Returns `array`.
*/
function shuffleSelf(array) {
function shuffleSelf(array, size) {
var index = -1,
length = array.length,
lastIndex = length - 1;
while (++index < length) {
size = size === undefined ? length : size;
while (++index < size) {
var rand = baseRandom(index, lastIndex),
value = array[rand];
array[rand] = array[index];
array[index] = value;
}
array.length = size;
return array;
}
@@ -9629,7 +9716,8 @@
* // => 2
*/
function sample(collection) {
return arraySample(isArrayLike(collection) ? collection : values(collection));
var func = isArray(collection) ? arraySample : baseSample;
return func(collection);
}
/**
@@ -9658,7 +9746,8 @@
} else {
n = toInteger(n);
}
return arraySampleSize(isArrayLike(collection) ? collection : values(collection), n);
var func = isArray(collection) ? arraySampleSize : baseSampleSize;
return func(collection, n);
}
/**
@@ -9677,10 +9766,8 @@
* // => [4, 1, 3, 2]
*/
function shuffle(collection) {
return shuffleSelf(isArrayLike(collection)
? copyArray(collection)
: values(collection)
);
var func = isArray(collection) ? arrayShuffle : baseShuffle;
return func(collection);
}
/**
@@ -11116,11 +11203,10 @@
* _.isArguments([1, 2, 3]);
* // => false
*/
function isArguments(value) {
// Safari 8.1 makes `arguments.callee` enumerable in strict mode.
return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
(!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
}
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
!propertyIsEnumerable.call(value, 'callee');
};
/**
* Checks if `value` is classified as an `Array` object.
@@ -11340,8 +11426,8 @@
*/
function isEmpty(value) {
if (isArrayLike(value) &&
(isArray(value) || typeof value == 'string' ||
typeof value.splice == 'function' || isBuffer(value) || isArguments(value))) {
(isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
isBuffer(value) || isTypedArray(value) || isArguments(value))) {
return !value.length;
}
var tag = getTag(value);
@@ -11349,7 +11435,7 @@
return !value.size;
}
if (isPrototype(value)) {
return !nativeKeys(value).length;
return !baseKeys(value).length;
}
for (var key in value) {
if (hasOwnProperty.call(value, key)) {
@@ -11504,9 +11590,9 @@
*/
function isFunction(value) {
// The use of `Object#toString` avoids issues with the `typeof` operator
// in Safari 8-9 which returns 'object' for typed array and other constructors.
// in Safari 9 which returns 'object' for typed array and other constructors.
var tag = isObject(value) ? objectToString.call(value) : '';
return tag == funcTag || tag == genTag;
return tag == funcTag || tag == genTag || tag == proxyTag;
}
/**
@@ -11779,7 +11865,7 @@
*/
function isNative(value) {
if (isMaskable(value)) {
throw new Error('This method is not supported with core-js. Try https://github.com/es-shims.');
throw new Error(CORE_ERROR_TEXT);
}
return baseIsNative(value);
}
@@ -12394,8 +12480,8 @@
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to process.
* @returns {string} Returns the string.
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
* @example
*
* _.toString(null);
@@ -13579,22 +13665,23 @@
* // => { '1': ['a', 'c'], '2': ['b'] }
*/
function transform(object, iteratee, accumulator) {
var isArr = isArray(object) || isTypedArray(object);
iteratee = getIteratee(iteratee, 4);
var isArr = isArray(object),
isArrLike = isArr || isBuffer(object) || isTypedArray(object);
iteratee = getIteratee(iteratee, 4);
if (accumulator == null) {
if (isArr || isObject(object)) {
var Ctor = object.constructor;
if (isArr) {
accumulator = isArray(object) ? new Ctor : [];
} else {
accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
}
} else {
var Ctor = object && object.constructor;
if (isArrLike) {
accumulator = isArr ? new Ctor : [];
}
else if (isObject(object)) {
accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
}
else {
accumulator = {};
}
}
(isArr ? arrayEach : baseForOwn)(object, function(value, index, object) {
(isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
return iteratee(accumulator, value, index, object);
});
return accumulator;
@@ -14272,7 +14359,7 @@
} else if (radix) {
radix = +radix;
}
return nativeParseInt(toString(string), radix || 0);
return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
}
/**
@@ -16861,7 +16948,7 @@
lodash.prototype[iteratorSymbol] = wrapperToIterator;
}
return lodash;
}
});
/*--------------------------------------------------------------------------*/

View File

@@ -1,6 +1,6 @@
define(['./_MapCache'], function(MapCache) {
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**

View File

@@ -1,6 +1,6 @@
define([], function() {
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**

View File

@@ -1,6 +1,6 @@
{
"name": "lodash-amd",
"version": "4.16.0",
"version": "4.16.4",
"description": "Lodash exported as AMD modules.",
"keywords": "amd, modules, stdlib, util",
"homepage": "https://lodash.com/custom-builds",

View File

@@ -1,5 +1,8 @@
define(['./_root', './toString'], function(root, toString) {
/** Used to match leading and trailing whitespace. */
var reTrimStart = /^\s+/;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeParseInt = root.parseInt;
@@ -33,7 +36,7 @@ define(['./_root', './toString'], function(root, toString) {
} else if (radix) {
radix = +radix;
}
return nativeParseInt(toString(string), radix || 0);
return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
}
return parseInt;

View File

@@ -3,7 +3,7 @@ define(['./_baseRest', './toInteger'], function(baseRest, toInteger) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**

View File

@@ -1,4 +1,4 @@
define(['./_arraySample', './isArrayLike', './values'], function(arraySample, isArrayLike, values) {
define(['./_arraySample', './_baseSample', './isArray'], function(arraySample, baseSample, isArray) {
/**
* Gets a random element from `collection`.
@@ -15,7 +15,8 @@ define(['./_arraySample', './isArrayLike', './values'], function(arraySample, is
* // => 2
*/
function sample(collection) {
return arraySample(isArrayLike(collection) ? collection : values(collection));
var func = isArray(collection) ? arraySample : baseSample;
return func(collection);
}
return sample;

View File

@@ -1,4 +1,4 @@
define(['./_arraySampleSize', './isArrayLike', './_isIterateeCall', './toInteger', './values'], function(arraySampleSize, isArrayLike, isIterateeCall, toInteger, values) {
define(['./_arraySampleSize', './_baseSampleSize', './isArray', './_isIterateeCall', './toInteger'], function(arraySampleSize, baseSampleSize, isArray, isIterateeCall, toInteger) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -29,7 +29,8 @@ define(['./_arraySampleSize', './isArrayLike', './_isIterateeCall', './toInteger
} else {
n = toInteger(n);
}
return arraySampleSize(isArrayLike(collection) ? collection : values(collection), n);
var func = isArray(collection) ? arraySampleSize : baseSampleSize;
return func(collection, n);
}
return sampleSize;

View File

@@ -1,4 +1,4 @@
define(['./_copyArray', './isArrayLike', './_shuffleSelf', './values'], function(copyArray, isArrayLike, shuffleSelf, values) {
define(['./_arrayShuffle', './_baseShuffle', './isArray'], function(arrayShuffle, baseShuffle, isArray) {
/**
* Creates an array of shuffled values, using a version of the
@@ -16,10 +16,8 @@ define(['./_copyArray', './isArrayLike', './_shuffleSelf', './values'], function
* // => [4, 1, 3, 2]
*/
function shuffle(collection) {
return shuffleSelf(isArrayLike(collection)
? copyArray(collection)
: values(collection)
);
var func = isArray(collection) ? arrayShuffle : baseShuffle;
return func(collection);
}
return shuffle;

View File

@@ -3,7 +3,7 @@ define(['./_apply', './_arrayPush', './_baseRest', './_castSlice', './toInteger'
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/* Built-in method references for those with the same name as other `lodash` methods. */

View File

@@ -1,6 +1,6 @@
define(['./debounce', './isObject'], function(debounce, isObject) {
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**

View File

@@ -8,8 +8,8 @@ define(['./_baseToString'], function(baseToString) {
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to process.
* @returns {string} Returns the string.
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
* @example
*
* _.toString(null);

View File

@@ -1,4 +1,4 @@
define(['./_arrayEach', './_baseCreate', './_baseForOwn', './_baseIteratee', './_getPrototype', './isArray', './isFunction', './isObject', './isTypedArray'], function(arrayEach, baseCreate, baseForOwn, baseIteratee, getPrototype, isArray, isFunction, isObject, isTypedArray) {
define(['./_arrayEach', './_baseCreate', './_baseForOwn', './_baseIteratee', './_getPrototype', './isArray', './isBuffer', './isFunction', './isObject', './isTypedArray'], function(arrayEach, baseCreate, baseForOwn, baseIteratee, getPrototype, isArray, isBuffer, isFunction, isObject, isTypedArray) {
/**
* An alternative to `_.reduce`; this method transforms `object` to a new
@@ -31,22 +31,23 @@ define(['./_arrayEach', './_baseCreate', './_baseForOwn', './_baseIteratee', './
* // => { '1': ['a', 'c'], '2': ['b'] }
*/
function transform(object, iteratee, accumulator) {
var isArr = isArray(object) || isTypedArray(object);
iteratee = baseIteratee(iteratee, 4);
var isArr = isArray(object),
isArrLike = isArr || isBuffer(object) || isTypedArray(object);
iteratee = baseIteratee(iteratee, 4);
if (accumulator == null) {
if (isArr || isObject(object)) {
var Ctor = object.constructor;
if (isArr) {
accumulator = isArray(object) ? new Ctor : [];
} else {
accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
}
} else {
var Ctor = object && object.constructor;
if (isArrLike) {
accumulator = isArr ? new Ctor : [];
}
else if (isObject(object)) {
accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
}
else {
accumulator = {};
}
}
(isArr ? arrayEach : baseForOwn)(object, function(value, index, object) {
(isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
return iteratee(accumulator, value, index, object);
});
return accumulator;

View File

@@ -1,7 +1,7 @@
define(['./toString', './_unescapeHtmlChar'], function(toString, unescapeHtmlChar) {
/** Used to match HTML entities and HTML characters. */
var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g,
var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
reHasEscapedHtml = RegExp(reEscapedHtml.source);
/**