@railway-ts/pipelines 0.1.30 → 0.2.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.
- package/README.md +4 -4
- package/dist/composition/index.d.mts +367 -0
- package/dist/composition/index.mjs +37 -59
- package/dist/composition/index.mjs.map +1 -1
- package/dist/{result/index.d.cts → index-DDkNG41b.d.mts} +63 -139
- package/dist/option/index.d.mts +7 -0
- package/dist/option/index.mjs +1 -114
- package/dist/option-BQCaaEBP.mjs +909 -0
- package/dist/option-BQCaaEBP.mjs.map +1 -0
- package/dist/result/index.d.mts +7 -0
- package/dist/result/index.mjs +1 -185
- package/dist/schema/{index.d.cts → index.d.mts} +227 -259
- package/dist/schema/index.mjs +1646 -978
- package/dist/schema/index.mjs.map +1 -1
- package/docs/GETTING_STARTED.md +1 -1
- package/docs/RECIPES.md +3 -3
- package/package.json +21 -70
- package/dist/composition/index.cjs +0 -94
- package/dist/composition/index.cjs.map +0 -1
- package/dist/composition/index.d.cts +0 -373
- package/dist/composition/index.d.ts +0 -373
- package/dist/option/index.cjs +0 -137
- package/dist/option/index.cjs.map +0 -1
- package/dist/option/index.d.cts +0 -1
- package/dist/option/index.d.ts +0 -1
- package/dist/option/index.mjs.map +0 -1
- package/dist/result/index.cjs +0 -219
- package/dist/result/index.cjs.map +0 -1
- package/dist/result/index.d.ts +0 -1063
- package/dist/result/index.mjs.map +0 -1
- package/dist/schema/index.cjs +0 -1165
- package/dist/schema/index.cjs.map +0 -1
- package/dist/schema/index.d.ts +0 -1266
package/docs/GETTING_STARTED.md
CHANGED
|
@@ -200,8 +200,8 @@ So far we've been starting pipelines with `ok(10)` -- a known good value. In the
|
|
|
200
200
|
The schema system validates untrusted data and returns a `Result`:
|
|
201
201
|
|
|
202
202
|
```typescript
|
|
203
|
-
import { validate, object, required, chain, string, parseNumber, min } from '@railway-ts/pipelines/schema';
|
|
204
203
|
import { match } from '@railway-ts/pipelines/result';
|
|
204
|
+
import { validate, object, required, chain, string, parseNumber, min } from '@railway-ts/pipelines/schema';
|
|
205
205
|
|
|
206
206
|
const userSchema = object({
|
|
207
207
|
name: required(string()),
|
package/docs/RECIPES.md
CHANGED
|
@@ -67,8 +67,8 @@ const processData = flow(
|
|
|
67
67
|
### Sequential Steps
|
|
68
68
|
|
|
69
69
|
```typescript
|
|
70
|
-
import { flatMapWith } from '@railway-ts/pipelines/result';
|
|
71
70
|
import { pipeAsync } from '@railway-ts/pipelines/composition';
|
|
71
|
+
import { flatMapWith } from '@railway-ts/pipelines/result';
|
|
72
72
|
|
|
73
73
|
const processOrder = async (input: unknown) => {
|
|
74
74
|
const result = await pipeAsync(
|
|
@@ -224,8 +224,8 @@ const result = validate({ password: 'abc', confirmPassword: 'xyz' }, signupSchem
|
|
|
224
224
|
`formatErrors` flattens `ValidationError[]` into `Record<string, string>` keyed by dot-path. `ROOT_ERROR_KEY` (`"_root"`) is used for errors without a field path:
|
|
225
225
|
|
|
226
226
|
```typescript
|
|
227
|
-
import { validate, formatErrors, ROOT_ERROR_KEY } from '@railway-ts/pipelines/schema';
|
|
228
227
|
import { match } from '@railway-ts/pipelines/result';
|
|
228
|
+
import { validate, formatErrors, ROOT_ERROR_KEY } from '@railway-ts/pipelines/schema';
|
|
229
229
|
|
|
230
230
|
const result = validate(input, schema);
|
|
231
231
|
|
|
@@ -793,8 +793,8 @@ Convert between multi-argument and tuple-accepting functions. Pairs naturally wi
|
|
|
793
793
|
|
|
794
794
|
```typescript
|
|
795
795
|
import { tupled, untupled } from '@railway-ts/pipelines/composition';
|
|
796
|
-
import { combine, mapWith, match } from '@railway-ts/pipelines/result';
|
|
797
796
|
import { pipe } from '@railway-ts/pipelines/composition';
|
|
797
|
+
import { combine, mapWith, match } from '@railway-ts/pipelines/result';
|
|
798
798
|
|
|
799
799
|
const createUser = (name: string, age: number) => ({ name, age });
|
|
800
800
|
|
package/package.json
CHANGED
|
@@ -1,28 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@railway-ts/pipelines",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Railway-oriented pipelines for TypeScript: a lightweight fp-style Result/Option and schema layer for handling errors and validating boundaries.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./option": {
|
|
8
|
-
"types": "./dist/option/index.d.
|
|
9
|
-
"
|
|
10
|
-
"require": "./dist/option/index.cjs"
|
|
8
|
+
"types": "./dist/option/index.d.mts",
|
|
9
|
+
"default": "./dist/option/index.mjs"
|
|
11
10
|
},
|
|
12
11
|
"./result": {
|
|
13
|
-
"types": "./dist/result/index.d.
|
|
14
|
-
"
|
|
15
|
-
"require": "./dist/result/index.cjs"
|
|
12
|
+
"types": "./dist/result/index.d.mts",
|
|
13
|
+
"default": "./dist/result/index.mjs"
|
|
16
14
|
},
|
|
17
15
|
"./composition": {
|
|
18
|
-
"types": "./dist/composition/index.d.
|
|
19
|
-
"
|
|
20
|
-
"require": "./dist/composition/index.cjs"
|
|
16
|
+
"types": "./dist/composition/index.d.mts",
|
|
17
|
+
"default": "./dist/composition/index.mjs"
|
|
21
18
|
},
|
|
22
19
|
"./schema": {
|
|
23
|
-
"types": "./dist/schema/index.d.
|
|
24
|
-
"
|
|
25
|
-
"require": "./dist/schema/index.cjs"
|
|
20
|
+
"types": "./dist/schema/index.d.mts",
|
|
21
|
+
"default": "./dist/schema/index.mjs"
|
|
26
22
|
}
|
|
27
23
|
},
|
|
28
24
|
"files": [
|
|
@@ -35,45 +31,13 @@
|
|
|
35
31
|
"node": ">=18"
|
|
36
32
|
},
|
|
37
33
|
"scripts": {
|
|
38
|
-
"build": "
|
|
39
|
-
"
|
|
40
|
-
"
|
|
34
|
+
"build": "tsdown",
|
|
35
|
+
"dev": "tsdown --watch",
|
|
36
|
+
"typecheck": "tsc --noEmit",
|
|
41
37
|
"test": "bun test",
|
|
42
|
-
"test:
|
|
43
|
-
"test:
|
|
44
|
-
"test:coverage:lcov": "mkdir -p coverage && bun test --coverage --coverage-reporter=lcov",
|
|
45
|
-
"test:bail": "bun test --bail",
|
|
46
|
-
"test:fast": "bun test --bail --timeout=1000",
|
|
47
|
-
"test:pattern": "bun test --test-name-pattern",
|
|
48
|
-
"test:only": "bun test --only",
|
|
49
|
-
"test:reporter": "bun test --reporter=junit --reporter-outfile=junit.xml",
|
|
50
|
-
"lint": "bunx eslint .",
|
|
51
|
-
"lint:fix": "bunx eslint . --fix",
|
|
52
|
-
"format": "bunx prettier --write .",
|
|
53
|
-
"format:check": "bunx prettier --check .",
|
|
54
|
-
"typecheck": "bunx tsc --noEmit",
|
|
55
|
-
"size": "bunx size-limit",
|
|
56
|
-
"prepublishOnly": "bun run typecheck && bun run lint && bun run test && bun run build && bun run size",
|
|
57
|
-
"check": "bun run typecheck && bun run lint && bun run test"
|
|
38
|
+
"test:coverage": "mkdir -p coverage && bun test --coverage --coverage-reporter=lcov",
|
|
39
|
+
"test:package": "bun run build && tsc -p tests/package && node tests/package/runtime.mjs"
|
|
58
40
|
},
|
|
59
|
-
"size-limit": [
|
|
60
|
-
{
|
|
61
|
-
"path": "dist/option/index.mjs",
|
|
62
|
-
"limit": "2 kB"
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
"path": "dist/result/index.mjs",
|
|
66
|
-
"limit": "4 kB"
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
"path": "dist/composition/index.mjs",
|
|
70
|
-
"limit": "2 kB"
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
"path": "dist/schema/index.mjs",
|
|
74
|
-
"limit": "10 kB"
|
|
75
|
-
}
|
|
76
|
-
],
|
|
77
41
|
"keywords": [
|
|
78
42
|
"railway",
|
|
79
43
|
"railway-oriented",
|
|
@@ -93,33 +57,20 @@
|
|
|
93
57
|
"validation",
|
|
94
58
|
"runtime-validation"
|
|
95
59
|
],
|
|
96
|
-
"repository":
|
|
97
|
-
|
|
60
|
+
"repository": {
|
|
61
|
+
"type": "git",
|
|
62
|
+
"url": "git+https://github.com/sakobu/railway-ts.git",
|
|
63
|
+
"directory": "packages/pipelines"
|
|
64
|
+
},
|
|
65
|
+
"homepage": "https://github.com/sakobu/railway-ts/tree/main/packages/pipelines#readme",
|
|
98
66
|
"bugs": {
|
|
99
|
-
"url": "https://github.com/sakobu/railway-ts
|
|
67
|
+
"url": "https://github.com/sakobu/railway-ts/issues"
|
|
100
68
|
},
|
|
101
69
|
"author": "Sarkis Melkonian",
|
|
102
70
|
"license": "MIT",
|
|
103
71
|
"publishConfig": {
|
|
104
72
|
"access": "public"
|
|
105
73
|
},
|
|
106
|
-
"devDependencies": {
|
|
107
|
-
"@eslint/js": "^10.0.1",
|
|
108
|
-
"@size-limit/preset-small-lib": "^14.3.0",
|
|
109
|
-
"@types/bun": "1.4.5",
|
|
110
|
-
"eslint": "^10.15.0",
|
|
111
|
-
"eslint-import-resolver-typescript": "^4.4.5",
|
|
112
|
-
"eslint-plugin-import": "^2.32.0",
|
|
113
|
-
"eslint-plugin-prettier": "^5.5.7",
|
|
114
|
-
"eslint-plugin-security": "^4.2.1",
|
|
115
|
-
"eslint-plugin-unicorn": "^80.0.0",
|
|
116
|
-
"globals": "^17.14.0",
|
|
117
|
-
"prettier": "^3.10.1",
|
|
118
|
-
"size-limit": "^14.3.0",
|
|
119
|
-
"tsup": "^9.0.0",
|
|
120
|
-
"typescript": "^6.0.3",
|
|
121
|
-
"typescript-eslint": "^8.73.0"
|
|
122
|
-
},
|
|
123
74
|
"peerDependencies": {
|
|
124
75
|
"typescript": ">=5.0"
|
|
125
76
|
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// src/composition/pipe.ts
|
|
4
|
-
function pipe(value, ...fns) {
|
|
5
|
-
let result = value;
|
|
6
|
-
for (const fn of fns) {
|
|
7
|
-
result = fn(result);
|
|
8
|
-
}
|
|
9
|
-
return result;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// src/composition/flow.ts
|
|
13
|
-
function flow(...fns) {
|
|
14
|
-
if (fns.length === 1) {
|
|
15
|
-
return fns[0];
|
|
16
|
-
}
|
|
17
|
-
const [first, ...rest] = fns;
|
|
18
|
-
return (...args) => {
|
|
19
|
-
let result = first(...args);
|
|
20
|
-
for (const fn of rest) {
|
|
21
|
-
result = fn(result);
|
|
22
|
-
}
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// src/composition/pipe-async.ts
|
|
28
|
-
async function pipeAsync(a, ...fns) {
|
|
29
|
-
let result = await a;
|
|
30
|
-
for (const fn of fns) {
|
|
31
|
-
result = await fn(result);
|
|
32
|
-
}
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// src/composition/flow-async.ts
|
|
37
|
-
function flowAsync(first, ...fns) {
|
|
38
|
-
return async (...args) => {
|
|
39
|
-
let result = await first(...args);
|
|
40
|
-
for (const fn of fns) {
|
|
41
|
-
result = await fn(result);
|
|
42
|
-
}
|
|
43
|
-
return result;
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// src/composition/curry.ts
|
|
48
|
-
function curry(fn) {
|
|
49
|
-
const arity = fn.length;
|
|
50
|
-
return function curried(...args) {
|
|
51
|
-
if (args.length >= arity) {
|
|
52
|
-
return fn(...args);
|
|
53
|
-
}
|
|
54
|
-
return function(...nextArgs) {
|
|
55
|
-
return curried(...args, ...nextArgs);
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// src/composition/uncurry.ts
|
|
61
|
-
function uncurry(fn) {
|
|
62
|
-
return function uncurried(...args) {
|
|
63
|
-
let result = fn;
|
|
64
|
-
for (const arg of args) {
|
|
65
|
-
result = result(arg);
|
|
66
|
-
}
|
|
67
|
-
return result;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// src/composition/tupled.ts
|
|
72
|
-
function tupled(fn) {
|
|
73
|
-
return function tupledFn(args) {
|
|
74
|
-
return fn(...args);
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// src/composition/untupled.ts
|
|
79
|
-
function untupled(fn) {
|
|
80
|
-
return function untupledFn(...args) {
|
|
81
|
-
return fn(args);
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
exports.curry = curry;
|
|
86
|
-
exports.flow = flow;
|
|
87
|
-
exports.flowAsync = flowAsync;
|
|
88
|
-
exports.pipe = pipe;
|
|
89
|
-
exports.pipeAsync = pipeAsync;
|
|
90
|
-
exports.tupled = tupled;
|
|
91
|
-
exports.uncurry = uncurry;
|
|
92
|
-
exports.untupled = untupled;
|
|
93
|
-
//# sourceMappingURL=index.cjs.map
|
|
94
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/composition/pipe.ts","../../src/composition/flow.ts","../../src/composition/pipe-async.ts","../../src/composition/flow-async.ts","../../src/composition/curry.ts","../../src/composition/uncurry.ts","../../src/composition/tupled.ts","../../src/composition/untupled.ts"],"names":[],"mappings":";;;AA8GO,SAAS,IAAA,CAAK,UAAmB,GAAA,EAAiC;AACvE,EAAA,IAAI,MAAA,GAAS,KAAA;AACb,EAAA,KAAA,MAAW,MAAM,GAAA,EAAK;AACpB,IAAA,MAAA,GAAS,GAAG,MAAM,CAAA;AAAA,EACpB;AACA,EAAA,OAAO,MAAA;AACT;;;ACkBO,SAAS,QAAQ,GAAA,EAA+D;AACrF,EAAA,IAAI,GAAA,CAAI,WAAW,CAAA,EAAG;AACpB,IAAA,OAAO,IAAI,CAAC,CAAA;AAAA,EACd;AAEA,EAAA,MAAM,CAAC,KAAA,EAAO,GAAG,IAAI,CAAA,GAAI,GAAA;AACzB,EAAA,OAAO,IAAI,IAAA,KAA6B;AACtC,IAAA,IAAI,MAAA,GAAS,KAAA,CAAM,GAAG,IAAI,CAAA;AAC1B,IAAA,KAAA,MAAW,MAAM,IAAA,EAAM;AACrB,MAAA,MAAA,GAAS,GAAG,MAAM,CAAA;AAAA,IACpB;AACA,IAAA,OAAO,MAAA;AAAA,EACT,CAAA;AACF;;;AC5CA,eAAsB,SAAA,CAAU,MAAe,GAAA,EAA0C;AACvF,EAAA,IAAI,SAAS,MAAM,CAAA;AACnB,EAAA,KAAA,MAAW,MAAM,GAAA,EAAK;AACpB,IAAA,MAAA,GAAS,MAAM,GAAG,MAAM,CAAA;AAAA,EAC1B;AACA,EAAA,OAAO,MAAA;AACT;;;ACHO,SAAS,SAAA,CACd,UACG,GAAA,EACuC;AAC1C,EAAA,OAAO,UAAU,IAAA,KAAoB;AACnC,IAAA,IAAI,MAAA,GAAS,MAAM,KAAA,CAAM,GAAG,IAAI,CAAA;AAChC,IAAA,KAAA,MAAW,MAAM,GAAA,EAAK;AACpB,MAAA,MAAA,GAAS,MAAM,GAAG,MAAM,CAAA;AAAA,IAC1B;AACA,IAAA,OAAO,MAAA;AAAA,EACT,CAAA;AACF;;;AChEO,SAAS,MAAiC,EAAA,EAAwB;AACvE,EAAA,MAAM,QAAQ,EAAA,CAAG,MAAA;AAEjB,EAAA,OAAO,SAAS,WAAW,IAAA,EAA0B;AACnD,IAAA,IAAI,IAAA,CAAK,UAAU,KAAA,EAAO;AACxB,MAAA,OAAQ,EAAA,CAAuB,GAAG,IAAI,CAAA;AAAA,IACxC;AAEA,IAAA,OAAO,YAAa,QAAA,EAA8B;AAChD,MAAA,OAAO,OAAA,CAAQ,GAAG,IAAA,EAAM,GAAG,QAAQ,CAAA;AAAA,IACrC,CAAA;AAAA,EACF,CAAA;AACF;;;ACPO,SAAS,QAAQ,EAAA,EAAsB;AAC5C,EAAA,OAAO,SAAS,aAAa,IAAA,EAA0B;AAErD,IAAA,IAAI,MAAA,GAAS,EAAA;AAEb,IAAA,KAAA,MAAW,OAAO,IAAA,EAAM;AACtB,MAAA,MAAA,GAAU,OAA2B,GAAG,CAAA;AAAA,IAC1C;AAEA,IAAA,OAAO,MAAA;AAAA,EACT,CAAA;AACF;;;ACbO,SAAS,OAAkC,EAAA,EAAqC;AACrF,EAAA,OAAO,SAAS,SAAS,IAAA,EAA0B;AACjD,IAAA,OAAO,EAAA,CAAG,GAAG,IAAI,CAAA;AAAA,EACnB,CAAA;AACF;;;ACPO,SAAS,SAAoC,EAAA,EAAwB;AAC1E,EAAA,OAAO,SAAS,cAAc,IAAA,EAA0B;AACtD,IAAA,OAAO,GAAG,IAAI,CAAA;AAAA,EAChB,CAAA;AACF","file":"index.cjs","sourcesContent":["import type { UnknownFunction } from './types';\n\n/**\n * Pipes a value through a series of functions, from left to right.\n * Each function receives the output of the previous function.\n * Unlike flow, pipe immediately executes the functions with the provided initial value.\n *\n * @example\n * // Basic usage\n * const result = pipe(\n * 5,\n * (n) => n * 2, // 10\n * (n) => n + 1, // 11\n * (n) => n.toString() // \"11\"\n * );\n * // result: \"11\"\n *\n * @example\n * // With Option\n * import { some, mapOption } from \"@railway-ts/pipelines/option\";\n *\n * const optionResult = pipe(\n * some(5),\n * (o) => mapOption(o, (n) => n * 2),\n * (o) => mapOption(o, (n) => n.toString())\n * );\n * // optionResult: Option<string> containing \"10\"\n *\n * @example\n * // With Result\n * import { ok, mapResult } from \"@railway-ts/pipelines/result\";\n *\n * const resultValue = pipe(\n * ok(5),\n * (r) => mapResult(r, (n) => n * 2),\n * (r) => mapResult(r, (n) => n.toString())\n * );\n * // resultValue: Result<string, never> containing \"10\"\n *\n * @param a - The initial value to pipe through the functions\n * @param ab - The first function to apply to the initial value\n * @param functions - Additional functions to apply in sequence\n * @returns The final result after applying all functions\n */\n\nexport function pipe<A, B>(a: A, ab: (this: void, a: A) => B): B;\nexport function pipe<A, B, C>(a: A, ab: (this: void, a: A) => B, bc: (this: void, b: B) => C): C;\nexport function pipe<A, B, C, D>(\n a: A,\n ab: (this: void, a: A) => B,\n bc: (this: void, b: B) => C,\n cd: (this: void, c: C) => D,\n): D;\nexport function pipe<A, B, C, D, E>(\n a: A,\n ab: (this: void, a: A) => B,\n bc: (this: void, b: B) => C,\n cd: (this: void, c: C) => D,\n de: (this: void, d: D) => E,\n): E;\nexport function pipe<A, B, C, D, E, F>(\n a: A,\n ab: (this: void, a: A) => B,\n bc: (this: void, b: B) => C,\n cd: (this: void, c: C) => D,\n de: (this: void, d: D) => E,\n ef: (this: void, e: E) => F,\n): F;\nexport function pipe<A, B, C, D, E, F, G>(\n a: A,\n ab: (this: void, a: A) => B,\n bc: (this: void, b: B) => C,\n cd: (this: void, c: C) => D,\n de: (this: void, d: D) => E,\n ef: (this: void, e: E) => F,\n fg: (this: void, f: F) => G,\n): G;\nexport function pipe<A, B, C, D, E, F, G, H>(\n a: A,\n ab: (this: void, a: A) => B,\n bc: (this: void, b: B) => C,\n cd: (this: void, c: C) => D,\n de: (this: void, d: D) => E,\n ef: (this: void, e: E) => F,\n fg: (this: void, f: F) => G,\n gh: (this: void, g: G) => H,\n): H;\nexport function pipe<A, B, C, D, E, F, G, H, I>(\n a: A,\n ab: (this: void, a: A) => B,\n bc: (this: void, b: B) => C,\n cd: (this: void, c: C) => D,\n de: (this: void, d: D) => E,\n ef: (this: void, e: E) => F,\n fg: (this: void, f: F) => G,\n gh: (this: void, g: G) => H,\n hi: (this: void, h: H) => I,\n): I;\nexport function pipe<A, B, C, D, E, F, G, H, I, J>(\n a: A,\n ab: (this: void, a: A) => B,\n bc: (this: void, b: B) => C,\n cd: (this: void, c: C) => D,\n de: (this: void, d: D) => E,\n ef: (this: void, e: E) => F,\n fg: (this: void, f: F) => G,\n gh: (this: void, g: G) => H,\n hi: (this: void, h: H) => I,\n ij: (this: void, i: I) => J,\n): J;\nexport function pipe(value: unknown, ...fns: UnknownFunction[]): unknown {\n let result = value;\n for (const fn of fns) {\n result = fn(result);\n }\n return result;\n}\n","import type { UnknownFunction } from './types';\n\n/**\n * Creates a new function that is the composition of the provided functions, applied from left to right.\n * Unlike pipe, flow doesn't immediately execute the functions but returns a new function that,\n * when called, will run the composed functions in sequence.\n *\n * @example\n * // Basic usage\n * const processNumber = flow(\n * (n: number) => n * 2,\n * (n) => n + 1,\n * (n) => n.toString()\n * );\n *\n * const result = processNumber(5); // \"11\"\n *\n * @example\n * // With multiple arguments\n * const formatName = flow(\n * (first: string, last: string) => `${first} ${last}`,\n * (name) => name.toUpperCase()\n * );\n *\n * const name = formatName(\"John\", \"Doe\"); // \"JOHN DOE\"\n *\n * @example\n * // With Option type\n * import { some, none, mapOption, flatMapOption, type Option } from \"@railway-ts/pipelines/option\";\n *\n * const safeParseInt = (radix: number) => (str: string): Option<number> => {\n * const n = Number.parseInt(str, radix);\n * return Number.isNaN(n) ? none() : some(n);\n * };\n *\n * const processString = flow(\n * (s: string) => some(s),\n * (o) => mapOption(o, (s) => s + \"0\"),\n * (o) => flatMapOption(o, safeParseInt(10))\n * );\n *\n * const option = processString(\"42\"); // Option<number> containing 420\n *\n * @example\n * // With Result type\n * import { ok, err, flatMapResult } from \"@railway-ts/pipelines/result\";\n *\n * const validatePositive = (n: number) => (n > 0 ? ok(n) : err(\"Not positive\"));\n *\n * const validateNumber = flow(\n * (n: number) => ok(n),\n * (r) => flatMapResult(r, validatePositive),\n * (r) => flatMapResult(r, (n) => ok(n * 2))\n * );\n *\n * const result = validateNumber(5); // Result<number, string> containing 10\n *\n * @param ab - The first function in the composition\n * @param functions - Additional functions to compose in sequence\n * @returns A new function that applies all the composed functions in sequence\n */\nexport function flow<A extends unknown[], B>(ab: (this: void, ...a: A) => B): (...a: A) => B;\nexport function flow<A extends unknown[], B, C>(\n ab: (this: void, ...a: A) => B,\n bc: (this: void, b: B) => C,\n): (...a: A) => C;\nexport function flow<A extends unknown[], B, C, D>(\n ab: (this: void, ...a: A) => B,\n bc: (this: void, b: B) => C,\n cd: (this: void, c: C) => D,\n): (...a: A) => D;\nexport function flow<A extends unknown[], B, C, D, E>(\n ab: (this: void, ...a: A) => B,\n bc: (this: void, b: B) => C,\n cd: (this: void, c: C) => D,\n de: (this: void, d: D) => E,\n): (...a: A) => E;\nexport function flow<A extends unknown[], B, C, D, E, F>(\n ab: (this: void, ...a: A) => B,\n bc: (this: void, b: B) => C,\n cd: (this: void, c: C) => D,\n de: (this: void, d: D) => E,\n ef: (this: void, e: E) => F,\n): (...a: A) => F;\nexport function flow<A extends unknown[], B, C, D, E, F, G>(\n ab: (this: void, ...a: A) => B,\n bc: (this: void, b: B) => C,\n cd: (this: void, c: C) => D,\n de: (this: void, d: D) => E,\n ef: (this: void, e: E) => F,\n fg: (this: void, f: F) => G,\n): (...a: A) => G;\nexport function flow<A extends unknown[], B, C, D, E, F, G, H>(\n ab: (this: void, ...a: A) => B,\n bc: (this: void, b: B) => C,\n cd: (this: void, c: C) => D,\n de: (this: void, d: D) => E,\n ef: (this: void, e: E) => F,\n fg: (this: void, f: F) => G,\n gh: (this: void, g: G) => H,\n): (...a: A) => H;\nexport function flow<A extends unknown[], B, C, D, E, F, G, H, I>(\n ab: (this: void, ...a: A) => B,\n bc: (this: void, b: B) => C,\n cd: (this: void, c: C) => D,\n de: (this: void, d: D) => E,\n ef: (this: void, e: E) => F,\n fg: (this: void, f: F) => G,\n gh: (this: void, g: G) => H,\n hi: (this: void, h: H) => I,\n): (...a: A) => I;\nexport function flow<A extends unknown[], B, C, D, E, F, G, H, I, J>(\n ab: (this: void, ...a: A) => B,\n bc: (this: void, b: B) => C,\n cd: (this: void, c: C) => D,\n de: (this: void, d: D) => E,\n ef: (this: void, e: E) => F,\n fg: (this: void, f: F) => G,\n gh: (this: void, g: G) => H,\n hi: (this: void, h: H) => I,\n ij: (this: void, i: I) => J,\n): (...a: A) => J;\nexport function flow<A extends unknown[], B, C, D, E, F, G, H, I, J, K>(\n ab: (this: void, ...a: A) => B,\n bc: (this: void, b: B) => C,\n cd: (this: void, c: C) => D,\n de: (this: void, d: D) => E,\n ef: (this: void, e: E) => F,\n fg: (this: void, f: F) => G,\n gh: (this: void, g: G) => H,\n hi: (this: void, h: H) => I,\n ij: (this: void, i: I) => J,\n jk: (this: void, j: J) => K,\n): (...a: A) => K;\nexport function flow(...fns: [UnknownFunction, ...UnknownFunction[]]): UnknownFunction {\n if (fns.length === 1) {\n return fns[0];\n }\n\n const [first, ...rest] = fns;\n return (...args: unknown[]): unknown => {\n let result = first(...args);\n for (const fn of rest) {\n result = fn(result);\n }\n return result;\n };\n}\n","import type { MaybeAsync, UnknownFunction } from './types';\n\n/**\n * Pipes a value through a series of potentially async functions, from left to right.\n * Each function receives the awaited output of the previous function.\n * Unlike pipe, pipeAsync awaits between each step, enabling async composition.\n *\n * @example\n * // Basic async usage\n * const result = await pipeAsync(\n * 5,\n * async (n) => n * 2, // 10\n * (n) => n + 1, // 11\n * async (n) => n.toString() // \"11\"\n * );\n * // result: \"11\"\n *\n * @example\n * // With Result and curried helpers\n * import { ok, flatMapWith, mapWith } from \"@railway-ts/pipelines/result\";\n *\n * const result = await pipeAsync(\n * ok(5),\n * flatMapWith(async (n) => ok(n * 2)),\n * mapWith((n) => n.toString())\n * );\n * // result: Result<string, never> containing \"10\"\n *\n * @param a - The initial value (or Promise) to pipe through the functions\n * @param ab - The first function to apply to the initial value\n * @param functions - Additional functions to apply in sequence\n * @returns A Promise of the final result after applying all functions\n */\n\nexport function pipeAsync<A, B>(a: MaybeAsync<A>, ab: (this: void, a: A) => MaybeAsync<B>): Promise<B>;\nexport function pipeAsync<A, B, C>(\n a: MaybeAsync<A>,\n ab: (this: void, a: A) => MaybeAsync<B>,\n bc: (this: void, b: B) => MaybeAsync<C>,\n): Promise<C>;\nexport function pipeAsync<A, B, C, D>(\n a: MaybeAsync<A>,\n ab: (this: void, a: A) => MaybeAsync<B>,\n bc: (this: void, b: B) => MaybeAsync<C>,\n cd: (this: void, c: C) => MaybeAsync<D>,\n): Promise<D>;\nexport function pipeAsync<A, B, C, D, E>(\n a: MaybeAsync<A>,\n ab: (this: void, a: A) => MaybeAsync<B>,\n bc: (this: void, b: B) => MaybeAsync<C>,\n cd: (this: void, c: C) => MaybeAsync<D>,\n de: (this: void, d: D) => MaybeAsync<E>,\n): Promise<E>;\nexport function pipeAsync<A, B, C, D, E, F>(\n a: MaybeAsync<A>,\n ab: (this: void, a: A) => MaybeAsync<B>,\n bc: (this: void, b: B) => MaybeAsync<C>,\n cd: (this: void, c: C) => MaybeAsync<D>,\n de: (this: void, d: D) => MaybeAsync<E>,\n ef: (this: void, e: E) => MaybeAsync<F>,\n): Promise<F>;\nexport function pipeAsync<A, B, C, D, E, F, G>(\n a: MaybeAsync<A>,\n ab: (this: void, a: A) => MaybeAsync<B>,\n bc: (this: void, b: B) => MaybeAsync<C>,\n cd: (this: void, c: C) => MaybeAsync<D>,\n de: (this: void, d: D) => MaybeAsync<E>,\n ef: (this: void, e: E) => MaybeAsync<F>,\n fg: (this: void, f: F) => MaybeAsync<G>,\n): Promise<G>;\nexport function pipeAsync<A, B, C, D, E, F, G, H>(\n a: MaybeAsync<A>,\n ab: (this: void, a: A) => MaybeAsync<B>,\n bc: (this: void, b: B) => MaybeAsync<C>,\n cd: (this: void, c: C) => MaybeAsync<D>,\n de: (this: void, d: D) => MaybeAsync<E>,\n ef: (this: void, e: E) => MaybeAsync<F>,\n fg: (this: void, f: F) => MaybeAsync<G>,\n gh: (this: void, g: G) => MaybeAsync<H>,\n): Promise<H>;\nexport function pipeAsync<A, B, C, D, E, F, G, H, I>(\n a: MaybeAsync<A>,\n ab: (this: void, a: A) => MaybeAsync<B>,\n bc: (this: void, b: B) => MaybeAsync<C>,\n cd: (this: void, c: C) => MaybeAsync<D>,\n de: (this: void, d: D) => MaybeAsync<E>,\n ef: (this: void, e: E) => MaybeAsync<F>,\n fg: (this: void, f: F) => MaybeAsync<G>,\n gh: (this: void, g: G) => MaybeAsync<H>,\n hi: (this: void, h: H) => MaybeAsync<I>,\n): Promise<I>;\nexport function pipeAsync<A, B, C, D, E, F, G, H, I, J>(\n a: MaybeAsync<A>,\n ab: (this: void, a: A) => MaybeAsync<B>,\n bc: (this: void, b: B) => MaybeAsync<C>,\n cd: (this: void, c: C) => MaybeAsync<D>,\n de: (this: void, d: D) => MaybeAsync<E>,\n ef: (this: void, e: E) => MaybeAsync<F>,\n fg: (this: void, f: F) => MaybeAsync<G>,\n gh: (this: void, g: G) => MaybeAsync<H>,\n hi: (this: void, h: H) => MaybeAsync<I>,\n ij: (this: void, i: I) => MaybeAsync<J>,\n): Promise<J>;\nexport async function pipeAsync(a: unknown, ...fns: UnknownFunction[]): Promise<unknown> {\n let result = await a;\n for (const fn of fns) {\n result = await fn(result);\n }\n return result;\n}\n","import type { MaybeAsync, UnknownFunction } from './types';\n\n/**\n * Creates a new function that is the async composition of the provided functions, applied from left to right.\n * Unlike flow, flowAsync awaits between each step, enabling async composition.\n * The returned function always returns a Promise.\n *\n * @example\n * // Basic async usage\n * const processNumber = flowAsync(\n * async (n: number) => n * 2,\n * (n) => n + 1,\n * async (n) => n.toString()\n * );\n *\n * const result = await processNumber(5); // \"11\"\n *\n * @example\n * // With Result and curried helpers\n * import { ok, flatMapWith, mapWith } from \"@railway-ts/pipelines/result\";\n *\n * const process = flowAsync(\n * (n: number) => ok(n),\n * flatMapWith(async (n) => ok(n * 2)),\n * mapWith((n) => n.toString())\n * );\n *\n * const result = await process(5); // Result<string, never> containing \"10\"\n *\n * @param ab - The first function in the composition\n * @param functions - Additional functions to compose in sequence\n * @returns A new function that applies all the composed functions in sequence, returning a Promise\n */\nexport function flowAsync<A extends unknown[], B>(ab: (this: void, ...a: A) => MaybeAsync<B>): (...a: A) => Promise<B>;\nexport function flowAsync<A extends unknown[], B, C>(\n ab: (this: void, ...a: A) => MaybeAsync<B>,\n bc: (this: void, b: B) => MaybeAsync<C>,\n): (...a: A) => Promise<C>;\nexport function flowAsync<A extends unknown[], B, C, D>(\n ab: (this: void, ...a: A) => MaybeAsync<B>,\n bc: (this: void, b: B) => MaybeAsync<C>,\n cd: (this: void, c: C) => MaybeAsync<D>,\n): (...a: A) => Promise<D>;\nexport function flowAsync<A extends unknown[], B, C, D, E>(\n ab: (this: void, ...a: A) => MaybeAsync<B>,\n bc: (this: void, b: B) => MaybeAsync<C>,\n cd: (this: void, c: C) => MaybeAsync<D>,\n de: (this: void, d: D) => MaybeAsync<E>,\n): (...a: A) => Promise<E>;\nexport function flowAsync<A extends unknown[], B, C, D, E, F>(\n ab: (this: void, ...a: A) => MaybeAsync<B>,\n bc: (this: void, b: B) => MaybeAsync<C>,\n cd: (this: void, c: C) => MaybeAsync<D>,\n de: (this: void, d: D) => MaybeAsync<E>,\n ef: (this: void, e: E) => MaybeAsync<F>,\n): (...a: A) => Promise<F>;\nexport function flowAsync<A extends unknown[], B, C, D, E, F, G>(\n ab: (this: void, ...a: A) => MaybeAsync<B>,\n bc: (this: void, b: B) => MaybeAsync<C>,\n cd: (this: void, c: C) => MaybeAsync<D>,\n de: (this: void, d: D) => MaybeAsync<E>,\n ef: (this: void, e: E) => MaybeAsync<F>,\n fg: (this: void, f: F) => MaybeAsync<G>,\n): (...a: A) => Promise<G>;\nexport function flowAsync<A extends unknown[], B, C, D, E, F, G, H>(\n ab: (this: void, ...a: A) => MaybeAsync<B>,\n bc: (this: void, b: B) => MaybeAsync<C>,\n cd: (this: void, c: C) => MaybeAsync<D>,\n de: (this: void, d: D) => MaybeAsync<E>,\n ef: (this: void, e: E) => MaybeAsync<F>,\n fg: (this: void, f: F) => MaybeAsync<G>,\n gh: (this: void, g: G) => MaybeAsync<H>,\n): (...a: A) => Promise<H>;\nexport function flowAsync<A extends unknown[], B, C, D, E, F, G, H, I>(\n ab: (this: void, ...a: A) => MaybeAsync<B>,\n bc: (this: void, b: B) => MaybeAsync<C>,\n cd: (this: void, c: C) => MaybeAsync<D>,\n de: (this: void, d: D) => MaybeAsync<E>,\n ef: (this: void, e: E) => MaybeAsync<F>,\n fg: (this: void, f: F) => MaybeAsync<G>,\n gh: (this: void, g: G) => MaybeAsync<H>,\n hi: (this: void, h: H) => MaybeAsync<I>,\n): (...a: A) => Promise<I>;\nexport function flowAsync<A extends unknown[], B, C, D, E, F, G, H, I, J>(\n ab: (this: void, ...a: A) => MaybeAsync<B>,\n bc: (this: void, b: B) => MaybeAsync<C>,\n cd: (this: void, c: C) => MaybeAsync<D>,\n de: (this: void, d: D) => MaybeAsync<E>,\n ef: (this: void, e: E) => MaybeAsync<F>,\n fg: (this: void, f: F) => MaybeAsync<G>,\n gh: (this: void, g: G) => MaybeAsync<H>,\n hi: (this: void, h: H) => MaybeAsync<I>,\n ij: (this: void, i: I) => MaybeAsync<J>,\n): (...a: A) => Promise<J>;\nexport function flowAsync<A extends unknown[], B, C, D, E, F, G, H, I, J, K>(\n ab: (this: void, ...a: A) => MaybeAsync<B>,\n bc: (this: void, b: B) => MaybeAsync<C>,\n cd: (this: void, c: C) => MaybeAsync<D>,\n de: (this: void, d: D) => MaybeAsync<E>,\n ef: (this: void, e: E) => MaybeAsync<F>,\n fg: (this: void, f: F) => MaybeAsync<G>,\n gh: (this: void, g: G) => MaybeAsync<H>,\n hi: (this: void, h: H) => MaybeAsync<I>,\n ij: (this: void, i: I) => MaybeAsync<J>,\n jk: (this: void, j: J) => MaybeAsync<K>,\n): (...a: A) => Promise<K>;\nexport function flowAsync(\n first: (...args: unknown[]) => unknown,\n ...fns: UnknownFunction[]\n): (...args: unknown[]) => Promise<unknown> {\n return async (...args: unknown[]) => {\n let result = await first(...args);\n for (const fn of fns) {\n result = await fn(result);\n }\n return result;\n };\n}\n","import type { UnknownFunction } from './types';\n\n/**\n * Curries a multi-parameter function into a sequence of unary functions.\n * Enables partial application at any depth and composes cleanly with `pipe`.\n *\n * Note: This curry is unary-only at each step to ensure compatibility with `pipe` and `flow`.\n *\n * @example\n * // Basic (2-arity)\n * const add = (a: number, b: number) => a + b;\n * const add5 = curry(add)(5);\n * add5(3); // 8\n *\n * @example\n * // 3-arity and partial application\n * const multiply = (a: number, b: number, c: number) => a * b * c;\n * const curriedMultiply = curry(multiply);\n * curriedMultiply(2)(3)(4); // 24\n *\n * @example\n * // With pipe\n * import { pipe } from \"@/utils\";\n * const divide = (divisor: number, dividend: number) => dividend / divisor;\n * const result = pipe(100, curry(divide)(2), (n) => n + 1); // 51\n *\n * @example\n * // With Result validators\n * import { ok, err, flatMap, type Result } from \"@/result\";\n * const between = (min: number, max: number, n: number): Result<number, string> =>\n * n >= min && n <= max ? ok(n) : err(`Value must be between ${min} and ${max}`);\n * const validateAge = curry(between)(0)(120);\n * pipe(ok(25), (r) => flatMap(r, validateAge)); // ok(25)\n *\n * @param fn - The multi-argument function to transform into a unary curried chain\n * @returns A curried function that takes one argument at each application step\n */\n\n// 2-arity\nexport function curry<A, B, R>(fn: (a: A, b: B) => R): (a: A) => (b: B) => R;\n\n// 3-arity\nexport function curry<A, B, C, R>(fn: (a: A, b: B, c: C) => R): (a: A) => (b: B) => (c: C) => R;\n\n// 4-arity\nexport function curry<A, B, C, D, R>(fn: (a: A, b: B, c: C, d: D) => R): (a: A) => (b: B) => (c: C) => (d: D) => R;\n\n// 5-arity\nexport function curry<A, B, C, D, E, R>(\n fn: (a: A, b: B, c: C, d: D, e: E) => R,\n): (a: A) => (b: B) => (c: C) => (d: D) => (e: E) => R;\n\n// Implementation\nexport function curry<T extends UnknownFunction>(fn: T): UnknownFunction {\n const arity = fn.length;\n\n return function curried(...args: unknown[]): unknown {\n if (args.length >= arity) {\n return (fn as UnknownFunction)(...args);\n }\n\n return function (...nextArgs: unknown[]): unknown {\n return curried(...args, ...nextArgs);\n };\n };\n}\n","import type { UnknownFunction } from './types';\n\n/**\n * Uncurries a curried unary function chain back into a multi-argument function.\n * Inverse of `curry`. Useful when calling curried APIs with positional arguments.\n *\n * Note: Expects strictly unary nesting (the shape produced by `curry`).\n *\n * @example\n * // 2-arity\n * const addCurried = (a: number) => (b: number) => a + b;\n * const add = uncurry(addCurried);\n * add(5, 3); // 8\n *\n * @example\n * // 3-arity\n * const multiplyCurried = (a: number) => (b: number) => (c: number) => a * b * c;\n * const multiply = uncurry(multiplyCurried);\n * multiply(2, 3, 4); // 24\n *\n * @example\n * // Round-trip with curry\n * import { curry } from \"@railway-ts/pipelines\";\n * const divide = (divisor: number, dividend: number) => dividend / divisor;\n * const divideCurried = curry(divide);\n * const divideUncurried = uncurry(divideCurried);\n * divideUncurried(2, 100); // 50\n *\n * @param fn - A curried unary function chain (e.g., a => b => c => r)\n * @returns A multi-argument function equivalent to applying the curried chain in sequence\n */\n\n// Overloads ordered from most specific (5-arity) to least specific (2-arity)\n// This ensures TypeScript matches the correct overload\n\n// 5-arity\nexport function uncurry<A, B, C, D, E, R>(\n fn: (a: A) => (b: B) => (c: C) => (d: D) => (e: E) => R,\n): (a: A, b: B, c: C, d: D, e: E) => R;\n\n// 5-arity\nexport function uncurry<A, B, C, D, E, R>(\n fn: (a: A) => (b: B) => (c: C) => (d: D) => (e: E) => R,\n): (a: A, b: B, c: C, d: D, e: E) => R;\n\n// 4-arity\nexport function uncurry<A, B, C, D, R>(fn: (a: A) => (b: B) => (c: C) => (d: D) => R): (a: A, b: B, c: C, d: D) => R;\n\n// 3-arity\nexport function uncurry<A, B, C, R>(fn: (a: A) => (b: B) => (c: C) => R): (a: A, b: B, c: C) => R;\n\n// 2-arity\nexport function uncurry<A, B, R>(fn: (a: A) => (b: B) => R): (a: A, b: B) => R;\n\n// 1-arity (identity - technically not curried, but allows for consistent API)\nexport function uncurry<A, R>(fn: (a: A) => R): (a: A) => R;\n\n// Implementation - looser types allow overloads to work correctly\nexport function uncurry(fn: unknown): unknown {\n return function uncurried(...args: unknown[]): unknown {\n // Apply arguments sequentially to the curried function chain\n let result = fn;\n\n for (const arg of args) {\n result = (result as UnknownFunction)(arg);\n }\n\n return result;\n };\n}\n","import type { UnknownFunction } from './types';\n\n/**\n * Transforms a multi-argument function into one that accepts a single tuple argument.\n * This makes multi-arg functions composable in `pipe`/`flow` when your data is a tuple.\n *\n * @example\n * // Basic\n * const add = (a: number, b: number) => a + b;\n * const tupledAdd = tupled(add);\n * tupledAdd([5, 3]); // 8\n *\n * @example\n * // With pipe (tuple input)\n * import { pipe } from \"@/utils\";\n * const distance = (x: number, y: number) => Math.hypot(x, y);\n * pipe([3, 4] as [number, number], tupled(distance)); // 5\n *\n * @example\n * // With Result\n * import { ok, err, flatMapResult, mapResult, type Result } from \"@railway-ts/pipelines/result\";\n * const divide = (dividend: number, divisor: number): Result<number, string> =>\n * divisor === 0 ? err(\"Division by zero\") : ok(dividend / divisor);\n * const tupledDivide = tupled(divide);\n * pipe(ok<[number, number], string>([10, 2]),\n * (r) => flatMapResult(r, tupledDivide),\n * (r) => mapResult(r, (n) => n * 2)\n * ); // ok(10)\n *\n * @example\n * // With Option\n * import { some, none, flatMapOption, type Option } from \"@railway-ts/pipelines/option\";\n * const safeParse = (str: string, radix: number): Option<number> => {\n * const n = Number.parseInt(str, radix);\n * return Number.isNaN(n) ? none() : some(n);\n * };\n * const tupledParse = tupled(safeParse);\n * flatMapOption(some([\"FF\", 16] as [string, number]), tupledParse); // some(255)\n *\n * @param fn - A function taking positional arguments to be adapted to a single tuple argument\n * @returns A function that takes a tuple and applies it to `fn` as positional args\n */\n\n// 2-arity\nexport function tupled<A, B, R>(fn: (a: A, b: B) => R): (args: [A, B]) => R;\n\n// 3-arity\nexport function tupled<A, B, C, R>(fn: (a: A, b: B, c: C) => R): (args: [A, B, C]) => R;\n\n// 4-arity\nexport function tupled<A, B, C, D, R>(fn: (a: A, b: B, c: C, d: D) => R): (args: [A, B, C, D]) => R;\n\n// 5-arity\nexport function tupled<A, B, C, D, E, R>(fn: (a: A, b: B, c: C, d: D, e: E) => R): (args: [A, B, C, D, E]) => R;\n\n// Implementation\nexport function tupled<T extends UnknownFunction>(fn: T): (args: unknown[]) => unknown {\n return function tupledFn(args: unknown[]): unknown {\n return fn(...args);\n };\n}\n","import type { UnknownFunction } from './types';\n\n/**\n * Transforms a function that accepts a tuple into a multi-argument function.\n * Inverse of `tupled`. Useful when callers have positional arguments but your core API uses tuples.\n *\n * @example\n * // Basic\n * const tupledAdd = ([a, b]: [number, number]) => a + b;\n * const add = untupled(tupledAdd);\n * add(5, 3); // 8\n *\n * @example\n * // 3-arity\n * const sum3Tupled = ([a, b, c]: [number, number, number]) => a + b + c;\n * const sum3 = untupled(sum3Tupled);\n * sum3(1, 2, 3); // 6\n *\n * @example\n * // With Result\n * import { ok, err, flatMapResult, type Result } from \"@railway-ts/pipelines/result\";\n * const validateRange = ([min, max, value]: [number, number, number]): Result<number, string> =>\n * value >= min && value <= max ? ok(value) : err(`Value ${value} not between ${min} and ${max}`);\n * const validate = untupled(validateRange);\n * flatMapResult(ok(50), (n) => validate(0, 100, n)); // ok(50)\n *\n * @example\n * // With Option\n * import { some, none, type Option } from \"@railway-ts/pipelines/option\";\n * const parsePair = ([x, y]: [string, string]): Option<number> => {\n * const a = Number(x), b = Number(y);\n * return Number.isNaN(a) || Number.isNaN(b) ? none() : some(a + b);\n * };\n * const parse = untupled(parsePair);\n * parse(\"2\", \"3\"); // some(5)\n *\n * @param fn - A function that accepts a tuple of arguments\n * @returns A function that accepts the same arguments positionally\n */\n\n// 2-arity\nexport function untupled<A, B, R>(fn: (args: [A, B]) => R): (a: A, b: B) => R;\n\n// 3-arity\nexport function untupled<A, B, C, R>(fn: (args: [A, B, C]) => R): (a: A, b: B, c: C) => R;\n\n// 4-arity\nexport function untupled<A, B, C, D, R>(fn: (args: [A, B, C, D]) => R): (a: A, b: B, c: C, d: D) => R;\n\n// 5-arity\nexport function untupled<A, B, C, D, E, R>(fn: (args: [A, B, C, D, E]) => R): (a: A, b: B, c: C, d: D, e: E) => R;\n\n// Implementation\nexport function untupled<T extends UnknownFunction>(fn: T): UnknownFunction {\n return function untupledFn(...args: unknown[]): unknown {\n return fn(args);\n };\n}\n"]}
|