@0ti.me/tiny-pfp 中文文档教程
tiny-pfp
lodash 的轻量级替代品。
Functional Programming
const {fp} = require('@0ti.me/tiny-pfp');
const mapReduce = (mapFn, reduceFn, initialAccumulator) =>
flow([fp.map(mapFn), fp.reduce(reduceFn, initialAccumulator)]);
const data = [1, 2, 3];
const result = mapReduce(each => 3 * each, (acc, each) => acc + each, 0)(data);
console.error(result); // Outputs the sum of 3x each item in data: 18
tiny-pfp
A lightweight alternative to lodash.
Functional Programming
const {fp} = require('@0ti.me/tiny-pfp');
const mapReduce = (mapFn, reduceFn, initialAccumulator) =>
flow([fp.map(mapFn), fp.reduce(reduceFn, initialAccumulator)]);
const data = [1, 2, 3];
const result = mapReduce(each => 3 * each, (acc, each) => acc + each, 0)(data);
console.error(result); // Outputs the sum of 3x each item in data: 18