fp-pack 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/README.md +1 -1
  2. package/dist/fp-pack.umd.js.map +1 -1
  3. package/dist/implement/async/pipeAsync.d.ts +1 -0
  4. package/dist/implement/async/pipeAsync.d.ts.map +1 -1
  5. package/dist/implement/async/pipeAsync.mjs.map +1 -1
  6. package/dist/implement/async/pipeAsyncSideEffect.d.ts +1 -0
  7. package/dist/implement/async/pipeAsyncSideEffect.d.ts.map +1 -1
  8. package/dist/implement/async/pipeAsyncSideEffect.mjs.map +1 -1
  9. package/dist/implement/async/pipeAsyncSideEffectStrict.d.ts +16 -0
  10. package/dist/implement/async/pipeAsyncSideEffectStrict.d.ts.map +1 -1
  11. package/dist/implement/async/pipeAsyncSideEffectStrict.mjs.map +1 -1
  12. package/dist/implement/composition/pipe.d.ts +2 -0
  13. package/dist/implement/composition/pipe.d.ts.map +1 -1
  14. package/dist/implement/composition/pipe.mjs.map +1 -1
  15. package/dist/implement/composition/pipe.type-test.d.ts +35 -0
  16. package/dist/implement/composition/pipe.type-test.d.ts.map +1 -1
  17. package/dist/implement/composition/pipeSideEffect.d.ts +2 -0
  18. package/dist/implement/composition/pipeSideEffect.d.ts.map +1 -1
  19. package/dist/implement/composition/pipeSideEffect.mjs.map +1 -1
  20. package/dist/implement/composition/pipeSideEffectStrict.d.ts +16 -0
  21. package/dist/implement/composition/pipeSideEffectStrict.d.ts.map +1 -1
  22. package/dist/implement/composition/pipeSideEffectStrict.mjs.map +1 -1
  23. package/dist/skills/fp-pack/SKILL.md +2 -2
  24. package/dist/skills/fp-pack.md +2 -2
  25. package/package.json +1 -1
  26. package/src/implement/async/pipeAsync.ts +8 -0
  27. package/src/implement/async/pipeAsyncSideEffect.ts +8 -0
  28. package/src/implement/async/pipeAsyncSideEffectStrict.ts +30 -0
  29. package/src/implement/composition/pipe.ts +16 -0
  30. package/src/implement/composition/pipe.type-test.ts +93 -0
  31. package/src/implement/composition/pipeSideEffect.ts +16 -0
  32. package/src/implement/composition/pipeSideEffectStrict.ts +30 -0
@@ -32,6 +32,14 @@ function pipeAsync<A, B, C, D, E, R>(
32
32
  de: AsyncOrSync<Awaited<D>, E>,
33
33
  ef: AsyncOrSync<Awaited<E>, R>
34
34
  ): (a: A) => Promise<Awaited<R>>;
35
+ function pipeAsync<A, B, C, D, E, F, R>(
36
+ ab: AsyncOrSync<A, B>,
37
+ bc: AsyncOrSync<Awaited<B>, C>,
38
+ cd: AsyncOrSync<Awaited<C>, D>,
39
+ de: AsyncOrSync<Awaited<D>, E>,
40
+ ef: AsyncOrSync<Awaited<E>, F>,
41
+ fg: AsyncOrSync<Awaited<F>, R>
42
+ ): (a: A) => Promise<Awaited<R>>;
35
43
 
36
44
  function pipeAsync<Fns extends [AsyncOrSync<any, any>, ...AsyncOrSync<any, any>[]]>(...funcs: Fns): PipeAsync<Fns>;
37
45
  function pipeAsync(...funcs: Array<AsyncOrSync<any, any>>): (value: any) => Promise<any>;
@@ -47,6 +47,14 @@ function pipeAsyncSideEffect<A, B, C, D, E, R>(
47
47
  de: AsyncOrSync<Awaited<D>, E>,
48
48
  ef: AsyncOrSync<Awaited<E>, R>
49
49
  ): (a: A | SideEffect<any>) => Promise<MaybeSideEffect<Awaited<R>>>;
50
+ function pipeAsyncSideEffect<A, B, C, D, E, F, R>(
51
+ ab: AsyncOrSync<A, B>,
52
+ bc: AsyncOrSync<Awaited<B>, C>,
53
+ cd: AsyncOrSync<Awaited<C>, D>,
54
+ de: AsyncOrSync<Awaited<D>, E>,
55
+ ef: AsyncOrSync<Awaited<E>, F>,
56
+ fg: AsyncOrSync<Awaited<F>, R>
57
+ ): (a: A | SideEffect<any>) => Promise<MaybeSideEffect<Awaited<R>>>;
50
58
 
51
59
  function pipeAsyncSideEffect<Fns extends [AsyncOrSync<any, any>, ...AsyncOrSync<any, any>[]]>(
52
60
  ...funcs: Fns
@@ -82,6 +82,21 @@ function pipeAsyncSideEffectStrict<B, C, D, E, R>(
82
82
  AsyncOrSync<NonSideEffect<Awaited<D>>, E>,
83
83
  AsyncOrSync<NonSideEffect<Awaited<E>>, R>
84
84
  ]>;
85
+ function pipeAsyncSideEffectStrict<B, C, D, E, F, R>(
86
+ ab: ZeroFn<B>,
87
+ bc: AsyncOrSync<NonSideEffect<Awaited<B>>, C>,
88
+ cd: AsyncOrSync<NonSideEffect<Awaited<C>>, D>,
89
+ de: AsyncOrSync<NonSideEffect<Awaited<D>>, E>,
90
+ ef: AsyncOrSync<NonSideEffect<Awaited<E>>, F>,
91
+ fg: AsyncOrSync<NonSideEffect<Awaited<F>>, R>
92
+ ): PipeAsyncSideEffectStrict<[
93
+ ZeroFn<B>,
94
+ AsyncOrSync<NonSideEffect<Awaited<B>>, C>,
95
+ AsyncOrSync<NonSideEffect<Awaited<C>>, D>,
96
+ AsyncOrSync<NonSideEffect<Awaited<D>>, E>,
97
+ AsyncOrSync<NonSideEffect<Awaited<E>>, F>,
98
+ AsyncOrSync<NonSideEffect<Awaited<F>>, R>
99
+ ]>;
85
100
  function pipeAsyncSideEffectStrict<A, R>(
86
101
  ab: AsyncOrSync<A, R>
87
102
  ): PipeAsyncSideEffectStrict<[AsyncOrSync<A, R>]>;
@@ -122,6 +137,21 @@ function pipeAsyncSideEffectStrict<A, B, C, D, E, R>(
122
137
  AsyncOrSync<NonSideEffect<Awaited<D>>, E>,
123
138
  AsyncOrSync<NonSideEffect<Awaited<E>>, R>
124
139
  ]>;
140
+ function pipeAsyncSideEffectStrict<A, B, C, D, E, F, R>(
141
+ ab: AsyncOrSync<A, B>,
142
+ bc: AsyncOrSync<NonSideEffect<Awaited<B>>, C>,
143
+ cd: AsyncOrSync<NonSideEffect<Awaited<C>>, D>,
144
+ de: AsyncOrSync<NonSideEffect<Awaited<D>>, E>,
145
+ ef: AsyncOrSync<NonSideEffect<Awaited<E>>, F>,
146
+ fg: AsyncOrSync<NonSideEffect<Awaited<F>>, R>
147
+ ): PipeAsyncSideEffectStrict<[
148
+ AsyncOrSync<A, B>,
149
+ AsyncOrSync<NonSideEffect<Awaited<B>>, C>,
150
+ AsyncOrSync<NonSideEffect<Awaited<C>>, D>,
151
+ AsyncOrSync<NonSideEffect<Awaited<D>>, E>,
152
+ AsyncOrSync<NonSideEffect<Awaited<E>>, F>,
153
+ AsyncOrSync<NonSideEffect<Awaited<F>>, R>
154
+ ]>;
125
155
 
126
156
  function pipeAsyncSideEffectStrict<Fns extends [AnyFn, ...AnyFn[]]>(...funcs: Fns): PipeAsyncSideEffectStrict<Fns>;
127
157
  function pipeAsyncSideEffectStrict(...funcs: Array<AsyncOrSync<any, any>>) {
@@ -23,6 +23,14 @@ function pipe<B, C, D, E, R>(
23
23
  de: UnaryFn<D, E>,
24
24
  ef: UnaryFn<E, R>
25
25
  ): () => R;
26
+ function pipe<B, C, D, E, F, R>(
27
+ ab: ZeroFn<B>,
28
+ bc: UnaryFn<B, C>,
29
+ cd: UnaryFn<C, D>,
30
+ de: UnaryFn<D, E>,
31
+ ef: UnaryFn<E, F>,
32
+ fg: UnaryFn<F, R>
33
+ ): () => R;
26
34
  function pipe<A, R>(ab: UnaryFn<A, R>): (a: A) => R;
27
35
  function pipe<A, B, R>(ab: UnaryFn<A, B>, bc: UnaryFn<B, R>): (a: A) => R;
28
36
  function pipe<A, B, C, R>(ab: UnaryFn<A, B>, bc: UnaryFn<B, C>, cd: UnaryFn<C, R>): (a: A) => R;
@@ -39,6 +47,14 @@ function pipe<A, B, C, D, E, R>(
39
47
  de: UnaryFn<D, E>,
40
48
  ef: UnaryFn<E, R>
41
49
  ): (a: A) => R;
50
+ function pipe<A, B, C, D, E, F, R>(
51
+ ab: UnaryFn<A, B>,
52
+ bc: UnaryFn<B, C>,
53
+ cd: UnaryFn<C, D>,
54
+ de: UnaryFn<D, E>,
55
+ ef: UnaryFn<E, F>,
56
+ fg: UnaryFn<F, R>
57
+ ): (a: A) => R;
42
58
 
43
59
  function pipe<Fns extends [UnaryFn<any, any>, ...UnaryFn<any, any>[]]>(...funcs: Fns): Pipe<Fns>;
44
60
  function pipe(...funcs: Array<UnaryFn<any, any>>): (input: any) => any;
@@ -24,6 +24,18 @@ export const purePipe = pipe(
24
24
  type PurePipeExpected = (input: number) => string;
25
25
  export type PipePureIsStrict = Expect<Equal<typeof purePipe, PurePipeExpected>>;
26
26
 
27
+ export const purePipeSix = pipe(
28
+ (value: number) => value + 1,
29
+ (value) => value * 2,
30
+ (value) => `${value}`,
31
+ (value) => value.length,
32
+ (value) => value + 1,
33
+ (value) => `n:${value}`
34
+ );
35
+
36
+ type PurePipeSixExpected = (input: number) => string;
37
+ export type PipePureSixIsStrict = Expect<Equal<typeof purePipeSix, PurePipeSixExpected>>;
38
+
27
39
  export const pipeWithSideEffectInput = pipeSideEffect(
28
40
  (value: number) => value + 1,
29
41
  (value) => value * 2,
@@ -35,6 +47,18 @@ export const pipeWithSideEffectValue = pipeWithSideEffectInput(sideEffectInput);
35
47
  type PipeExpected = (input: number | SideEffect<any>) => string | SideEffect<any>;
36
48
  export type PipeAcceptsSideEffectInput = Expect<Equal<typeof pipeWithSideEffectInput, PipeExpected>>;
37
49
 
50
+ export const pipeSideEffectSix = pipeSideEffect(
51
+ (value: number) => value + 1,
52
+ (value) => value * 2,
53
+ (value) => value + 3,
54
+ (value) => value - 1,
55
+ (value) => value * 2,
56
+ (value) => `n:${value}`
57
+ );
58
+
59
+ type PipeSideEffectSixExpected = (input: number | SideEffect<any>) => string | SideEffect<any>;
60
+ export type PipeSideEffectSixIsStrict = Expect<Equal<typeof pipeSideEffectSix, PipeSideEffectSixExpected>>;
61
+
38
62
  export const purePipeAsync = pipeAsync(
39
63
  (value: number) => value + 1,
40
64
  async (value) => value * 2,
@@ -44,6 +68,18 @@ export const purePipeAsync = pipeAsync(
44
68
  type PurePipeAsyncExpected = (input: number) => Promise<string>;
45
69
  export type PipeAsyncPureIsStrict = Expect<Equal<typeof purePipeAsync, PurePipeAsyncExpected>>;
46
70
 
71
+ export const purePipeAsyncSix = pipeAsync(
72
+ (value: number) => value + 1,
73
+ async (value) => value * 2,
74
+ (value) => `${value}`,
75
+ async (value) => value.length,
76
+ (value) => value + 3,
77
+ async (value) => `n:${value}`
78
+ );
79
+
80
+ type PurePipeAsyncSixExpected = (input: number) => Promise<string>;
81
+ export type PipeAsyncPureSixIsStrict = Expect<Equal<typeof purePipeAsyncSix, PurePipeAsyncSixExpected>>;
82
+
47
83
  export const pipeAsyncWithSideEffectInput = pipeAsyncSideEffect(
48
84
  (value: number) => value + 1,
49
85
  async (value) => value * 2,
@@ -57,6 +93,20 @@ export type PipeAsyncAcceptsSideEffectInput = Expect<
57
93
  Equal<typeof pipeAsyncWithSideEffectInput, PipeAsyncExpected>
58
94
  >;
59
95
 
96
+ export const pipeAsyncSideEffectSix = pipeAsyncSideEffect(
97
+ (value: number) => value + 1,
98
+ async (value) => value * 2,
99
+ (value) => value + 3,
100
+ async (value) => value - 1,
101
+ (value) => value * 2,
102
+ async (value) => `n:${value}`
103
+ );
104
+
105
+ type PipeAsyncSideEffectSixExpected = (input: number | SideEffect<any>) => Promise<string | SideEffect<any>>;
106
+ export type PipeAsyncSideEffectSixIsStrict = Expect<
107
+ Equal<typeof pipeAsyncSideEffectSix, PipeAsyncSideEffectSixExpected>
108
+ >;
109
+
60
110
  export const strictPipeSideEffect = pipeSideEffectStrict(
61
111
  (value: number) => value + 1,
62
112
  (value) => (value > 1 ? value : SideEffect.of(() => 'LOW' as const)),
@@ -81,6 +131,25 @@ export type PipeSideEffectStrictInputEffects = Expect<
81
131
  Equal<StrictSideEffectInputEffects, StrictSideEffectInputEffectsExpected>
82
132
  >;
83
133
 
134
+ export const strictPipeSideEffectSix = pipeSideEffectStrict(
135
+ (value: number) => value + 1,
136
+ (value) => (value > 2 ? value : SideEffect.of(() => 'LOW' as const)),
137
+ (value) => value + 1,
138
+ (value) => (value > 10 ? value : SideEffect.of(() => 'SMALL' as const)),
139
+ (value) => value * 2,
140
+ (value) => (value > 40 ? value : SideEffect.of(() => 0 as const))
141
+ );
142
+
143
+ export const strictPipeSideEffectSixResult = strictPipeSideEffectSix(1);
144
+
145
+ type StrictSixEffects = EffectUnion<typeof strictPipeSideEffectSixResult>;
146
+ type StrictSixEffectsExpected = 'LOW' | 'SMALL' | 0;
147
+ export type PipeSideEffectStrictSixEffects = Expect<Equal<StrictSixEffects, StrictSixEffectsExpected>>;
148
+
149
+ type StrictSixValue = ValueUnion<typeof strictPipeSideEffectSixResult>;
150
+ type StrictSixValueExpected = number;
151
+ export type PipeSideEffectStrictSixValue = Expect<Equal<StrictSixValue, StrictSixValueExpected>>;
152
+
84
153
  export const strictPipeAsyncSideEffect = pipeAsyncSideEffectStrict(
85
154
  (value: number) => value + 1,
86
155
  async (value) => (value > 1 ? value : SideEffect.of(() => 'LOW' as const)),
@@ -101,3 +170,27 @@ type StrictPipeAsyncValueExpected = number;
101
170
  export type PipeAsyncSideEffectStrictValue = Expect<
102
171
  Equal<StrictPipeAsyncValue, StrictPipeAsyncValueExpected>
103
172
  >;
173
+
174
+ export const strictPipeAsyncSideEffectSix = pipeAsyncSideEffectStrict(
175
+ (value: number) => value + 1,
176
+ async (value) => (value > 2 ? value : SideEffect.of(() => 'LOW' as const)),
177
+ (value) => value + 1,
178
+ async (value) => (value > 10 ? value : SideEffect.of(() => 'SMALL' as const)),
179
+ (value) => value * 2,
180
+ async (value) => (value > 40 ? value : SideEffect.of(() => 0 as const))
181
+ );
182
+
183
+ export const strictPipeAsyncSideEffectSixResult = strictPipeAsyncSideEffectSix(1);
184
+
185
+ type StrictAsyncSixResolved = Awaited<typeof strictPipeAsyncSideEffectSixResult>;
186
+ type StrictAsyncSixEffects = EffectUnion<StrictAsyncSixResolved>;
187
+ type StrictAsyncSixEffectsExpected = 'LOW' | 'SMALL' | 0;
188
+ export type PipeAsyncSideEffectStrictSixEffects = Expect<
189
+ Equal<StrictAsyncSixEffects, StrictAsyncSixEffectsExpected>
190
+ >;
191
+
192
+ type StrictAsyncSixValue = ValueUnion<StrictAsyncSixResolved>;
193
+ type StrictAsyncSixValueExpected = number;
194
+ export type PipeAsyncSideEffectStrictSixValue = Expect<
195
+ Equal<StrictAsyncSixValue, StrictAsyncSixValueExpected>
196
+ >;
@@ -35,6 +35,14 @@ function pipeSideEffect<B, C, D, E, R>(
35
35
  de: UnaryFn<D, E>,
36
36
  ef: UnaryFn<E, R>
37
37
  ): () => MaybeSideEffect<R>;
38
+ function pipeSideEffect<B, C, D, E, F, R>(
39
+ ab: ZeroFn<B>,
40
+ bc: UnaryFn<B, C>,
41
+ cd: UnaryFn<C, D>,
42
+ de: UnaryFn<D, E>,
43
+ ef: UnaryFn<E, F>,
44
+ fg: UnaryFn<F, R>
45
+ ): () => MaybeSideEffect<R>;
38
46
  function pipeSideEffect<A, R>(ab: UnaryFn<A, R>): (a: A | SideEffect<any>) => MaybeSideEffect<R>;
39
47
  function pipeSideEffect<A, B, R>(
40
48
  ab: UnaryFn<A, B>,
@@ -58,6 +66,14 @@ function pipeSideEffect<A, B, C, D, E, R>(
58
66
  de: UnaryFn<D, E>,
59
67
  ef: UnaryFn<E, R>
60
68
  ): (a: A | SideEffect<any>) => MaybeSideEffect<R>;
69
+ function pipeSideEffect<A, B, C, D, E, F, R>(
70
+ ab: UnaryFn<A, B>,
71
+ bc: UnaryFn<B, C>,
72
+ cd: UnaryFn<C, D>,
73
+ de: UnaryFn<D, E>,
74
+ ef: UnaryFn<E, F>,
75
+ fg: UnaryFn<F, R>
76
+ ): (a: A | SideEffect<any>) => MaybeSideEffect<R>;
61
77
 
62
78
  function pipeSideEffect<Fns extends [UnaryFn<any, any>, ...UnaryFn<any, any>[]]>(...funcs: Fns): PipeSideEffect<Fns>;
63
79
  function pipeSideEffect(...funcs: Array<UnaryFn<any, any>>): (input: any) => any;
@@ -82,6 +82,21 @@ function pipeSideEffectStrict<B, C, D, E, R>(
82
82
  UnaryFn<NonSideEffect<D>, E>,
83
83
  UnaryFn<NonSideEffect<E>, R>
84
84
  ]>;
85
+ function pipeSideEffectStrict<B, C, D, E, F, R>(
86
+ ab: ZeroFn<B>,
87
+ bc: UnaryFn<NonSideEffect<B>, C>,
88
+ cd: UnaryFn<NonSideEffect<C>, D>,
89
+ de: UnaryFn<NonSideEffect<D>, E>,
90
+ ef: UnaryFn<NonSideEffect<E>, F>,
91
+ fg: UnaryFn<NonSideEffect<F>, R>
92
+ ): PipeSideEffectStrict<[
93
+ ZeroFn<B>,
94
+ UnaryFn<NonSideEffect<B>, C>,
95
+ UnaryFn<NonSideEffect<C>, D>,
96
+ UnaryFn<NonSideEffect<D>, E>,
97
+ UnaryFn<NonSideEffect<E>, F>,
98
+ UnaryFn<NonSideEffect<F>, R>
99
+ ]>;
85
100
  function pipeSideEffectStrict<A, R>(ab: UnaryFn<A, R>): PipeSideEffectStrict<[UnaryFn<A, R>]>;
86
101
  function pipeSideEffectStrict<A, B, R>(
87
102
  ab: UnaryFn<A, B>,
@@ -116,6 +131,21 @@ function pipeSideEffectStrict<A, B, C, D, E, R>(
116
131
  UnaryFn<NonSideEffect<D>, E>,
117
132
  UnaryFn<NonSideEffect<E>, R>
118
133
  ]>;
134
+ function pipeSideEffectStrict<A, B, C, D, E, F, R>(
135
+ ab: UnaryFn<A, B>,
136
+ bc: UnaryFn<NonSideEffect<B>, C>,
137
+ cd: UnaryFn<NonSideEffect<C>, D>,
138
+ de: UnaryFn<NonSideEffect<D>, E>,
139
+ ef: UnaryFn<NonSideEffect<E>, F>,
140
+ fg: UnaryFn<NonSideEffect<F>, R>
141
+ ): PipeSideEffectStrict<[
142
+ UnaryFn<A, B>,
143
+ UnaryFn<NonSideEffect<B>, C>,
144
+ UnaryFn<NonSideEffect<C>, D>,
145
+ UnaryFn<NonSideEffect<D>, E>,
146
+ UnaryFn<NonSideEffect<E>, F>,
147
+ UnaryFn<NonSideEffect<F>, R>
148
+ ]>;
119
149
 
120
150
  function pipeSideEffectStrict<Fns extends [AnyFn, ...AnyFn[]]>(...funcs: Fns): PipeSideEffectStrict<Fns>;
121
151
  function pipeSideEffectStrict(...funcs: Array<(input: any) => any>) {