From ee6de19717285fbd3947bf9dd27a918e595416ee Mon Sep 17 00:00:00 2001 From: cha0s Date: Mon, 11 Nov 2019 15:29:37 -0600 Subject: [PATCH] chore: tidy --- packages/core/fast-apply.js | 0 packages/core/function.js | 18 +++++++++++++----- packages/core/index.js | 11 ----------- 3 files changed, 13 insertions(+), 16 deletions(-) delete mode 100644 packages/core/fast-apply.js diff --git a/packages/core/fast-apply.js b/packages/core/fast-apply.js deleted file mode 100644 index e69de29..0000000 diff --git a/packages/core/function.js b/packages/core/function.js index 35d9ac7..66dd4bf 100644 --- a/packages/core/function.js +++ b/packages/core/function.js @@ -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) { if (funcs.length === 0) { - return arg => arg + return arg => arg; } - 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) { diff --git a/packages/core/index.js b/packages/core/index.js index 4c7027a..d454277 100644 --- a/packages/core/index.js +++ b/packages/core/index.js @@ -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 {EventEmitterMixin as EventEmitter} from './event-emitter'; export {merge} from './merge';