@carbonteq/fp 0.8.1 → 0.9.1
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 +460 -51
- package/dist/errors.cjs +19 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +10 -0
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.mts +10 -0
- package/dist/errors.d.mts.map +1 -0
- package/dist/errors.mjs +17 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/index.cjs +13 -7
- package/dist/index.d.cts +6 -5
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +7 -0
- package/dist/match.cjs +12 -3
- package/dist/match.cjs.map +1 -0
- package/dist/match.d.cts +15 -5
- package/dist/match.d.cts.map +1 -0
- package/dist/{match-COIWq-e8.d.cts → match.d.mts} +3 -6
- package/dist/match.d.mts.map +1 -0
- package/dist/match.mjs +11 -0
- package/dist/match.mjs.map +1 -0
- package/dist/option.cjs +279 -4
- package/dist/option.cjs.map +1 -0
- package/dist/option.d.cts +99 -3
- package/dist/option.d.cts.map +1 -0
- package/dist/option.d.mts +99 -0
- package/dist/option.d.mts.map +1 -0
- package/dist/option.mjs +279 -0
- package/dist/option.mjs.map +1 -0
- package/dist/result.cjs +484 -5
- package/dist/result.cjs.map +1 -0
- package/dist/result.d.cts +142 -3
- package/dist/result.d.cts.map +1 -0
- package/dist/result.d.mts +142 -0
- package/dist/result.d.mts.map +1 -0
- package/dist/result.mjs +480 -0
- package/dist/result.mjs.map +1 -0
- package/dist/tuple.cjs.map +1 -1
- package/dist/tuple.d.cts +0 -1
- package/dist/tuple.d.cts.map +1 -1
- package/dist/{tuple.d.ts → tuple.d.mts} +1 -2
- package/dist/tuple.d.mts.map +1 -0
- package/dist/{tuple.js → tuple.mjs} +1 -1
- package/dist/tuple.mjs.map +1 -0
- package/dist/unit.cjs +6 -2
- package/dist/unit.cjs.map +1 -0
- package/dist/unit.d.cts +6 -2
- package/dist/unit.d.cts.map +1 -0
- package/dist/{unit-D0y_qAUW.d.cts → unit.d.mts} +1 -4
- package/dist/unit.d.mts.map +1 -0
- package/dist/{unit-udy5j53P.js → unit.mjs} +1 -1
- package/dist/unit.mjs.map +1 -0
- package/dist/utils.cjs +9 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +5 -0
- package/dist/utils.d.cts.map +1 -0
- package/dist/utils.d.mts +5 -0
- package/dist/utils.d.mts.map +1 -0
- package/dist/utils.mjs +8 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +86 -51
- package/dist/chunk-CUT6urMc.cjs +0 -30
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -6
- package/dist/match-BQP0RNSk.js +0 -13
- package/dist/match-BQP0RNSk.js.map +0 -1
- package/dist/match-COIWq-e8.d.cts.map +0 -1
- package/dist/match-DXKW7ym5.d.ts +0 -18
- package/dist/match-DXKW7ym5.d.ts.map +0 -1
- package/dist/match-DyAuOeqx.cjs +0 -25
- package/dist/match-DyAuOeqx.cjs.map +0 -1
- package/dist/match.d.ts +0 -5
- package/dist/match.js +0 -3
- package/dist/option-8_eiz02z.d.cts +0 -45
- package/dist/option-8_eiz02z.d.cts.map +0 -1
- package/dist/option-Be_DXVE6.js +0 -181
- package/dist/option-Be_DXVE6.js.map +0 -1
- package/dist/option-CoelyMEg.d.ts +0 -45
- package/dist/option-CoelyMEg.d.ts.map +0 -1
- package/dist/option-DHCdfOco.cjs +0 -193
- package/dist/option-DHCdfOco.cjs.map +0 -1
- package/dist/option.d.ts +0 -3
- package/dist/option.js +0 -4
- package/dist/result-CdGWA5IL.js +0 -318
- package/dist/result-CdGWA5IL.js.map +0 -1
- package/dist/result-DsVjSFnO.d.ts +0 -132
- package/dist/result-DsVjSFnO.d.ts.map +0 -1
- package/dist/result-Dy_C5dC6.d.cts +0 -132
- package/dist/result-Dy_C5dC6.d.cts.map +0 -1
- package/dist/result-nuhyCRyu.cjs +0 -336
- package/dist/result-nuhyCRyu.cjs.map +0 -1
- package/dist/result.d.ts +0 -3
- package/dist/result.js +0 -4
- package/dist/tuple.d.ts.map +0 -1
- package/dist/tuple.js.map +0 -1
- package/dist/unit-CnjFzJN1.cjs +0 -12
- package/dist/unit-CnjFzJN1.cjs.map +0 -1
- package/dist/unit-CoBLIJFc.d.ts +0 -9
- package/dist/unit-CoBLIJFc.d.ts.map +0 -1
- package/dist/unit-D0y_qAUW.d.cts.map +0 -1
- package/dist/unit-udy5j53P.js.map +0 -1
- package/dist/unit.d.ts +0 -2
- package/dist/unit.js +0 -3
package/dist/unit.d.cts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unit.d.cts","names":[],"sources":["../src/unit.ts"],"sourcesContent":[],"mappings":";cAAa;AAAA,KACD,IAAA,GAD0B,OACZ,IADY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unit.d.mts","names":[],"sources":["../src/unit.ts"],"sourcesContent":[],"mappings":";cAAa;AAAA,KACD,IAAA,GAD0B,OACZ,IADY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unit.mjs","names":[],"sources":["../src/unit.ts"],"sourcesContent":["export const UNIT = Symbol.for(\"UNIT\");\nexport type UNIT = typeof UNIT;\n"],"mappings":";AAAA,MAAa,OAAO,OAAO,IAAI,OAAO"}
|
package/dist/utils.cjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/utils.ts
|
|
3
|
+
function isPromiseLike(value) {
|
|
4
|
+
return !!value && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
exports.isPromiseLike = isPromiseLike;
|
|
9
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["export function isPromiseLike<T>(value: unknown): value is Promise<T> {\n return (\n !!value &&\n (typeof value === \"object\" || typeof value === \"function\") &&\n // @ts-expect-error: we are checking for .then property existence\n typeof value.then === \"function\"\n );\n}\n"],"mappings":";;AAAA,SAAgB,cAAiB,OAAqC;AACpE,QACE,CAAC,CAAC,UACD,OAAO,UAAU,YAAY,OAAO,UAAU,eAE/C,OAAO,MAAM,SAAS"}
|
package/dist/utils.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.cts","names":[],"sources":["../src/utils.ts"],"sourcesContent":[],"mappings":";iBAAgB,2CAA2C,QAAQ"}
|
package/dist/utils.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.mts","names":[],"sources":["../src/utils.ts"],"sourcesContent":[],"mappings":";iBAAgB,2CAA2C,QAAQ"}
|
package/dist/utils.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["export function isPromiseLike<T>(value: unknown): value is Promise<T> {\n return (\n !!value &&\n (typeof value === \"object\" || typeof value === \"function\") &&\n // @ts-expect-error: we are checking for .then property existence\n typeof value.then === \"function\"\n );\n}\n"],"mappings":";AAAA,SAAgB,cAAiB,OAAqC;AACpE,QACE,CAAC,CAAC,UACD,OAAO,UAAU,YAAY,OAAO,UAAU,eAE/C,OAAO,MAAM,SAAS"}
|
package/package.json
CHANGED
|
@@ -1,55 +1,82 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbonteq/fp",
|
|
3
|
-
"version": "0.8.1",
|
|
4
3
|
"description": "FP utils",
|
|
4
|
+
"version": "0.9.1",
|
|
5
5
|
"author": "Arslan <rslnkrmt2552@gmail.com>",
|
|
6
|
-
"main": "lib/index.js",
|
|
7
|
-
"module": "lib/index.mjs",
|
|
8
|
-
"types": "lib/index.d.ts",
|
|
9
6
|
"license": "MIT",
|
|
7
|
+
"scope": "@carbonteq",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/carbonteq/fp.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/carbonteq/fp/issues"
|
|
14
|
+
},
|
|
10
15
|
"type": "module",
|
|
16
|
+
"files": [
|
|
17
|
+
"/dist",
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"main": "./dist/index.cjs",
|
|
21
|
+
"module": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
11
23
|
"exports": {
|
|
12
|
-
"node": {
|
|
13
|
-
"types": "./dist/index.d.ts",
|
|
14
|
-
"require": "./dist/index.cjs",
|
|
15
|
-
"import": "./dist/index.js"
|
|
16
|
-
},
|
|
17
24
|
".": {
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
25
|
+
"require": {
|
|
26
|
+
"types": "./dist/index.d.cts",
|
|
27
|
+
"default": "./dist/index.cjs"
|
|
28
|
+
},
|
|
29
|
+
"import": {
|
|
30
|
+
"types": "./dist/index.d.mts",
|
|
31
|
+
"default": "./dist/index.mjs"
|
|
32
|
+
}
|
|
21
33
|
},
|
|
22
34
|
"./result": {
|
|
23
|
-
"require":
|
|
24
|
-
|
|
25
|
-
|
|
35
|
+
"require": {
|
|
36
|
+
"types": "./dist/result.d.cts",
|
|
37
|
+
"default": "./dist/result.cjs"
|
|
38
|
+
},
|
|
39
|
+
"import": {
|
|
40
|
+
"types": "./dist/result.d.mts",
|
|
41
|
+
"default": "./dist/result.mjs"
|
|
42
|
+
}
|
|
26
43
|
},
|
|
27
44
|
"./option": {
|
|
28
|
-
"require":
|
|
29
|
-
|
|
30
|
-
|
|
45
|
+
"require": {
|
|
46
|
+
"types": "./dist/option.d.cts",
|
|
47
|
+
"default": "./dist/option.cjs"
|
|
48
|
+
},
|
|
49
|
+
"import": {
|
|
50
|
+
"types": "./dist/option.d.mts",
|
|
51
|
+
"default": "./dist/option.mjs"
|
|
52
|
+
}
|
|
31
53
|
},
|
|
32
54
|
"./match": {
|
|
33
|
-
"require":
|
|
34
|
-
|
|
35
|
-
|
|
55
|
+
"require": {
|
|
56
|
+
"types": "./dist/match.d.cts",
|
|
57
|
+
"default": "./dist/match.cjs"
|
|
58
|
+
},
|
|
59
|
+
"import": {
|
|
60
|
+
"types": "./dist/match.d.mts",
|
|
61
|
+
"default": "./dist/match.mjs"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"./errors": {
|
|
65
|
+
"require": {
|
|
66
|
+
"types": "./dist/errors.d.cts",
|
|
67
|
+
"default": "./dist/errors.cjs"
|
|
68
|
+
},
|
|
69
|
+
"import": {
|
|
70
|
+
"types": "./dist/errors.d.mts",
|
|
71
|
+
"default": "./dist/errors.mjs"
|
|
72
|
+
}
|
|
36
73
|
}
|
|
37
74
|
},
|
|
38
|
-
"files": [
|
|
39
|
-
"/dist"
|
|
40
|
-
],
|
|
41
|
-
"scope": "@carbonteq",
|
|
42
|
-
"repository": {
|
|
43
|
-
"type": "git",
|
|
44
|
-
"url": "https://github.com/carbonteq/fp"
|
|
45
|
-
},
|
|
46
|
-
"bugs": {
|
|
47
|
-
"url": "https://github.com/carbonteq/fp/issues"
|
|
48
|
-
},
|
|
49
75
|
"homepage": "https://github.com/carbonteq/fp#readme",
|
|
50
76
|
"sideEffects": false,
|
|
51
77
|
"publishConfig": {
|
|
52
78
|
"access": "public",
|
|
79
|
+
"provenance": true,
|
|
53
80
|
"registry": "https://registry.npmjs.org/"
|
|
54
81
|
},
|
|
55
82
|
"scripts": {
|
|
@@ -57,32 +84,40 @@
|
|
|
57
84
|
"lint:fix": "biome check src tests --write --unsafe",
|
|
58
85
|
"fmt:dry": "biome format src tests",
|
|
59
86
|
"fmt": "biome format src tests --write",
|
|
60
|
-
"tc": "tsc --pretty --noEmit
|
|
87
|
+
"tc": "tsc --pretty --noEmit",
|
|
61
88
|
"build": "NODE_ENV=production tsdown",
|
|
62
|
-
"bd": "tsdown",
|
|
63
89
|
"dev": "tsdown --watch",
|
|
64
|
-
"test": "
|
|
65
|
-
"test:
|
|
90
|
+
"test": "bun test",
|
|
91
|
+
"test:node": "tsx --test tests/*.test.ts",
|
|
92
|
+
"test:dbg": "bun test --inspect",
|
|
66
93
|
"release": "changeset publish",
|
|
67
|
-
"tag": "changeset tag"
|
|
94
|
+
"tag": "changeset tag",
|
|
95
|
+
"knip": "knip"
|
|
68
96
|
},
|
|
69
97
|
"devDependencies": {
|
|
70
|
-
"@biomejs/biome": "^
|
|
71
|
-
"@changesets/cli": "^2.
|
|
72
|
-
"@microsoft/api-extractor": "^7.
|
|
73
|
-
"@swc/core": "^1.
|
|
74
|
-
"@tsconfig/
|
|
75
|
-
"@
|
|
98
|
+
"@biomejs/biome": "^2.3.11",
|
|
99
|
+
"@changesets/cli": "^2.29.8",
|
|
100
|
+
"@microsoft/api-extractor": "^7.55.2",
|
|
101
|
+
"@swc/core": "^1.15.8",
|
|
102
|
+
"@tsconfig/bun": "^1.0.10",
|
|
103
|
+
"@tsconfig/node22": "^22.0.5",
|
|
104
|
+
"@types/bun": "^1.3.5",
|
|
105
|
+
"@types/node": "^24.10.1",
|
|
106
|
+
"@typescript/native-preview": "^7.0.0-dev.20260107.1",
|
|
107
|
+
"bunup": "^0.16.17",
|
|
76
108
|
"changesets": "^1.0.2",
|
|
77
|
-
"jsr": "^0.13.
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
109
|
+
"jsr": "^0.13.5",
|
|
110
|
+
"knip": "^5.80.0",
|
|
111
|
+
"oxfmt": "^0.23.0",
|
|
112
|
+
"oxlint": "^1.38.0",
|
|
113
|
+
"oxlint-tsgolint": "^0.10.1",
|
|
114
|
+
"tsdown": "^0.19.0-beta.4",
|
|
115
|
+
"tsx": "^4.21.0",
|
|
116
|
+
"typescript": "^5.9.3"
|
|
81
117
|
},
|
|
82
118
|
"engines": {
|
|
83
|
-
"node": ">=
|
|
84
|
-
"npm": ">=8.0.0",
|
|
85
|
-
"yarn": ">=1.22.0"
|
|
119
|
+
"node": ">=22.0.0"
|
|
86
120
|
},
|
|
87
|
-
"
|
|
121
|
+
"trustedDependencies": [],
|
|
122
|
+
"packageManager": "bun@1.3.5"
|
|
88
123
|
}
|
package/dist/chunk-CUT6urMc.cjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
|
|
25
|
-
Object.defineProperty(exports, '__toESM', {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () {
|
|
28
|
-
return __toESM;
|
|
29
|
-
}
|
|
30
|
-
});
|
package/dist/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { UNIT$1 as UNIT } from "./unit-CoBLIJFc.js";
|
|
2
|
-
import { CombineResults, Result$1 as Result, UnitResult, UnwrapResult, UnwrappedErrWithOk$1 as UnwrappedErrWithOk, UnwrappedOkWithErr$1 as UnwrappedOkWithErr } from "./result-DsVjSFnO.js";
|
|
3
|
-
import { Option$1 as Option, UnitOption, UnwrapOption, UnwrappedNone$1 as UnwrappedNone } from "./option-CoelyMEg.js";
|
|
4
|
-
import { matchOpt$1 as matchOpt, matchRes$1 as matchRes } from "./match-DXKW7ym5.js";
|
|
5
|
-
export { CombineResults, Option, Result, UNIT, UnitOption, UnitResult, UnwrapOption, UnwrapResult, UnwrappedErrWithOk, UnwrappedNone, UnwrappedOkWithErr, matchOpt, matchRes };
|
package/dist/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { UNIT } from "./unit-udy5j53P.js";
|
|
2
|
-
import { Result, UnwrappedErrWithOk, UnwrappedOkWithErr } from "./result-CdGWA5IL.js";
|
|
3
|
-
import { Option, UnwrappedNone } from "./option-Be_DXVE6.js";
|
|
4
|
-
import { matchOpt, matchRes } from "./match-BQP0RNSk.js";
|
|
5
|
-
|
|
6
|
-
export { Option, Result, UNIT, UnwrappedErrWithOk, UnwrappedNone, UnwrappedOkWithErr, matchOpt, matchRes };
|
package/dist/match-BQP0RNSk.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
//#region src/match.ts
|
|
2
|
-
const matchRes = (r, branches) => {
|
|
3
|
-
if (r.isOk()) return branches.Ok(r.unwrap());
|
|
4
|
-
return branches.Err(r.unwrapErr());
|
|
5
|
-
};
|
|
6
|
-
const matchOpt = (o, branches) => {
|
|
7
|
-
if (o.isSome()) return branches.Some(o.unwrap());
|
|
8
|
-
return branches.None();
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
//#endregion
|
|
12
|
-
export { matchOpt, matchRes };
|
|
13
|
-
//# sourceMappingURL=match-BQP0RNSk.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"match-BQP0RNSk.js","names":["r: Result<T, E>","branches: { Ok: (val: T) => U; Err: (err: E) => U }","o: Option<T>","branches: { Some: (val: T) => U; None: () => U }"],"sources":["../src/match.ts"],"sourcesContent":["import type { Option } from \"./option.ts\";\nimport type { Result } from \"./result.ts\";\n\nexport const matchRes = <T, E, U>(\n r: Result<T, E>,\n branches: { Ok: (val: T) => U; Err: (err: E) => U },\n): U => {\n if (r.isOk()) {\n return branches.Ok(r.unwrap());\n }\n\n return branches.Err(r.unwrapErr());\n};\n\nexport const matchOpt = <T, U>(\n o: Option<T>,\n branches: { Some: (val: T) => U; None: () => U },\n): U => {\n if (o.isSome()) {\n return branches.Some(o.unwrap());\n }\n return branches.None();\n};\n"],"mappings":";AAGA,MAAa,WAAW,CACtBA,GACAC,aACM;AACN,KAAI,EAAE,MAAM,CACV,QAAO,SAAS,GAAG,EAAE,QAAQ,CAAC;AAGhC,QAAO,SAAS,IAAI,EAAE,WAAW,CAAC;AACnC;AAED,MAAa,WAAW,CACtBC,GACAC,aACM;AACN,KAAI,EAAE,QAAQ,CACZ,QAAO,SAAS,KAAK,EAAE,QAAQ,CAAC;AAElC,QAAO,SAAS,MAAM;AACvB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"match-COIWq-e8.d.cts","names":[],"sources":["../src/match.ts"],"sourcesContent":[],"mappings":";;;;cAGa,uBACR,OAAO,GAAG;YACS,MAAM;EAFjB,GAAA,EAAA,CAAA,GAAA,EAE+B,CAO3C,EAAA,GAPiD,CAOjD;CAAA,EAAA,GANE,CAMF;AARW,cAUC,QAVD,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,EAWP,MAXO,CAWA,CAXA,CAAA,EAAA,QAAA,EAAA;EAAC,IAAE,EAAA,CAAA,GAAA,EAYW,CAZX,EAAA,GAYiB,CAZjB;EAAC,IAAX,EAAA,GAAA,GAY0C,CAZ1C;CAAM,EAAA,GAaR,CAZqB"}
|
package/dist/match-DXKW7ym5.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Result$1 as Result } from "./result-DsVjSFnO.js";
|
|
2
|
-
import { Option$1 as Option } from "./option-CoelyMEg.js";
|
|
3
|
-
|
|
4
|
-
//#region src/match.d.ts
|
|
5
|
-
declare const matchRes: <T, E, U>(r: Result<T, E>, branches: {
|
|
6
|
-
Ok: (val: T) => U;
|
|
7
|
-
Err: (err: E) => U;
|
|
8
|
-
}) => U;
|
|
9
|
-
declare const matchOpt: <T, U>(o: Option<T>, branches: {
|
|
10
|
-
Some: (val: T) => U;
|
|
11
|
-
None: () => U;
|
|
12
|
-
}) => U;
|
|
13
|
-
|
|
14
|
-
//#endregion
|
|
15
|
-
//# sourceMappingURL=match.d.ts.map
|
|
16
|
-
|
|
17
|
-
export { matchOpt as matchOpt$1, matchRes as matchRes$1 };
|
|
18
|
-
//# sourceMappingURL=match-DXKW7ym5.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"match-DXKW7ym5.d.ts","names":[],"sources":["../src/match.ts"],"sourcesContent":[],"mappings":";;;;cAGa,uBACR,OAAO,GAAG;YACS,MAAM;EAFjB,GAAA,EAAA,CAAA,GAAA,EAE+B,CAO3C,EAAA,GAPiD,CAOjD;CAAA,EAAA,GANE,CAMF;AARW,cAUC,QAVD,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,EAWP,MAXO,CAWA,CAXA,CAAA,EAAA,QAAA,EAAA;EAAC,IAAE,EAAA,CAAA,GAAA,EAYW,CAZX,EAAA,GAYiB,CAZjB;EAAC,IAAX,EAAA,GAAA,GAY0C,CAZ1C;CAAM,EAAA,GAaR,CAZqB"}
|
package/dist/match-DyAuOeqx.cjs
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/match.ts
|
|
3
|
-
const matchRes = (r, branches) => {
|
|
4
|
-
if (r.isOk()) return branches.Ok(r.unwrap());
|
|
5
|
-
return branches.Err(r.unwrapErr());
|
|
6
|
-
};
|
|
7
|
-
const matchOpt = (o, branches) => {
|
|
8
|
-
if (o.isSome()) return branches.Some(o.unwrap());
|
|
9
|
-
return branches.None();
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
//#endregion
|
|
13
|
-
Object.defineProperty(exports, 'matchOpt', {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () {
|
|
16
|
-
return matchOpt;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports, 'matchRes', {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function () {
|
|
22
|
-
return matchRes;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
//# sourceMappingURL=match-DyAuOeqx.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"match-DyAuOeqx.cjs","names":["r: Result<T, E>","branches: { Ok: (val: T) => U; Err: (err: E) => U }","o: Option<T>","branches: { Some: (val: T) => U; None: () => U }"],"sources":["../src/match.ts"],"sourcesContent":["import type { Option } from \"./option.ts\";\nimport type { Result } from \"./result.ts\";\n\nexport const matchRes = <T, E, U>(\n r: Result<T, E>,\n branches: { Ok: (val: T) => U; Err: (err: E) => U },\n): U => {\n if (r.isOk()) {\n return branches.Ok(r.unwrap());\n }\n\n return branches.Err(r.unwrapErr());\n};\n\nexport const matchOpt = <T, U>(\n o: Option<T>,\n branches: { Some: (val: T) => U; None: () => U },\n): U => {\n if (o.isSome()) {\n return branches.Some(o.unwrap());\n }\n return branches.None();\n};\n"],"mappings":";;AAGA,MAAa,WAAW,CACtBA,GACAC,aACM;AACN,KAAI,EAAE,MAAM,CACV,QAAO,SAAS,GAAG,EAAE,QAAQ,CAAC;AAGhC,QAAO,SAAS,IAAI,EAAE,WAAW,CAAC;AACnC;AAED,MAAa,WAAW,CACtBC,GACAC,aACM;AACN,KAAI,EAAE,QAAQ,CACZ,QAAO,SAAS,KAAK,EAAE,QAAQ,CAAC;AAElC,QAAO,SAAS,MAAM;AACvB"}
|
package/dist/match.d.ts
DELETED
package/dist/match.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { UNIT } from "./unit-D0y_qAUW.cjs";
|
|
2
|
-
|
|
3
|
-
//#region src/option.d.ts
|
|
4
|
-
declare class UnwrappedNone extends Error {
|
|
5
|
-
constructor();
|
|
6
|
-
}
|
|
7
|
-
type UnitOption = Option<UNIT>;
|
|
8
|
-
type UnwrapOption<T> = T extends Option<infer R> ? R : never;
|
|
9
|
-
declare class Option<T> {
|
|
10
|
-
#private;
|
|
11
|
-
private val;
|
|
12
|
-
private constructor();
|
|
13
|
-
static readonly None: Option<never>;
|
|
14
|
-
private static safeMap;
|
|
15
|
-
static Some<Inner>(val: Inner): Option<Inner>;
|
|
16
|
-
static fromNullable<T, Out = NonNullable<T>>(val: T): Option<Out>;
|
|
17
|
-
isSome(): this is Option<T>;
|
|
18
|
-
isNone(): this is Option<never>;
|
|
19
|
-
isUnit(): this is Option<UNIT>;
|
|
20
|
-
unwrap(): T;
|
|
21
|
-
safeUnwrap(): T | null;
|
|
22
|
-
map<U, Curr = Awaited<T>>(mapper: (val: Curr) => U): Option<U>;
|
|
23
|
-
map<U, Curr = Awaited<T>>(mapper: (val: Curr) => Promise<U>): Option<Promise<U>>;
|
|
24
|
-
mapOr<U, Curr = Awaited<T>>(default_: U, fn: (val: Curr) => U): Option<U>;
|
|
25
|
-
mapOr<U, Curr = Awaited<T>>(default_: U, fn: (val: Curr) => Promise<U>): Option<Promise<U>>;
|
|
26
|
-
flatMap<U, Curr = Awaited<T>>(mapper: (val: Curr) => Option<U>): Option<U>;
|
|
27
|
-
flatMap<U, Curr = Awaited<T>>(mapper: (val: Curr) => Promise<Option<U>>): Option<Promise<U>>;
|
|
28
|
-
zip<U, Curr>(this: Option<Promise<Curr>>, fn: (val: Curr) => U): Option<Promise<[Curr, U]>>;
|
|
29
|
-
zip<U, Curr>(this: Option<Curr>, fn: (val: Curr) => Promise<U>): Option<Promise<[T, U]>>;
|
|
30
|
-
zip<U, Curr>(this: Option<Curr>, fn: (val: Curr) => U): Option<[T, U]>;
|
|
31
|
-
flatZip<U, Curr>(this: Option<Promise<Curr>>, fn: (val: Curr) => Promise<Option<U>>): Option<Promise<[Curr, U]>>;
|
|
32
|
-
flatZip<U, Curr>(this: Option<Promise<Curr>>, fn: (val: Curr) => Option<U>): Option<Promise<[Curr, U]>>;
|
|
33
|
-
flatZip<U, Curr>(this: Option<Curr>, fn: (val: Curr) => Promise<Option<U>>): Option<Promise<[T, U]>>;
|
|
34
|
-
flatZip<U, Curr>(this: Option<Curr>, fn: (val: Curr) => Option<U>): Option<[T, U]>;
|
|
35
|
-
toPromise<Curr = Awaited<T>>(): Promise<Option<Curr>>;
|
|
36
|
-
static fromPromise<U>(o: Promise<Option<U>>): Option<Promise<U>>;
|
|
37
|
-
toString(): string;
|
|
38
|
-
innerMap<Inner, Out>(this: Option<Array<Inner>>, mapper: (val: Inner) => Out): Option<NoInfer<Out>[]>;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
//# sourceMappingURL=option.d.ts.map
|
|
43
|
-
|
|
44
|
-
export { Option, UnitOption, UnwrapOption, UnwrappedNone };
|
|
45
|
-
//# sourceMappingURL=option-8_eiz02z.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"option-8_eiz02z.d.cts","names":[],"sources":["../src/option.ts"],"sourcesContent":[],"mappings":";;;cAMa,aAAA,SAAsB,KAAK;;AAAxC;AASY,KAAA,UAAA,GAAa,MAAH,CAAU,IAAV,CAAA;AAAA,KACV,YADU,CAAA,CAAA,CAAA,GACQ,CADR,SACkB,MADlB,CAAA,KAAA,EAAA,CAAA,GACoC,CADpC,GAAA,KAAA;AAAU,cAUnB,MAVmB,CAAA,CAAA,CAAA,CAAA;EAAI,CAAA,OAAX;EA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CAAA,EAAA,IAAA,CAAA,CAAA,IAAA,EA8JF,MA9JE,CA8JK,IA9JL,CAAA,EAAA,EAAA,EAAA,CAAA,GAAA,EA+JE,IA/JF,EAAA,GA+JW,MA/JX,CA+JkB,CA/JlB,CAAA,CAAA,EAgKP,MAhKO,CAAA,CAgKC,CAhKD,EAgKI,CAhKJ,CAAA,CAAA;EAAC,SAQG,CAAA,OAoMS,OApMT,CAoMiB,CApMjB,CAAA,CAAA,CAAA,CAAA,EAoMwB,OApMxB,CAoMgC,MApMhC,CAoMuC,IApMvC,CAAA,CAAA;EAAC,OAMO,WAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EA4MG,OA5MH,CA4MW,MA5MX,CA4MkB,CA5MlB,CAAA,CAAA,CAAA,EA4MwB,MA5MxB,CA4M+B,OA5M/B,CA4MuC,CA5MvC,CAAA,CAAA;EAAC,QAAT,CAAA,CAAA,EAAA,MAAA;EAAO,QAAmB,CAAA,KAAA,EAAA,GAAA,CAAA,CAAA,IAAA,EAkOhC,MAlOgC,CAkOzB,KAlOyB,CAkOnB,KAlOmB,CAAA,CAAA,EAAA,MAAA,EAAA,CAAA,GAAA,EAmOxB,KAnOwB,EAAA,GAmOd,GAnOc,CAAA,EAoOrC,MApOqC,CAoO9B,OApO8B,CAoOtB,GApOsB,CAAA,EAAA,CAAA"}
|
package/dist/option-Be_DXVE6.js
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import { UNIT } from "./unit-udy5j53P.js";
|
|
2
|
-
import { isPromise } from "node:util/types";
|
|
3
|
-
|
|
4
|
-
//#region src/option.ts
|
|
5
|
-
var UnwrappedNone = class extends Error {
|
|
6
|
-
constructor() {
|
|
7
|
-
super("Unwrapped Option<None>");
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
const UNWRAPPED_NONE_ERR = new UnwrappedNone();
|
|
11
|
-
const NONE_VAL = Symbol.for("None");
|
|
12
|
-
var Option = class Option {
|
|
13
|
-
#ctx;
|
|
14
|
-
constructor(val, ctx) {
|
|
15
|
-
this.val = val;
|
|
16
|
-
this.#ctx = ctx;
|
|
17
|
-
}
|
|
18
|
-
static None = new Option(NONE_VAL, { promiseNoneSlot: true });
|
|
19
|
-
static safeMap(p, mapper, ctx) {
|
|
20
|
-
return p.then((v) => {
|
|
21
|
-
if (v === NONE_VAL) {
|
|
22
|
-
ctx.promiseNoneSlot = true;
|
|
23
|
-
return NONE_VAL;
|
|
24
|
-
}
|
|
25
|
-
return mapper(v);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
static Some(val) {
|
|
29
|
-
return new Option(val, { promiseNoneSlot: false });
|
|
30
|
-
}
|
|
31
|
-
static fromNullable(val) {
|
|
32
|
-
return val === null ? Option.None : Option.Some(val);
|
|
33
|
-
}
|
|
34
|
-
isSome() {
|
|
35
|
-
return this.val !== NONE_VAL;
|
|
36
|
-
}
|
|
37
|
-
isNone() {
|
|
38
|
-
return this.val === NONE_VAL || isPromise(this.val) && this.#ctx.promiseNoneSlot;
|
|
39
|
-
}
|
|
40
|
-
isUnit() {
|
|
41
|
-
return this.val === UNIT;
|
|
42
|
-
}
|
|
43
|
-
unwrap() {
|
|
44
|
-
if (this.isNone()) throw UNWRAPPED_NONE_ERR;
|
|
45
|
-
return this.val;
|
|
46
|
-
}
|
|
47
|
-
safeUnwrap() {
|
|
48
|
-
if (this.isNone()) return null;
|
|
49
|
-
return this.val;
|
|
50
|
-
}
|
|
51
|
-
map(mapper) {
|
|
52
|
-
if (this.isNone()) return Option.None;
|
|
53
|
-
const ctx = this.#ctx;
|
|
54
|
-
const curr = this.val;
|
|
55
|
-
if (isPromise(curr)) {
|
|
56
|
-
const p = curr;
|
|
57
|
-
const safetlyMapped = Option.safeMap(p, mapper, ctx);
|
|
58
|
-
return new Option(safetlyMapped, ctx);
|
|
59
|
-
}
|
|
60
|
-
const transformed = mapper(curr);
|
|
61
|
-
return new Option(transformed, ctx);
|
|
62
|
-
}
|
|
63
|
-
mapOr(default_, mapper) {
|
|
64
|
-
if (this.isNone()) return new Option(default_, this.#ctx);
|
|
65
|
-
const ctx = this.#ctx;
|
|
66
|
-
const curr = this.val;
|
|
67
|
-
if (isPromise(curr)) {
|
|
68
|
-
const p = curr;
|
|
69
|
-
const safetlyMapped = Option.safeMap(p, mapper, ctx);
|
|
70
|
-
return new Option(safetlyMapped, ctx);
|
|
71
|
-
}
|
|
72
|
-
const transformed = mapper(curr);
|
|
73
|
-
return new Option(transformed, ctx);
|
|
74
|
-
}
|
|
75
|
-
flatMap(mapper) {
|
|
76
|
-
if (this.isNone()) return Option.None;
|
|
77
|
-
const ctx = this.#ctx;
|
|
78
|
-
const curr = this.val;
|
|
79
|
-
if (isPromise(curr)) {
|
|
80
|
-
const p = curr;
|
|
81
|
-
const castedNone = NONE_VAL;
|
|
82
|
-
const newP = new Promise((resolve, reject) => {
|
|
83
|
-
p.then((curr$1) => {
|
|
84
|
-
if (curr$1 === NONE_VAL) {
|
|
85
|
-
ctx.promiseNoneSlot = true;
|
|
86
|
-
resolve(castedNone);
|
|
87
|
-
} else {
|
|
88
|
-
const r = mapper(curr$1);
|
|
89
|
-
if (isPromise(r)) r.then((innerOpt) => resolve(innerOpt.val), reject);
|
|
90
|
-
else resolve(r.val);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
return new Option(newP, ctx);
|
|
95
|
-
}
|
|
96
|
-
const mapped = mapper(curr);
|
|
97
|
-
if (isPromise(mapped)) return Option.fromPromise(mapped);
|
|
98
|
-
return mapped;
|
|
99
|
-
}
|
|
100
|
-
zip(fn) {
|
|
101
|
-
if (this.isNone()) return Option.None;
|
|
102
|
-
const curr = this.val;
|
|
103
|
-
const ctx = this.#ctx;
|
|
104
|
-
if (isPromise(curr)) {
|
|
105
|
-
const val = curr;
|
|
106
|
-
const p = val.then(async (v) => {
|
|
107
|
-
if (v === NONE_VAL) {
|
|
108
|
-
ctx.promiseNoneSlot = true;
|
|
109
|
-
return NONE_VAL;
|
|
110
|
-
}
|
|
111
|
-
const next = await fn(v);
|
|
112
|
-
return [v, next];
|
|
113
|
-
});
|
|
114
|
-
return new Option(p, ctx);
|
|
115
|
-
}
|
|
116
|
-
const u = fn(curr);
|
|
117
|
-
if (isPromise(u)) {
|
|
118
|
-
const p = u.then((uu) => [curr, uu]);
|
|
119
|
-
return new Option(p, ctx);
|
|
120
|
-
}
|
|
121
|
-
return new Option([curr, u], ctx);
|
|
122
|
-
}
|
|
123
|
-
flatZip(fn) {
|
|
124
|
-
if (this.isNone()) return Option.None;
|
|
125
|
-
const curr = this.val;
|
|
126
|
-
const ctx = this.#ctx;
|
|
127
|
-
if (isPromise(curr)) {
|
|
128
|
-
const val = curr;
|
|
129
|
-
const p = val.then(async (v) => {
|
|
130
|
-
if (v === NONE_VAL) {
|
|
131
|
-
ctx.promiseNoneSlot = true;
|
|
132
|
-
return NONE_VAL;
|
|
133
|
-
}
|
|
134
|
-
const next = await fn(v);
|
|
135
|
-
if (next.isNone()) return NONE_VAL;
|
|
136
|
-
return [v, next.val];
|
|
137
|
-
});
|
|
138
|
-
return new Option(p, ctx);
|
|
139
|
-
}
|
|
140
|
-
const c = curr;
|
|
141
|
-
const u = fn(c);
|
|
142
|
-
if (isPromise(u)) {
|
|
143
|
-
const p = u.then((uu) => {
|
|
144
|
-
if (uu.isNone()) return NONE_VAL;
|
|
145
|
-
return [c, uu.val];
|
|
146
|
-
});
|
|
147
|
-
return new Option(p, ctx);
|
|
148
|
-
}
|
|
149
|
-
return u.map((inner) => [c, inner]);
|
|
150
|
-
}
|
|
151
|
-
async toPromise() {
|
|
152
|
-
const curr = this.val;
|
|
153
|
-
let inner;
|
|
154
|
-
if (isPromise(curr)) {
|
|
155
|
-
const awaited = await curr;
|
|
156
|
-
inner = awaited;
|
|
157
|
-
} else inner = curr;
|
|
158
|
-
return new Option(inner, this.#ctx);
|
|
159
|
-
}
|
|
160
|
-
static fromPromise(o) {
|
|
161
|
-
const ctx = { promiseNoneSlot: false };
|
|
162
|
-
const p = new Promise((resolve, reject) => o.then((innerOpt) => {
|
|
163
|
-
ctx.promiseNoneSlot ||= innerOpt.#ctx.promiseNoneSlot;
|
|
164
|
-
resolve(innerOpt.val);
|
|
165
|
-
}, reject));
|
|
166
|
-
return new Option(p, ctx);
|
|
167
|
-
}
|
|
168
|
-
toString() {
|
|
169
|
-
if (this.isNone()) return "Option::None";
|
|
170
|
-
return `Option::Some(${this.val})`;
|
|
171
|
-
}
|
|
172
|
-
innerMap(mapper) {
|
|
173
|
-
if (this.isNone()) return Option.None;
|
|
174
|
-
if (!Array.isArray(this.val)) throw new Error("Can only be called for Option<Array<T>>");
|
|
175
|
-
return new Option(this.val.map(mapper), this.#ctx);
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
//#endregion
|
|
180
|
-
export { Option, UnwrappedNone };
|
|
181
|
-
//# sourceMappingURL=option-Be_DXVE6.js.map
|