Compare commits

...

1 Commits

Author SHA1 Message Date
John-David Dalton
ab95e7dde7 Bump to v4.16.2. 2016-09-25 13:40:14 -07:00
28 changed files with 128 additions and 47 deletions

View File

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

@@ -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 = prototype;
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';
/**

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;

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. */

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

@@ -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.1';
var VERSION = '4.16.2';
/** 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.1",
"version": "4.16.2",
"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';
/**