pipeLazy() function
왼쪽에서 오른쪽으로 함수 합성을 수행하는 함수를 만듭니다. 모든 인자는 단항이어야 합니다.
Signature:
typescript
declare function pipeLazy<T1, R>(
f1: (a: Awaited<T1>) => R,
): ((a: T1) => ReturnPipeType<[T1, R]>) &
((a: Promise<T1>) => ReturnPipeType<[Promise<T1>, R]>);Example
ts
pipeLazy(
map((a) => a + 10),
filter((a) => a % 2 === 0),
toArray,
)([1, 2, 3, 4, 5]); // [12, 14]
await pipeLazy(
map((a) => a + 10),
filter((a) => a % 2 === 0),
toArray,
)(Promise.resolve([1, 2, 3, 4, 5])); // [12, 14]
// if you want to use asynchronous callback
await pipeLazy(
toAsync,
map(async (a) => a + 10),
filter((a) => a % 2 === 0),
toArray,
)(Promise.resolve([1, 2, 3, 4, 5])); // [12, 14]
// with toAsync
await pipeLazy(
toAsync,
map((a) => a + 10),
filter((a) => a % 2 === 0),
toArray,
)([
Promise.resolve(1),
Promise.resolve(2),
Promise.resolve(3),
Promise.resolve(4),
Promise.resolve(5),
]); // [12, 14]