Compare commits

...

3 Commits

Author SHA1 Message Date
John-David Dalton
d9fd2bdf9c Bump to v4.16.3. 2016-10-02 21:54:44 -07:00
John-David Dalton
ab95e7dde7 Bump to v4.16.2. 2016-09-25 13:40:14 -07:00
John-David Dalton
5425ef9a59 Bump to v4.16.1. 2016-09-20 09:50:26 -07:00
38 changed files with 170 additions and 72 deletions

View File

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

View File

@@ -1,8 +1,7 @@
import baseRandom from './_baseRandom.js';
/**
* 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,5 +1,5 @@
import arrayShuffle from './_arrayShuffle.js';
import baseClamp from './_baseClamp.js';
import copyArray from './_copyArray.js';
import shuffleSelf from './_shuffleSelf.js';
/**
* A specialized version of `_.sampleSize` for arrays.
@@ -10,9 +10,7 @@ import baseClamp from './_baseClamp.js';
* @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), n);
}
export default arraySampleSize;

View File

@@ -12,7 +12,7 @@ import eq from './eq.js';
*/
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,5 +1,4 @@
/** Built-in value references. */
var defineProperty = Object.defineProperty;
import defineProperty from './_defineProperty.js';
/**
* The base implementation of `assignValue` and `assignMergeValue` without

View File

@@ -8,11 +8,23 @@ var objectCreate = Object.create;
* 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;
};
}());
export default baseCreate;

View File

@@ -1,4 +1,4 @@
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**

View File

@@ -4,6 +4,7 @@ import equalByTag from './_equalByTag.js';
import equalObjects from './_equalObjects.js';
import getTag from './_getTag.js';
import isArray from './isArray.js';
import isBuffer from './isBuffer.js';
import isTypedArray from './isTypedArray.js';
/** Used to compose bitmasks for comparison styles. */
@@ -53,6 +54,13 @@ function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
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,6 +1,7 @@
import assignMergeValue from './_assignMergeValue.js';
import baseClone from './_baseClone.js';
import cloneTypedArray from './_cloneTypedArray.js';
import copyArray from './_copyArray.js';
import initCloneObject from './_initCloneObject.js';
import isArguments from './isArguments.js';
import isArray from './isArray.js';
import isArrayLikeObject from './isArrayLikeObject.js';
@@ -41,29 +42,32 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
var isCommon = newValue === undefined;
if (isCommon) {
var isArr = isArray(srcValue),
isTyped = !isArr && isTypedArray(srcValue);
newValue = srcValue;
if (isArray(srcValue) || isTypedArray(srcValue)) {
if (isArr || isTyped) {
if (isArray(objValue)) {
newValue = objValue;
}
else if (isArrayLikeObject(objValue)) {
newValue = copyArray(objValue);
}
else {
else if (isTyped) {
isCommon = false;
newValue = baseClone(srcValue, true);
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 @@
import arraySample from './_arraySample.js';
import values from './values.js';
/**
* 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));
}
export default baseSample;

16
_baseSampleSize.js Normal file
View File

@@ -0,0 +1,16 @@
import shuffleSelf from './_shuffleSelf.js';
import values from './values.js';
/**
* 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) {
return shuffleSelf(values(collection), n);
}
export default baseSampleSize;

View File

@@ -1,6 +1,6 @@
import constant from './constant.js';
import defineProperty from './_defineProperty.js';
import identity from './identity.js';
import nativeDefineProperty from './_nativeDefineProperty.js';
/**
* The base implementation of `setToString` without support for hot loop shorting.
@@ -10,8 +10,8 @@ import nativeDefineProperty from './_nativeDefineProperty.js';
* @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 @@
import shuffleSelf from './_shuffleSelf.js';
import values from './values.js';
/**
* 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));
}
export default baseShuffle;

View File

@@ -1,3 +1,18 @@
import root from './_root.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;
/** Built-in value references. */
var Buffer = moduleExports ? root.Buffer : undefined,
allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
/**
* Creates a clone of `buffer`.
*
@@ -10,7 +25,9 @@ function cloneBuffer(buffer, isDeep) {
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

@@ -8,7 +8,7 @@ import isLaziable from './_isLaziable.js';
/** 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

@@ -9,7 +9,7 @@ import setData from './_setData.js';
import setWrapToString from './_setWrapToString.js';
import toInteger from './toInteger.js';
/** 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. */

11
_defineProperty.js Normal file
View File

@@ -0,0 +1,11 @@
import getNative from './_getNative.js';
var defineProperty = (function() {
try {
var func = getNative(Object, 'defineProperty');
func({}, '', {});
return func;
} catch (e) {}
}());
export default defineProperty;

View File

@@ -1,6 +0,0 @@
import getNative from './_getNative.js';
/* Built-in method references that are verified to be native. */
var nativeDefineProperty = getNative(Object, 'defineProperty');
export default nativeDefineProperty;

View File

@@ -1,24 +1,28 @@
import baseClamp from './_baseClamp.js';
import baseRandom from './_baseRandom.js';
/**
* 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 : baseClamp(size, 0, length);
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 @@
import toInteger from './toInteger.js';
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**

View File

@@ -1,6 +1,6 @@
import toInteger from './toInteger.js';
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**

View File

@@ -3,7 +3,7 @@ import arrayMap from './_arrayMap.js';
import baseIteratee from './_baseIteratee.js';
import baseRest from './_baseRest.js';
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**

View File

@@ -2,7 +2,7 @@ import isObject from './isObject.js';
import now from './now.js';
import toNumber from './toNumber.js';
/** 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

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

View File

@@ -2,7 +2,8 @@ import isObject from './isObject.js';
/** `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;
@@ -35,7 +36,7 @@ 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.
var tag = isObject(value) ? objectToString.call(value) : '';
return tag == funcTag || tag == genTag;
return tag == funcTag || tag == genTag || tag == proxyTag;
}
export default isFunction;

View File

@@ -1,6 +1,9 @@
import baseIsNative from './_baseIsNative.js';
import isMaskable from './_isMaskable.js';
/** 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.
*
@@ -29,7 +32,7 @@ import isMaskable from './_isMaskable.js';
*/
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);
}

View File

@@ -45,7 +45,7 @@ import toInteger from './toInteger.js';
import lodash from './wrapperLodash.js';
/** Used as the semantic version number. */
var VERSION = '4.16.0';
var VERSION = '4.16.3';
/** Used to compose bitmasks for function metadata. */
var BIND_KEY_FLAG = 2;

View File

@@ -1,6 +1,6 @@
import MapCache from './_MapCache.js';
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**

View File

@@ -1,4 +1,4 @@
/** 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-es",
"version": "4.16.0",
"version": "4.16.3",
"description": "Lodash exported as ES modules.",
"keywords": "es6, modules, stdlib, util",
"homepage": "https://lodash.com/custom-builds",

View File

@@ -1,6 +1,9 @@
import root from './_root.js';
import toString from './toString.js';
/** 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;
@@ -34,7 +37,7 @@ function parseInt(string, radix, guard) {
} else if (radix) {
radix = +radix;
}
return nativeParseInt(toString(string), radix || 0);
return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
}
export default parseInt;

View File

@@ -1,7 +1,7 @@
import baseRest from './_baseRest.js';
import toInteger from './toInteger.js';
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**

View File

@@ -1,6 +1,6 @@
import arraySample from './_arraySample.js';
import isArrayLike from './isArrayLike.js';
import values from './values.js';
import baseSample from './_baseSample.js';
import isArray from './isArray.js';
/**
* Gets a random element from `collection`.
@@ -17,7 +17,8 @@ import values from './values.js';
* // => 2
*/
function sample(collection) {
return arraySample(isArrayLike(collection) ? collection : values(collection));
var func = isArray(collection) ? arraySample : baseSample;
return func(collection);
}
export default sample;

View File

@@ -1,8 +1,8 @@
import arraySampleSize from './_arraySampleSize.js';
import isArrayLike from './isArrayLike.js';
import baseSampleSize from './_baseSampleSize.js';
import isArray from './isArray.js';
import isIterateeCall from './_isIterateeCall.js';
import toInteger from './toInteger.js';
import values from './values.js';
/**
* Gets `n` random elements at unique keys from `collection` up to the
@@ -30,7 +30,8 @@ function sampleSize(collection, n, guard) {
} else {
n = toInteger(n);
}
return arraySampleSize(isArrayLike(collection) ? collection : values(collection), n);
var func = isArray(collection) ? arraySampleSize : baseSampleSize;
return func(collection, n);
}
export default sampleSize;

View File

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

View File

@@ -4,7 +4,7 @@ import baseRest from './_baseRest.js';
import castSlice from './_castSlice.js';
import toInteger from './toInteger.js';
/** 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 @@
import debounce from './debounce.js';
import isObject from './isObject.js';
/** Used as the `TypeError` message for "Functions" methods. */
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**

View File

@@ -2,7 +2,7 @@ import toString from './toString.js';
import unescapeHtmlChar from './_unescapeHtmlChar.js';
/** 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);
/**