chore: tidy

This commit is contained in:
cha0s 2019-11-11 15:29:37 -06:00
parent a0f5c0019e
commit ee6de19717
3 changed files with 13 additions and 16 deletions

View File

@ -1,13 +1,21 @@
/**
* Composes single-argument functions from right to left. The rightmost
* function can take multiple arguments as it provides the signature for
* the resulting composite function.
*
* @param {...Function} funcs The functions to compose.
* @returns {Function} A function obtained by composing the argument functions
* from right to left. For example, compose(f, g, h) is identical to doing
* (...args) => f(g(h(...args))).
*/
export function compose(...funcs) { export function compose(...funcs) {
if (funcs.length === 0) { if (funcs.length === 0) {
return arg => arg return arg => arg;
} }
if (funcs.length === 1) { if (funcs.length === 1) {
return funcs[0] return funcs[0];
} }
return funcs.reduce((a, b) => (...args) => a(b(...args)));
return funcs.reduce((a, b) => (...args) => a(b(...args)))
} }
export function fastApply(holder, fn, args) { export function fastApply(holder, fn, args) {

View File

@ -1,14 +1,3 @@
/**
* Composes single-argument functions from right to left. The rightmost
* function can take multiple arguments as it provides the signature for
* the resulting composite function.
*
* @param {...Function} funcs The functions to compose.
* @returns {Function} A function obtained by composing the argument functions
* from right to left. For example, compose(f, g, h) is identical to doing
* (...args) => f(g(h(...args))).
*/
export {arrayUnique, flatten} from './array'; export {arrayUnique, flatten} from './array';
export {EventEmitterMixin as EventEmitter} from './event-emitter'; export {EventEmitterMixin as EventEmitter} from './event-emitter';
export {merge} from './merge'; export {merge} from './merge';