From e0d562950e35d81896653f203f2bfd6bf8cf2145 Mon Sep 17 00:00:00 2001 From: Alisue Date: Thu, 22 Aug 2024 19:21:30 +0900 Subject: [PATCH] feat: rename `Operator` to `AsyncOperator` --- async/mod.ts | 445 ++++++++++++++++++++++++++------------------------- 1 file changed, 225 insertions(+), 220 deletions(-) diff --git a/async/mod.ts b/async/mod.ts index 8519f23..5701aa9 100644 --- a/async/mod.ts +++ b/async/mod.ts @@ -1,14 +1,16 @@ /** - * Operator function that takes a value and returns a new value. + * AsyncOperator function that takes a value and returns a new value. */ -export type Operator = (v: A) => B | Promise; +export type AsyncOperator = (v: A) => B | Promise; /** * @internal */ -type LastOperatorReturn[]> = - T extends [...Operator[], Operator] ? R - : never; +type LastAsyncOperatorReturn< + T extends AsyncOperator[], +> = T extends + [...AsyncOperator[], AsyncOperator] ? R + : never; /** * Pipes a value through a series of asynchronous operator functions. @@ -17,7 +19,7 @@ type LastOperatorReturn[]> = * > [!NOTE] * > * > If the number of operators exceeds 20, the operator functions' types will default to - * > `Operator`, requiring explicit type annotations. + * > `AsyncOperator`, requiring explicit type annotations. * * @param value - The initial value to be processed through the operators. * @param operators - A sequence of functions to apply to the value. @@ -37,101 +39,104 @@ type LastOperatorReturn[]> = * ``` */ export function pipe(value: V): Promise; -export function pipe(value: V, o01: Operator): Promise; +export function pipe( + value: V, + o01: AsyncOperator, +): Promise; export function pipe( value: V, - o01: Operator, - o02: Operator, + o01: AsyncOperator, + o02: AsyncOperator, ): Promise; export function pipe( value: V, - o01: Operator, - o02: Operator, - o03: Operator, + o01: AsyncOperator, + o02: AsyncOperator, + o03: AsyncOperator, ): Promise; export function pipe( value: V, - o01: Operator, - o02: Operator, - o03: Operator, - o04: Operator, + o01: AsyncOperator, + o02: AsyncOperator, + o03: AsyncOperator, + o04: AsyncOperator, ): Promise; export function pipe( value: V, - o01: Operator, - o02: Operator, - o03: Operator, - o04: Operator, - o05: Operator, + o01: AsyncOperator, + o02: AsyncOperator, + o03: AsyncOperator, + o04: AsyncOperator, + o05: AsyncOperator, ): Promise; export function pipe( value: V, - o01: Operator, - o02: Operator, - o03: Operator, - o04: Operator, - o05: Operator, - o06: Operator, + o01: AsyncOperator, + o02: AsyncOperator, + o03: AsyncOperator, + o04: AsyncOperator, + o05: AsyncOperator, + o06: AsyncOperator, ): Promise; export function pipe( value: V, - o01: Operator, - o02: Operator, - o03: Operator, - o04: Operator, - o05: Operator, - o06: Operator, - o07: Operator, + o01: AsyncOperator, + o02: AsyncOperator, + o03: AsyncOperator, + o04: AsyncOperator, + o05: AsyncOperator, + o06: AsyncOperator, + o07: AsyncOperator, ): Promise; export function pipe( value: V, - o01: Operator, - o02: Operator, - o03: Operator, - o04: Operator, - o05: Operator, - o06: Operator, - o07: Operator, - o08: Operator, + o01: AsyncOperator, + o02: AsyncOperator, + o03: AsyncOperator, + o04: AsyncOperator, + o05: AsyncOperator, + o06: AsyncOperator, + o07: AsyncOperator, + o08: AsyncOperator, ): Promise; export function pipe( value: V, - o01: Operator, - o02: Operator, - o03: Operator, - o04: Operator, - o05: Operator, - o06: Operator, - o07: Operator, - o08: Operator, - o09: Operator, + o01: AsyncOperator, + o02: AsyncOperator, + o03: AsyncOperator, + o04: AsyncOperator, + o05: AsyncOperator, + o06: AsyncOperator, + o07: AsyncOperator, + o08: AsyncOperator, + o09: AsyncOperator, ): Promise; export function pipe( value: V, - o01: Operator, - o02: Operator, - o03: Operator, - o04: Operator, - o05: Operator, - o06: Operator, - o07: Operator, - o08: Operator, - o09: Operator, - o10: Operator, + o01: AsyncOperator, + o02: AsyncOperator, + o03: AsyncOperator, + o04: AsyncOperator, + o05: AsyncOperator, + o06: AsyncOperator, + o07: AsyncOperator, + o08: AsyncOperator, + o09: AsyncOperator, + o10: AsyncOperator, ): Promise; export function pipe( value: V, - o01: Operator, - o02: Operator, - o03: Operator, - o04: Operator, - o05: Operator, - o06: Operator, - o07: Operator, - o08: Operator, - o09: Operator, - o10: Operator, - o11: Operator, + o01: AsyncOperator, + o02: AsyncOperator, + o03: AsyncOperator, + o04: AsyncOperator, + o05: AsyncOperator, + o06: AsyncOperator, + o07: AsyncOperator, + o08: AsyncOperator, + o09: AsyncOperator, + o10: AsyncOperator, + o11: AsyncOperator, ): Promise; export function pipe< V, @@ -149,18 +154,18 @@ export function pipe< T12, >( value: V, - o01: Operator, - o02: Operator, - o03: Operator, - o04: Operator, - o05: Operator, - o06: Operator, - o07: Operator, - o08: Operator, - o09: Operator, - o10: Operator, - o11: Operator, - o12: Operator, + o01: AsyncOperator, + o02: AsyncOperator, + o03: AsyncOperator, + o04: AsyncOperator, + o05: AsyncOperator, + o06: AsyncOperator, + o07: AsyncOperator, + o08: AsyncOperator, + o09: AsyncOperator, + o10: AsyncOperator, + o11: AsyncOperator, + o12: AsyncOperator, ): Promise; export function pipe< V, @@ -179,19 +184,19 @@ export function pipe< T13, >( value: V, - o01: Operator, - o02: Operator, - o03: Operator, - o04: Operator, - o05: Operator, - o06: Operator, - o07: Operator, - o08: Operator, - o09: Operator, - o10: Operator, - o11: Operator, - o12: Operator, - o13: Operator, + o01: AsyncOperator, + o02: AsyncOperator, + o03: AsyncOperator, + o04: AsyncOperator, + o05: AsyncOperator, + o06: AsyncOperator, + o07: AsyncOperator, + o08: AsyncOperator, + o09: AsyncOperator, + o10: AsyncOperator, + o11: AsyncOperator, + o12: AsyncOperator, + o13: AsyncOperator, ): Promise; export function pipe< V, @@ -211,20 +216,20 @@ export function pipe< T14, >( value: V, - o01: Operator, - o02: Operator, - o03: Operator, - o04: Operator, - o05: Operator, - o06: Operator, - o07: Operator, - o08: Operator, - o09: Operator, - o10: Operator, - o11: Operator, - o12: Operator, - o13: Operator, - o14: Operator, + o01: AsyncOperator, + o02: AsyncOperator, + o03: AsyncOperator, + o04: AsyncOperator, + o05: AsyncOperator, + o06: AsyncOperator, + o07: AsyncOperator, + o08: AsyncOperator, + o09: AsyncOperator, + o10: AsyncOperator, + o11: AsyncOperator, + o12: AsyncOperator, + o13: AsyncOperator, + o14: AsyncOperator, ): Promise; export function pipe< V, @@ -245,21 +250,21 @@ export function pipe< T15, >( value: V, - o01: Operator, - o02: Operator, - o03: Operator, - o04: Operator, - o05: Operator, - o06: Operator, - o07: Operator, - o08: Operator, - o09: Operator, - o10: Operator, - o11: Operator, - o12: Operator, - o13: Operator, - o14: Operator, - o15: Operator, + o01: AsyncOperator, + o02: AsyncOperator, + o03: AsyncOperator, + o04: AsyncOperator, + o05: AsyncOperator, + o06: AsyncOperator, + o07: AsyncOperator, + o08: AsyncOperator, + o09: AsyncOperator, + o10: AsyncOperator, + o11: AsyncOperator, + o12: AsyncOperator, + o13: AsyncOperator, + o14: AsyncOperator, + o15: AsyncOperator, ): Promise; export function pipe< V, @@ -281,22 +286,22 @@ export function pipe< T16, >( value: V, - o01: Operator, - o02: Operator, - o03: Operator, - o04: Operator, - o05: Operator, - o06: Operator, - o07: Operator, - o08: Operator, - o09: Operator, - o10: Operator, - o11: Operator, - o12: Operator, - o13: Operator, - o14: Operator, - o15: Operator, - o16: Operator, + o01: AsyncOperator, + o02: AsyncOperator, + o03: AsyncOperator, + o04: AsyncOperator, + o05: AsyncOperator, + o06: AsyncOperator, + o07: AsyncOperator, + o08: AsyncOperator, + o09: AsyncOperator, + o10: AsyncOperator, + o11: AsyncOperator, + o12: AsyncOperator, + o13: AsyncOperator, + o14: AsyncOperator, + o15: AsyncOperator, + o16: AsyncOperator, ): Promise; export function pipe< V, @@ -319,23 +324,23 @@ export function pipe< T17, >( value: V, - o01: Operator, - o02: Operator, - o03: Operator, - o04: Operator, - o05: Operator, - o06: Operator, - o07: Operator, - o08: Operator, - o09: Operator, - o10: Operator, - o11: Operator, - o12: Operator, - o13: Operator, - o14: Operator, - o15: Operator, - o16: Operator, - o17: Operator, + o01: AsyncOperator, + o02: AsyncOperator, + o03: AsyncOperator, + o04: AsyncOperator, + o05: AsyncOperator, + o06: AsyncOperator, + o07: AsyncOperator, + o08: AsyncOperator, + o09: AsyncOperator, + o10: AsyncOperator, + o11: AsyncOperator, + o12: AsyncOperator, + o13: AsyncOperator, + o14: AsyncOperator, + o15: AsyncOperator, + o16: AsyncOperator, + o17: AsyncOperator, ): Promise; export function pipe< V, @@ -359,24 +364,24 @@ export function pipe< T18, >( value: V, - o01: Operator, - o02: Operator, - o03: Operator, - o04: Operator, - o05: Operator, - o06: Operator, - o07: Operator, - o08: Operator, - o09: Operator, - o10: Operator, - o11: Operator, - o12: Operator, - o13: Operator, - o14: Operator, - o15: Operator, - o16: Operator, - o17: Operator, - o18: Operator, + o01: AsyncOperator, + o02: AsyncOperator, + o03: AsyncOperator, + o04: AsyncOperator, + o05: AsyncOperator, + o06: AsyncOperator, + o07: AsyncOperator, + o08: AsyncOperator, + o09: AsyncOperator, + o10: AsyncOperator, + o11: AsyncOperator, + o12: AsyncOperator, + o13: AsyncOperator, + o14: AsyncOperator, + o15: AsyncOperator, + o16: AsyncOperator, + o17: AsyncOperator, + o18: AsyncOperator, ): Promise; export function pipe< V, @@ -401,25 +406,25 @@ export function pipe< T19, >( value: V, - o01: Operator, - o02: Operator, - o03: Operator, - o04: Operator, - o05: Operator, - o06: Operator, - o07: Operator, - o08: Operator, - o09: Operator, - o10: Operator, - o11: Operator, - o12: Operator, - o13: Operator, - o14: Operator, - o15: Operator, - o16: Operator, - o17: Operator, - o18: Operator, - o19: Operator, + o01: AsyncOperator, + o02: AsyncOperator, + o03: AsyncOperator, + o04: AsyncOperator, + o05: AsyncOperator, + o06: AsyncOperator, + o07: AsyncOperator, + o08: AsyncOperator, + o09: AsyncOperator, + o10: AsyncOperator, + o11: AsyncOperator, + o12: AsyncOperator, + o13: AsyncOperator, + o14: AsyncOperator, + o15: AsyncOperator, + o16: AsyncOperator, + o17: AsyncOperator, + o18: AsyncOperator, + o19: AsyncOperator, ): Promise; export function pipe< V, @@ -445,38 +450,38 @@ export function pipe< T20, >( value: V, - o01: Operator, - o02: Operator, - o03: Operator, - o04: Operator, - o05: Operator, - o06: Operator, - o07: Operator, - o08: Operator, - o09: Operator, - o10: Operator, - o11: Operator, - o12: Operator, - o13: Operator, - o14: Operator, - o15: Operator, - o16: Operator, - o17: Operator, - o18: Operator, - o19: Operator, - o20: Operator, + o01: AsyncOperator, + o02: AsyncOperator, + o03: AsyncOperator, + o04: AsyncOperator, + o05: AsyncOperator, + o06: AsyncOperator, + o07: AsyncOperator, + o08: AsyncOperator, + o09: AsyncOperator, + o10: AsyncOperator, + o11: AsyncOperator, + o12: AsyncOperator, + o13: AsyncOperator, + o14: AsyncOperator, + o15: AsyncOperator, + o16: AsyncOperator, + o17: AsyncOperator, + o18: AsyncOperator, + o19: AsyncOperator, + o20: AsyncOperator, ): Promise; // deno-lint-ignore no-explicit-any -export function pipe[]>( +export function pipe[]>( value: V, - ...operators: Operators -): Promise>; + ...operators: AsyncOperators +): Promise>; export async function pipe( value: V, // deno-lint-ignore no-explicit-any - ...operators: Operator[] + ...operators: AsyncOperator[] ) { return await operators.reduce( async (result, next) => next(await result),