mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Simplify _.shuffle and iterator options.
Former-commit-id: 341fd577d65725d47b26172d25b46dec2ac8e67f
This commit is contained in:
2
build.js
2
build.js
@@ -138,7 +138,7 @@
|
|||||||
'reject': ['identity'],
|
'reject': ['identity'],
|
||||||
'rest': [],
|
'rest': [],
|
||||||
'result': ['isFunction'],
|
'result': ['isFunction'],
|
||||||
'shuffle': [],
|
'shuffle': ['random'],
|
||||||
'size': ['keys'],
|
'size': ['keys'],
|
||||||
'some': ['identity'],
|
'some': ['identity'],
|
||||||
'sortBy': ['identity'],
|
'sortBy': ['identity'],
|
||||||
|
|||||||
@@ -80,6 +80,7 @@
|
|||||||
|
|
||||||
/* Native method shortcuts for methods with the same name as other `lodash` methods */
|
/* Native method shortcuts for methods with the same name as other `lodash` methods */
|
||||||
var nativeBind = reNative.test(nativeBind = slice.bind) && nativeBind,
|
var nativeBind = reNative.test(nativeBind = slice.bind) && nativeBind,
|
||||||
|
nativeCeil = Math.ceil,
|
||||||
nativeFloor = Math.floor,
|
nativeFloor = Math.floor,
|
||||||
nativeGetPrototypeOf = reNative.test(nativeGetPrototypeOf = Object.getPrototypeOf) && nativeGetPrototypeOf,
|
nativeGetPrototypeOf = reNative.test(nativeGetPrototypeOf = Object.getPrototypeOf) && nativeGetPrototypeOf,
|
||||||
nativeIsArray = reNative.test(nativeIsArray = Array.isArray) && nativeIsArray,
|
nativeIsArray = reNative.test(nativeIsArray = Array.isArray) && nativeIsArray,
|
||||||
@@ -430,7 +431,6 @@
|
|||||||
*/
|
*/
|
||||||
var baseIteratorOptions = {
|
var baseIteratorOptions = {
|
||||||
'args': 'collection, callback, thisArg',
|
'args': 'collection, callback, thisArg',
|
||||||
'init': 'collection',
|
|
||||||
'top': 'callback = createCallback(callback, thisArg)',
|
'top': 'callback = createCallback(callback, thisArg)',
|
||||||
'inLoop': 'if (callback(value, index, collection) === false) return result'
|
'inLoop': 'if (callback(value, index, collection) === false) return result'
|
||||||
};
|
};
|
||||||
@@ -455,7 +455,6 @@
|
|||||||
'useHas': false,
|
'useHas': false,
|
||||||
'useStrict': false,
|
'useStrict': false,
|
||||||
'args': 'object',
|
'args': 'object',
|
||||||
'init': 'object',
|
|
||||||
'top':
|
'top':
|
||||||
'for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {\n' +
|
'for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {\n' +
|
||||||
' if (iteratee = arguments[argsIndex]) {',
|
' if (iteratee = arguments[argsIndex]) {',
|
||||||
@@ -2807,7 +2806,7 @@
|
|||||||
// use `Array(length)` so V8 will avoid the slower "dictionary" mode
|
// use `Array(length)` so V8 will avoid the slower "dictionary" mode
|
||||||
// http://www.youtube.com/watch?v=XAqIpGU8ZZk#t=16m27s
|
// http://www.youtube.com/watch?v=XAqIpGU8ZZk#t=16m27s
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = nativeMax(0, Math.ceil((end - start) / step)),
|
length = nativeMax(0, nativeCeil((end - start) / step)),
|
||||||
result = Array(length);
|
result = Array(length);
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
@@ -2861,7 +2860,7 @@
|
|||||||
result = Array(length);
|
result = Array(length);
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var rand = nativeFloor(nativeRandom() * (index + 1));
|
var rand = random(index);
|
||||||
result[index] = result[rand];
|
result[index] = result[rand];
|
||||||
result[rand] = array[index];
|
result[rand] = array[index];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user