https://github.com/afeiship/reduce-fns
Generate the reduceable function.
https://github.com/afeiship/reduce-fns
fns reduce
Last synced: 10 months ago
JSON representation
Generate the reduceable function.
- Host: GitHub
- URL: https://github.com/afeiship/reduce-fns
- Owner: afeiship
- License: mit
- Created: 2017-08-07T11:45:05.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2021-11-24T15:28:36.000Z (over 4 years ago)
- Last Synced: 2025-08-18T13:27:36.800Z (10 months ago)
- Topics: fns, reduce
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# reduce-fns
> Generate the reduceable function.
[![version][version-image]][version-url]
[![license][license-image]][license-url]
[![size][size-image]][size-url]
[![download][download-image]][download-url]
## installation
```shell
npm install @jswork/reduce-fns
```
## usage
```js
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](https://github.com/afeiship/reduce-fns/blob/master/LICENSE.txt).
[version-image]: https://img.shields.io/npm/v/@jswork/reduce-fns
[version-url]: https://npmjs.org/package/@jswork/reduce-fns
[license-image]: https://img.shields.io/npm/l/@jswork/reduce-fns
[license-url]: https://github.com/afeiship/reduce-fns/blob/master/LICENSE.txt
[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/reduce-fns
[size-url]: https://github.com/afeiship/reduce-fns/blob/master/dist/reduce-fns.min.js
[download-image]: https://img.shields.io/npm/dm/@jswork/reduce-fns
[download-url]: https://www.npmjs.com/package/@jswork/reduce-fns