Skip to content

afeiship/reduce-fns

Repository files navigation

reduce-fns

Generate the reduceable function.

version license size download

installation

npm install @jswork/reduce-fns

usage

import reduceFns from '@jswork/reduce-fns';

const sum = (a, b) => a + b;
const mul = (a, b) => a * b;
const sumAll = reduceFns(
  () => 0,
  (args) => args[0],
  sum
);
const mulAll = reduceFns(
  () => 1,
  (args) => args[0],
  mul
);

console.log(sumAll(1, 2, 3))          // 6
console.log(mulAll(1, 2, 3, 4, 5))    // 120

license

Code released under the MIT license.

About

Generate the reduceable function.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published