-
Notifications
You must be signed in to change notification settings - Fork 0
find
김태헌 edited this page Sep 16, 2024
·
5 revisions
import { find } from 'mori-ts';
const array = [1, 2, 3, 4, 5];
const result = find(x => x > 2, array);
console.log(result); // 출력: 3
import { find } from 'mori-ts';
const result = find(x => x > 5, [1, 2, 3, 4, 5]);
console.log(result); // 출력: undefined
import { pipe, map, find, toAsync } from 'mori-ts';
const iter = [1, 2, 3, 4, 5];
const result = pipe(
iter,
map(x => x * 2),
find(x => x > 5),
);
console.log(result); // 출력: 6
const result2 = await pipe(
iter,
toAsync,
map(x => x * 2),
find(x => x > 5),
);
console.log(result); // 출력: 6
https://github.com/gangnamssal/mori-ts/blob/main/src/core/find/find.spec.ts