mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 00:27:50 +00:00
Remove semicolons.
This commit is contained in:
34
spread.js
34
spread.js
@@ -1,10 +1,10 @@
|
||||
import apply from './.internal/apply.js';
|
||||
import arrayPush from './.internal/arrayPush.js';
|
||||
import castSlice from './.internal/castSlice.js';
|
||||
import toInteger from './toInteger.js';
|
||||
import apply from './.internal/apply.js'
|
||||
import arrayPush from './.internal/arrayPush.js'
|
||||
import castSlice from './.internal/castSlice.js'
|
||||
import toInteger from './toInteger.js'
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
const nativeMax = Math.max;
|
||||
const nativeMax = Math.max
|
||||
|
||||
/**
|
||||
* Creates a function that invokes `func` with the `this` binding of the
|
||||
@@ -21,33 +21,33 @@ const nativeMax = Math.max;
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
* const say = spread((who, what) => `${ who } says ${ what }`);
|
||||
* const say = spread((who, what) => `${ who } says ${ what }`)
|
||||
*
|
||||
* say(['fred', 'hello']);
|
||||
* say(['fred', 'hello'])
|
||||
* // => 'fred says hello'
|
||||
*
|
||||
* const numbers = Promise.all([
|
||||
* Promise.resolve(40),
|
||||
* Promise.resolve(36)
|
||||
* ]);
|
||||
* ])
|
||||
*
|
||||
* numbers.then(spread((x, y) => x + y));
|
||||
* numbers.then(spread((x, y) => x + y))
|
||||
* // => a Promise of 76
|
||||
*/
|
||||
function spread(func, start) {
|
||||
if (typeof func != 'function') {
|
||||
throw new TypeError('Expected a function');
|
||||
throw new TypeError('Expected a function')
|
||||
}
|
||||
start = start == null ? 0 : nativeMax(toInteger(start), 0);
|
||||
start = start == null ? 0 : nativeMax(toInteger(start), 0)
|
||||
return (...args) => {
|
||||
const array = args[start];
|
||||
const otherArgs = castSlice(args, 0, start);
|
||||
const array = args[start]
|
||||
const otherArgs = castSlice(args, 0, start)
|
||||
|
||||
if (array) {
|
||||
arrayPush(otherArgs, array);
|
||||
arrayPush(otherArgs, array)
|
||||
}
|
||||
return apply(func, this, otherArgs);
|
||||
};
|
||||
return apply(func, this, otherArgs)
|
||||
}
|
||||
}
|
||||
|
||||
export default spread;
|
||||
export default spread
|
||||
|
||||
Reference in New Issue
Block a user