-
Notifications
You must be signed in to change notification settings - Fork 0
reduce
김태헌 edited this page Sep 26, 2024
·
4 revisions
import { reduce } from 'mori-ts';
const numbers = [1, 2, 3, 4, 5];
const result = reduce((acc, value) => acc + value, 0, numbers);
console.log(result); // 15
import { reduce } from 'mori-ts';
const objects = [{ x: 1 }, { x: 2 }, { x: 3 }, { x: 4 }, { x: 5 }];
const result = reduce((acc, value) => acc + value.x, 0, objects);
console.log(result); // 15
import { reduce, pipe, toAsync } from 'mori-ts';
const iter = [1, 2, 3];
const res = pipe(
iter,
toAsync,
reduce((acc, value) => acc + value),
); // 출력: 6
https://github.com/gangnamssal/mori-ts/blob/main/src/test/reduce.spec.ts