Sha256: 8faf9d6fdcf6e254dbedaf61225750a2b270bbdebc904fee78facfd59d8ba69e

Contents?: true

Size: 654 Bytes

Versions: 17

Compression:

Stored size: 654 Bytes

Contents

/**
 * 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 default function compose(...funcs) {
  if (funcs.length === 0) {
    return (arg) => arg
  }

  if (funcs.length === 1) {
    return funcs[0]
  }

  return funcs.reduce((a, b) => (...args) => a(b(...args)))
}

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
isomorfeus-redux-4.2.0 node_modules/redux/src/compose.js
isomorfeus-redux-4.1.18 node_modules/redux/src/compose.js
isomorfeus-redux-4.1.17 node_modules/redux/src/compose.js
isomorfeus-redux-4.1.16 node_modules/redux/src/compose.js
isomorfeus-redux-4.1.15 node_modules/redux/src/compose.js
isomorfeus-redux-4.1.14 node_modules/redux/src/compose.js
isomorfeus-redux-4.1.13 node_modules/redux/src/compose.js
isomorfeus-redux-4.1.12 node_modules/redux/src/compose.js
isomorfeus-redux-4.1.11 node_modules/redux/src/compose.js
isomorfeus-redux-4.1.10 node_modules/redux/src/compose.js
isomorfeus-redux-4.1.9 node_modules/redux/src/compose.js
isomorfeus-redux-4.1.8 node_modules/redux/src/compose.js
isomorfeus-redux-4.1.7 node_modules/redux/src/compose.js
isomorfeus-redux-4.1.6 node_modules/redux/src/compose.js
isomorfeus-redux-4.1.5 node_modules/redux/src/compose.js
isomorfeus-redux-4.1.4 node_modules/redux/src/compose.js
isomorfeus-redux-4.1.3 node_modules/redux/src/compose.js