functype 0.8.62 → 0.8.63
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/dist/Tuple-DfdXAbL_.d.ts +52 -0
- package/dist/branded/index.d.ts +48 -1
- package/dist/branded/index.mjs +2 -23
- package/dist/branded/index.mjs.map +1 -1
- package/dist/chunk-3DIRMZSK.mjs +2 -0
- package/dist/chunk-3DIRMZSK.mjs.map +1 -0
- package/dist/chunk-PXFJPCM7.mjs +2 -0
- package/dist/chunk-PXFJPCM7.mjs.map +1 -0
- package/dist/chunk-TQJDL6YW.mjs +2 -0
- package/dist/chunk-TQJDL6YW.mjs.map +1 -0
- package/dist/either/index.d.ts +3 -1
- package/dist/either/index.mjs +2 -13
- package/dist/either/index.mjs.map +1 -1
- package/dist/fpromise/index.d.ts +3 -2
- package/dist/fpromise/index.mjs +2 -6
- package/dist/fpromise/index.mjs.map +1 -1
- package/dist/index.d.ts +3 -28
- package/dist/index.mjs +2 -174
- package/dist/index.mjs.map +1 -1
- package/dist/list/index.d.ts +3 -1
- package/dist/list/index.mjs +2 -5
- package/dist/list/index.mjs.map +1 -1
- package/dist/map/index.d.ts +3 -2
- package/dist/map/index.mjs +2 -7
- package/dist/map/index.mjs.map +1 -1
- package/dist/option/index.d.ts +870 -1
- package/dist/option/index.mjs +2 -7
- package/dist/option/index.mjs.map +1 -1
- package/dist/set/index.d.ts +3 -2
- package/dist/set/index.mjs +2 -5
- package/dist/set/index.mjs.map +1 -1
- package/dist/try/index.d.ts +3 -1
- package/dist/try/index.mjs +2 -44
- package/dist/try/index.mjs.map +1 -1
- package/dist/tuple/index.d.ts +1 -1
- package/dist/tuple/index.mjs +2 -27
- package/dist/tuple/index.mjs.map +1 -1
- package/package.json +6 -7
- package/dist/Map-BNxKlujn.mjs +0 -46
- package/dist/Map-BNxKlujn.mjs.map +0 -1
- package/dist/branded/Brand.d.ts +0 -46
- package/dist/collections/index.d.ts +0 -8
- package/dist/companion/Companion.d.ts +0 -23
- package/dist/companion/index.d.ts +0 -1
- package/dist/core/base/Base.d.ts +0 -10
- package/dist/core/base/index.d.ts +0 -1
- package/dist/core/index.d.ts +0 -4
- package/dist/core/info/Info.d.ts +0 -26
- package/dist/core/info/index.d.ts +0 -1
- package/dist/core/task/Task.d.ts +0 -57
- package/dist/core/task/index.d.ts +0 -1
- package/dist/core/throwable/Throwable.d.ts +0 -18
- package/dist/core/throwable/index.d.ts +0 -1
- package/dist/either/Either.d.ts +0 -57
- package/dist/error/ParseError.d.ts +0 -6
- package/dist/error/index.d.ts +0 -1
- package/dist/fpromise/FPromise.d.ts +0 -369
- package/dist/fpromise/retry.d.ts +0 -106
- package/dist/functor/index.d.ts +0 -18
- package/dist/hkt/index.d.ts +0 -49
- package/dist/identity/Identity.d.ts +0 -5
- package/dist/identity/index.d.ts +0 -1
- package/dist/index-CgMYHgdG.mjs +0 -1286
- package/dist/index-CgMYHgdG.mjs.map +0 -1
- package/dist/iterable/index.d.ts +0 -25
- package/dist/list/List.d.ts +0 -45
- package/dist/map/Map.d.ts +0 -19
- package/dist/map/shim.d.ts +0 -2
- package/dist/option/Option.d.ts +0 -164
- package/dist/serializable/Serializable.d.ts +0 -15
- package/dist/serializable/index.d.ts +0 -1
- package/dist/set/Set.d.ts +0 -16
- package/dist/set/shim.d.ts +0 -2
- package/dist/try/Try.d.ts +0 -20
- package/dist/tuple/Tuple.d.ts +0 -11
- package/dist/typeable/Typeable.d.ts +0 -10
- package/dist/typeable/index.d.ts +0 -1
- package/dist/util/index.d.ts +0 -3
- package/dist/util/isIterable.d.ts +0 -1
- package/dist/valuable/Valuable.d.ts +0 -13
- package/dist/valuable/index.d.ts +0 -1
package/dist/option/index.mjs
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
e as None,
|
|
4
|
-
s as Option,
|
|
5
|
-
m as Some
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
export{e as None,f as Option,d as Some}from'../chunk-3DIRMZSK.mjs';import'../chunk-PXFJPCM7.mjs';import'../chunk-TQJDL6YW.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
|
package/dist/set/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export { S as Set } from '../option/index.js';
|
|
2
|
+
import '../Tuple-DfdXAbL_.js';
|
|
3
|
+
import '../branded/index.js';
|
package/dist/set/index.mjs
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
o as Set
|
|
4
|
-
};
|
|
5
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
export{g as Set}from'../chunk-3DIRMZSK.mjs';import'../chunk-PXFJPCM7.mjs';import'../chunk-TQJDL6YW.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
package/dist/set/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
|
package/dist/try/index.d.ts
CHANGED
package/dist/try/index.mjs
CHANGED
|
@@ -1,44 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
_tag: "Success",
|
|
4
|
-
error: void 0,
|
|
5
|
-
isSuccess: () => !0,
|
|
6
|
-
isFailure: () => !1,
|
|
7
|
-
get: () => t,
|
|
8
|
-
getOrElse: (r) => t,
|
|
9
|
-
orElse: (r) => a(t),
|
|
10
|
-
orThrow: (r) => t,
|
|
11
|
-
toEither: () => o(t),
|
|
12
|
-
map: (r) => c(() => r(t)),
|
|
13
|
-
flatMap: (r) => r(t),
|
|
14
|
-
toString: () => `Success(${e(t)})`,
|
|
15
|
-
toValue: () => ({ _tag: "Success", value: t })
|
|
16
|
-
}), s = (t) => ({
|
|
17
|
-
_tag: "Failure",
|
|
18
|
-
error: t,
|
|
19
|
-
isSuccess: () => !1,
|
|
20
|
-
isFailure: () => !0,
|
|
21
|
-
get: () => {
|
|
22
|
-
throw t;
|
|
23
|
-
},
|
|
24
|
-
getOrElse: (r) => r,
|
|
25
|
-
orElse: (r) => r,
|
|
26
|
-
orThrow: (r) => {
|
|
27
|
-
throw r;
|
|
28
|
-
},
|
|
29
|
-
toEither: () => i(t),
|
|
30
|
-
map: (r) => s(t),
|
|
31
|
-
flatMap: (r) => s(t),
|
|
32
|
-
toString: () => `Failure(${e(t)}))`,
|
|
33
|
-
toValue: () => ({ _tag: "Failure", value: t })
|
|
34
|
-
}), c = (t) => {
|
|
35
|
-
try {
|
|
36
|
-
return a(t());
|
|
37
|
-
} catch (r) {
|
|
38
|
-
return s(r instanceof Error ? r : new Error(String(r)));
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
export {
|
|
42
|
-
c as Try
|
|
43
|
-
};
|
|
44
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
export{w as Try}from'../chunk-3DIRMZSK.mjs';import'../chunk-PXFJPCM7.mjs';import'../chunk-TQJDL6YW.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
package/dist/try/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
|
package/dist/tuple/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { b as Tuple } from '../Tuple-DfdXAbL_.js';
|
package/dist/tuple/index.mjs
CHANGED
|
@@ -1,27 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
map: (e) => {
|
|
4
|
-
const r = e(t);
|
|
5
|
-
return n(r);
|
|
6
|
-
},
|
|
7
|
-
flatMap: (e) => e(t),
|
|
8
|
-
get: (e) => t[e],
|
|
9
|
-
toArray: () => t,
|
|
10
|
-
[Symbol.iterator]() {
|
|
11
|
-
let e = 0;
|
|
12
|
-
return {
|
|
13
|
-
next: () => e < t.length ? {
|
|
14
|
-
value: t[e++],
|
|
15
|
-
done: !1
|
|
16
|
-
} : {
|
|
17
|
-
value: void 0,
|
|
18
|
-
done: !0
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
},
|
|
22
|
-
toValue: () => ({ _tag: "Tuple", value: t })
|
|
23
|
-
});
|
|
24
|
-
export {
|
|
25
|
-
n as Tuple
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
export{c as Tuple}from'../chunk-PXFJPCM7.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
package/dist/tuple/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functype",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.63",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A smallish functional library for TypeScript",
|
|
6
6
|
"author": "jordan.burke@gmail.com",
|
|
@@ -31,11 +31,10 @@
|
|
|
31
31
|
"prettier": "^3.5.3",
|
|
32
32
|
"rimraf": "^6.0.1",
|
|
33
33
|
"ts-node": "^10.9.2",
|
|
34
|
+
"tsup": "^8.4.0",
|
|
34
35
|
"typedoc": "^0.28.2",
|
|
35
36
|
"typescript": "5.8.3",
|
|
36
|
-
"vitest": "^3.1.1"
|
|
37
|
-
"vite": "^6.2.6",
|
|
38
|
-
"vite-plugin-dts": "^4.5.3"
|
|
37
|
+
"vitest": "^3.1.1"
|
|
39
38
|
},
|
|
40
39
|
"types": "./dist/index.d.ts",
|
|
41
40
|
"module": "./dist/index.mjs",
|
|
@@ -117,9 +116,9 @@
|
|
|
117
116
|
"scripts": {
|
|
118
117
|
"compile": "tsc --noEmit",
|
|
119
118
|
"build": "pnpm compile && pnpm lint && pnpm test",
|
|
120
|
-
"build:dev": "
|
|
121
|
-
"build:prod": "pnpm compile && pnpm test &&
|
|
122
|
-
"build:watch": "
|
|
119
|
+
"build:dev": "tsup --watch",
|
|
120
|
+
"build:prod": "pnpm compile && pnpm test && cross-env NODE_ENV=production tsup",
|
|
121
|
+
"build:watch": "tsup --watch",
|
|
123
122
|
"build:publish": "pnpm build:prod && pnpm publish --access public",
|
|
124
123
|
"lint:fix": "eslint ./src --quiet --fix",
|
|
125
124
|
"lint:format": "prettier --loglevel warn --write \"./**/*.{ts,tsx,css,md,json}\" ",
|
package/dist/Map-BNxKlujn.mjs
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { f as h, e as n, O as c } from "./index-CgMYHgdG.mjs";
|
|
2
|
-
import { Tuple as w } from "./tuple/index.mjs";
|
|
3
|
-
const l = Map, r = (a) => {
|
|
4
|
-
const i = "Map", s = {
|
|
5
|
-
values: new l(a)
|
|
6
|
-
}, o = () => Array.from(s.values.entries()).map(([t, e]) => w([t, e])), u = (t) => r(new l(s.values).set(t.toArray()[0], t.toArray()[1]).entries()), p = (t) => {
|
|
7
|
-
const e = new l(s.values);
|
|
8
|
-
return e.delete(t) ? r(e.entries()) : r(s.values.entries());
|
|
9
|
-
}, g = (t) => {
|
|
10
|
-
const e = t.toArray();
|
|
11
|
-
return s.values.get(e[0]) === e[1];
|
|
12
|
-
}, v = () => s.values.size, f = (t) => r(Array.from(s.values.entries()).map(([e, O]) => [e, t(O)])), d = (t) => {
|
|
13
|
-
const e = r(s.values.entries()).toList();
|
|
14
|
-
return r(e.flatMap(t).toArray());
|
|
15
|
-
}, m = (t) => n(o()).reduce(t), M = (t) => n(o()).reduceRight(t), E = (t) => (e) => n(o()).foldLeft(t)(e), y = (t) => (e) => n(o()).foldRight(t)(e), S = (t) => c(s.values.get(t)), A = (t, e) => c(s.values.get(t)).getOrElse(e), L = () => s.values.size === 0;
|
|
16
|
-
return {
|
|
17
|
-
_tag: i,
|
|
18
|
-
add: u,
|
|
19
|
-
remove: p,
|
|
20
|
-
contains: g,
|
|
21
|
-
get size() {
|
|
22
|
-
return v();
|
|
23
|
-
},
|
|
24
|
-
map: f,
|
|
25
|
-
flatMap: d,
|
|
26
|
-
reduce: m,
|
|
27
|
-
reduceRight: M,
|
|
28
|
-
foldLeft: E,
|
|
29
|
-
foldRight: y,
|
|
30
|
-
get: S,
|
|
31
|
-
getOrElse: A,
|
|
32
|
-
get isEmpty() {
|
|
33
|
-
return L();
|
|
34
|
-
},
|
|
35
|
-
orElse: (t, e) => c(s.values.get(t)).orElse(e),
|
|
36
|
-
toList: () => n(o()),
|
|
37
|
-
toSet: () => h(o()),
|
|
38
|
-
toString: () => `Map(${o().toString()})`,
|
|
39
|
-
toValue: () => ({ _tag: "Map", value: s.values })
|
|
40
|
-
};
|
|
41
|
-
}, x = (a) => r(a);
|
|
42
|
-
export {
|
|
43
|
-
l as E,
|
|
44
|
-
x as M
|
|
45
|
-
};
|
|
46
|
-
//# sourceMappingURL=Map-BNxKlujn.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Map-BNxKlujn.mjs","sources":["../src/map/shim.ts","../src/map/Map.ts"],"sourcesContent":["export type IESMap<K, V> = Map<K, V>\nexport const ESMap = Map\n","import type { Collection } from \"@/collections\"\nimport { type Traversable, Typeable } from \"@/index\"\nimport type { IterableType } from \"@/iterable\"\nimport { List } from \"@/list/List\"\nimport { Option } from \"@/option/Option\"\nimport { Set } from \"@/set/Set\"\nimport { Tuple } from \"@/tuple/Tuple\"\nimport { Valuable } from \"@/valuable/Valuable\"\n\nimport { ESMap, type IESMap } from \"./shim\"\n\ntype SafeTraversable<K, V> = Omit<Traversable<Tuple<[K, V]>>, \"map\" | \"flatMap\">\n\nexport type Map<K, V> = {\n add(item: Tuple<[K, V]>): Map<K, V>\n remove(value: K): Map<K, V>\n map<U>(f: (value: V) => U): Map<K, U>\n flatMap<K2, V2>(f: (entry: Tuple<[K, V]>) => IterableType<[K2, V2]>): Map<K2, V2>\n get(key: K): Option<V>\n getOrElse(key: K, defaultValue: V): V\n orElse(key: K, alternative: Option<V>): Option<V>\n} & SafeTraversable<K, V> &\n Collection<Tuple<[K, V]>> &\n Typeable<\"Map\"> &\n Valuable<\"Map\", IESMap<K, V>>\n\ntype MapState<K, V> = {\n values: IESMap<K, V>\n}\n\nconst MapObject = <K, V>(entries?: readonly (readonly [K, V])[] | IterableIterator<[K, V]> | null): Map<K, V> => {\n const _tag = \"Map\"\n const state: MapState<K, V> = {\n values: new ESMap<K, V>(entries),\n }\n\n const getEntries = () => Array.from(state.values.entries()).map(([key, value]) => Tuple<[K, V]>([key, value]))\n\n const add = (item: Tuple<[K, V]>): Map<K, V> =>\n MapObject(new ESMap(state.values).set(item.toArray()[0], item.toArray()[1]).entries())\n\n const remove = (value: K): Map<K, V> => {\n const newMap = new ESMap(state.values)\n return newMap.delete(value) ? MapObject(newMap.entries()) : MapObject(state.values.entries())\n }\n\n const contains = (value: Tuple<[K, V]>): boolean => {\n const tuple = value.toArray()\n return state.values.get(tuple[0]) === tuple[1]\n }\n\n const size = (): number => state.values.size\n\n const map = <U>(f: (value: V) => U): Map<K, U> =>\n MapObject(Array.from(state.values.entries()).map(([k, v]) => [k, f(v)]))\n\n const flatMap = <K2, V2>(f: (entry: Tuple<[K, V]>) => IterableType<[K2, V2]>): Map<K2, V2> => {\n const list = MapObject(state.values.entries()).toList()\n return MapObject(list.flatMap(f).toArray())\n }\n\n const reduce = (f: (acc: Tuple<[K, V]>, value: Tuple<[K, V]>) => Tuple<[K, V]>): Tuple<[K, V]> =>\n List(getEntries()).reduce(f)\n\n const reduceRight = (f: (acc: Tuple<[K, V]>, value: Tuple<[K, V]>) => Tuple<[K, V]>): Tuple<[K, V]> =>\n List(getEntries()).reduceRight(f)\n\n const foldLeft =\n <B>(z: B) =>\n (op: (b: B, a: Tuple<[K, V]>) => B): B =>\n List(getEntries()).foldLeft(z)(op)\n\n const foldRight =\n <B>(z: B) =>\n (op: (a: Tuple<[K, V]>, b: B) => B): B =>\n List(getEntries()).foldRight(z)(op)\n\n const get = (key: K): Option<V> => Option(state.values.get(key))\n\n const getOrElse = (key: K, defaultValue: V): V => Option(state.values.get(key)).getOrElse(defaultValue)\n\n const isEmpty = (): boolean => state.values.size === 0\n\n const orElse = (key: K, alternative: Option<V>): Option<V> => Option(state.values.get(key)).orElse(alternative)\n\n const toList = (): List<Tuple<[K, V]>> => List(getEntries())\n\n const toSet = (): Set<Tuple<[K, V]>> => Set(getEntries())\n\n const toString = (): string => `Map(${getEntries().toString()})`\n\n return {\n _tag,\n add,\n remove,\n contains,\n get size() {\n return size()\n },\n map,\n flatMap,\n reduce,\n reduceRight,\n foldLeft,\n foldRight,\n get,\n getOrElse,\n get isEmpty() {\n return isEmpty()\n },\n orElse,\n toList,\n toSet,\n toString,\n toValue: () => ({ _tag: \"Map\", value: state.values }),\n }\n}\n\nexport const Map = <K, V>(entries?: readonly (readonly [K, V])[] | IterableIterator<[K, V]> | null): Map<K, V> =>\n MapObject(entries)\n\n// Example usage\n// const myMap = createMap<string, unknown>([\n// [\"a\", 1],\n// [\"b\", 2],\n// [\"c\", 3],\n// ])\n"],"names":["ESMap","MapObject","entries","_tag","state","getEntries","key","value","Tuple","add","item","remove","newMap","contains","tuple","size","map","f","k","v","flatMap","list","reduce","List","reduceRight","foldLeft","z","op","foldRight","get","Option","getOrElse","defaultValue","isEmpty","alternative","Set","Map"],"mappings":";;AACO,MAAMA,IAAQ,KC6BfC,IAAY,CAAOC,MAAwF;AAC/G,QAAMC,IAAO,OACPC,IAAwB;AAAA,IAC5B,QAAQ,IAAIJ,EAAYE,CAAO;AAAA,EACjC,GAEMG,IAAa,MAAM,MAAM,KAAKD,EAAM,OAAO,SAAS,EAAE,IAAI,CAAC,CAACE,GAAKC,CAAK,MAAMC,EAAc,CAACF,GAAKC,CAAK,CAAC,CAAC,GAEvGE,IAAM,CAACC,MACXT,EAAU,IAAID,EAAMI,EAAM,MAAM,EAAE,IAAIM,EAAK,QAAU,EAAA,CAAC,GAAGA,EAAK,QAAA,EAAU,CAAC,CAAC,EAAE,SAAS,GAEjFC,IAAS,CAACJ,MAAwB;AACtC,UAAMK,IAAS,IAAIZ,EAAMI,EAAM,MAAM;AACrC,WAAOQ,EAAO,OAAOL,CAAK,IAAIN,EAAUW,EAAO,QAAS,CAAA,IAAIX,EAAUG,EAAM,OAAO,SAAS;AAAA,EAC9F,GAEMS,IAAW,CAACN,MAAkC;AAC5C,UAAAO,IAAQP,EAAM,QAAQ;AACrB,WAAAH,EAAM,OAAO,IAAIU,EAAM,CAAC,CAAC,MAAMA,EAAM,CAAC;AAAA,EAC/C,GAEMC,IAAO,MAAcX,EAAM,OAAO,MAElCY,IAAM,CAAIC,MACdhB,EAAU,MAAM,KAAKG,EAAM,OAAO,QAAS,CAAA,EAAE,IAAI,CAAC,CAACc,GAAGC,CAAC,MAAM,CAACD,GAAGD,EAAEE,CAAC,CAAC,CAAC,CAAC,GAEnEC,IAAU,CAASH,MAAqE;AAC5F,UAAMI,IAAOpB,EAAUG,EAAM,OAAO,QAAQ,CAAC,EAAE,OAAO;AACtD,WAAOH,EAAUoB,EAAK,QAAQJ,CAAC,EAAE,SAAS;AAAA,EAC5C,GAEMK,IAAS,CAACL,MACdM,EAAKlB,GAAY,EAAE,OAAOY,CAAC,GAEvBO,IAAc,CAACP,MACnBM,EAAKlB,GAAY,EAAE,YAAYY,CAAC,GAE5BQ,IACJ,CAAIC,MACJ,CAACC,MACCJ,EAAKlB,EAAW,CAAC,EAAE,SAASqB,CAAC,EAAEC,CAAE,GAE/BC,IACJ,CAAIF,MACJ,CAACC,MACCJ,EAAKlB,EAAW,CAAC,EAAE,UAAUqB,CAAC,EAAEC,CAAE,GAEhCE,IAAM,CAACvB,MAAsBwB,EAAO1B,EAAM,OAAO,IAAIE,CAAG,CAAC,GAEzDyB,IAAY,CAACzB,GAAQ0B,MAAuBF,EAAO1B,EAAM,OAAO,IAAIE,CAAG,CAAC,EAAE,UAAU0B,CAAY,GAEhGC,IAAU,MAAe7B,EAAM,OAAO,SAAS;AAU9C,SAAA;AAAA,IACL,MAAAD;AAAA,IACA,KAAAM;AAAA,IACA,QAAAE;AAAA,IACA,UAAAE;AAAA,IACA,IAAI,OAAO;AACT,aAAOE,EAAK;AAAA,IACd;AAAA,IACA,KAAAC;AAAA,IACA,SAAAI;AAAA,IACA,QAAAE;AAAA,IACA,aAAAE;AAAA,IACA,UAAAC;AAAA,IACA,WAAAG;AAAA,IACA,KAAAC;AAAA,IACA,WAAAE;AAAA,IACA,IAAI,UAAU;AACZ,aAAOE,EAAQ;AAAA,IACjB;AAAA,IACA,QA3Ba,CAAC3B,GAAQ4B,MAAsCJ,EAAO1B,EAAM,OAAO,IAAIE,CAAG,CAAC,EAAE,OAAO4B,CAAW;AAAA,IA4B5G,QA1Ba,MAA2BX,EAAKlB,GAAY;AAAA,IA2BzD,OAzBY,MAA0B8B,EAAI9B,GAAY;AAAA,IA0BtD,UAxBe,MAAc,OAAOA,EAAW,EAAE,SAAU,CAAA;AAAA,IAyB3D,SAAS,OAAO,EAAE,MAAM,OAAO,OAAOD,EAAM,OAAO;AAAA,EACrD;AACF,GAEagC,IAAM,CAAOlC,MACxBD,EAAUC,CAAO;"}
|
package/dist/branded/Brand.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Brand is a utility for creating nominal typing in TypeScript
|
|
3
|
-
* It allows for creating distinct types that are structurally identical
|
|
4
|
-
* but considered different by TypeScript's type system
|
|
5
|
-
*/
|
|
6
|
-
export type Brand<K extends string, T> = T & {
|
|
7
|
-
readonly __brand: K;
|
|
8
|
-
};
|
|
9
|
-
export type Unbrand<T> = T extends Brand<string, infer U> ? U : never;
|
|
10
|
-
export type ExtractBrand<T> = T extends Brand<infer K, unknown> ? K : never;
|
|
11
|
-
/**
|
|
12
|
-
* Helper to create a branded type
|
|
13
|
-
* @param value - The value to brand
|
|
14
|
-
* @returns The branded value
|
|
15
|
-
*/
|
|
16
|
-
export declare function Brand<K extends string, T>(brand: K, value: T): Brand<K, T>;
|
|
17
|
-
/**
|
|
18
|
-
* Helper to remove a brand from a value
|
|
19
|
-
* @param branded - The branded value
|
|
20
|
-
* @returns The original value without the brand
|
|
21
|
-
*/
|
|
22
|
-
export declare function unbrand<T>(branded: Brand<string, T>): T;
|
|
23
|
-
/**
|
|
24
|
-
* Type guard for checking if a value has a specific brand
|
|
25
|
-
* @param value - The value to check
|
|
26
|
-
* @param brand - The brand to check for
|
|
27
|
-
* @returns True if the value has the specified brand
|
|
28
|
-
*
|
|
29
|
-
* Note: Since brands are phantom types that exist only at compile time,
|
|
30
|
-
* this function can only provide a runtime approximation. It always returns true
|
|
31
|
-
* for non-null values, as we have no way to actually check the brand at runtime.
|
|
32
|
-
* This function is primarily for API consistency and documentation purposes.
|
|
33
|
-
*/
|
|
34
|
-
export declare function hasBrand<K extends string, T>(value: unknown, brand: K): value is Brand<K, T>;
|
|
35
|
-
/**
|
|
36
|
-
* Create a branded type constructor for a specific brand
|
|
37
|
-
* @param brand - The brand name
|
|
38
|
-
* @returns A function that brands values with the specified brand
|
|
39
|
-
*/
|
|
40
|
-
export declare function createBrander<K extends string, T>(brand: K): (value: T) => Brand<K, T>;
|
|
41
|
-
export type BrandedString<K extends string> = Brand<K, string>;
|
|
42
|
-
export type BrandedNumber<K extends string> = Brand<K, number>;
|
|
43
|
-
export type BrandedBoolean<K extends string> = Brand<K, boolean>;
|
|
44
|
-
export declare const BrandedString: <K extends string>(brand: K) => (value: string) => BrandedString<K>;
|
|
45
|
-
export declare const BrandedNumber: <K extends string>(brand: K) => (value: number) => BrandedNumber<K>;
|
|
46
|
-
export declare const BrandedBoolean: <K extends string>(brand: K) => (value: boolean) => BrandedBoolean<K>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a function-object hybrid similar to Scala's companion objects.
|
|
3
|
-
* This utility allows creating TypeScript function objects with attached methods,
|
|
4
|
-
* mimicking Scala's class + companion object pattern without using classes.
|
|
5
|
-
*
|
|
6
|
-
* @param object The main function that will be invoked when the object is called
|
|
7
|
-
* @param companion Additional static methods to attach to the function
|
|
8
|
-
* @returns A function with the attached methods
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* const greet = (name: string) => `Hello, ${name}!`;
|
|
12
|
-
* const methods = {
|
|
13
|
-
* formal: (name: string) => `Good day, ${name}.`,
|
|
14
|
-
* casual: (name: string) => `Hey ${name}!`
|
|
15
|
-
* };
|
|
16
|
-
* const Greeter = createCompanionObject(greet, methods);
|
|
17
|
-
*
|
|
18
|
-
* // Usage:
|
|
19
|
-
* Greeter("World"); // Hello, World!
|
|
20
|
-
* Greeter.formal("Sir"); // Good day, Sir.
|
|
21
|
-
* Greeter.casual("Friend"); // Hey Friend!
|
|
22
|
-
*/
|
|
23
|
-
export declare function Companion<ObjectF extends object, CompanionF extends object>(object: ObjectF, companion: CompanionF): ObjectF & CompanionF;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Companion';
|
package/dist/core/base/Base.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Base';
|
package/dist/core/index.d.ts
DELETED
package/dist/core/info/Info.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Identity } from '../../identity/Identity';
|
|
2
|
-
type Params = {
|
|
3
|
-
id: string;
|
|
4
|
-
description: string;
|
|
5
|
-
location: string;
|
|
6
|
-
reason: string;
|
|
7
|
-
means: string;
|
|
8
|
-
} & Identity<string>;
|
|
9
|
-
/**
|
|
10
|
-
* Base Object from which most other objects inherit
|
|
11
|
-
* @param type
|
|
12
|
-
* @param body
|
|
13
|
-
* @param params
|
|
14
|
-
* @constructor
|
|
15
|
-
*/
|
|
16
|
-
export declare function Info<T>(type: string, body: T, params: Params): T & {
|
|
17
|
-
toString(): string;
|
|
18
|
-
_tag: string;
|
|
19
|
-
} & {
|
|
20
|
-
id: string;
|
|
21
|
-
description: string;
|
|
22
|
-
location: string;
|
|
23
|
-
reason: string;
|
|
24
|
-
means: string;
|
|
25
|
-
} & Identity<string>;
|
|
26
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Info';
|
package/dist/core/task/Task.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { Throwable } from '../throwable/Throwable';
|
|
2
|
-
import { Either } from '../../either/Either';
|
|
3
|
-
import { FPromise } from '../../fpromise/FPromise';
|
|
4
|
-
export type TaskParams = {
|
|
5
|
-
name?: string;
|
|
6
|
-
description?: string;
|
|
7
|
-
};
|
|
8
|
-
export type TaskInfo = {
|
|
9
|
-
_task: TaskParams;
|
|
10
|
-
};
|
|
11
|
-
export type TaskException<T> = Either<Throwable, T> & TaskInfo;
|
|
12
|
-
/**
|
|
13
|
-
* TaskException factory function
|
|
14
|
-
* @param error
|
|
15
|
-
* @param _task
|
|
16
|
-
* @param data
|
|
17
|
-
* @constructor
|
|
18
|
-
*/
|
|
19
|
-
export declare const TaskException: <T>(error: unknown, data?: unknown, _task?: TaskParams) => TaskException<T>;
|
|
20
|
-
export type TaskResult<T> = Either<Throwable, T> & TaskInfo;
|
|
21
|
-
export declare const TaskResult: <T>(data: T, _task?: TaskParams) => TaskResult<T>;
|
|
22
|
-
export type Sync<T> = Either<Throwable, T>;
|
|
23
|
-
export type Async<T> = FPromise<Sync<T>>;
|
|
24
|
-
/**
|
|
25
|
-
* Task adapter for bridging promise-based code with functional error handling patterns
|
|
26
|
-
*/
|
|
27
|
-
export declare const Task: <T = unknown>(params?: TaskParams) => {
|
|
28
|
-
_type: string;
|
|
29
|
-
/**
|
|
30
|
-
* Run an async operation with explicit try/catch/finally semantics
|
|
31
|
-
* Returns a raw Promise that can interact with traditional Promise-based code
|
|
32
|
-
*/
|
|
33
|
-
Async: <U = T>(t: () => U | Promise<U>, e?: (error: unknown) => unknown, f?: () => Promise<void> | void) => FPromise<U>;
|
|
34
|
-
/**
|
|
35
|
-
* Run a synchronous operation with explicit try/catch/finally semantics
|
|
36
|
-
* Returns an Either for functional error handling
|
|
37
|
-
*/
|
|
38
|
-
Sync: <U = T>(t: () => U, e?: (error: unknown) => unknown, f?: () => void) => Sync<U>;
|
|
39
|
-
/**
|
|
40
|
-
* Create a successful Task result
|
|
41
|
-
*/
|
|
42
|
-
success: (data: T) => TaskResult<T>;
|
|
43
|
-
/**
|
|
44
|
-
* Create a failed Task result
|
|
45
|
-
*/
|
|
46
|
-
fail: (error: unknown) => TaskException<T>;
|
|
47
|
-
/**
|
|
48
|
-
* Convert a Promise-returning function to a Task-compatible function
|
|
49
|
-
*/
|
|
50
|
-
fromPromise: <U, Args extends unknown[]>(promiseFn: (...args: Args) => Promise<U>) => ((...args: Args) => FPromise<U>);
|
|
51
|
-
/**
|
|
52
|
-
* Convert a Task result to a Promise
|
|
53
|
-
*/
|
|
54
|
-
toPromise: <U>(taskResult: TaskResult<U> | TaskException<U>) => Promise<U>;
|
|
55
|
-
toString(): string;
|
|
56
|
-
_tag: string;
|
|
57
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Task';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Typeable } from '../../typeable/Typeable';
|
|
2
|
-
declare const NAME: "Throwable";
|
|
3
|
-
export type ThrowableType = Error & Typeable<typeof NAME> & {
|
|
4
|
-
readonly data?: unknown;
|
|
5
|
-
readonly cause?: Error;
|
|
6
|
-
};
|
|
7
|
-
export declare class Throwable extends Error implements ThrowableType {
|
|
8
|
-
readonly _tag: typeof NAME;
|
|
9
|
-
readonly data?: unknown;
|
|
10
|
-
readonly cause?: Error;
|
|
11
|
-
protected constructor(message: string, options?: {
|
|
12
|
-
data?: unknown | undefined;
|
|
13
|
-
cause?: Error | undefined;
|
|
14
|
-
stack?: string | undefined;
|
|
15
|
-
});
|
|
16
|
-
static apply(srcError: unknown, data?: unknown): ThrowableType;
|
|
17
|
-
}
|
|
18
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Throwable';
|
package/dist/either/Either.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { AsyncFunctor, Functor, Type } from '../functor';
|
|
2
|
-
import { List } from '../list/List';
|
|
3
|
-
import { Option } from '../option/Option';
|
|
4
|
-
import { Typeable } from '../typeable/Typeable';
|
|
5
|
-
import { Valuable } from '../valuable/Valuable';
|
|
6
|
-
/**
|
|
7
|
-
* Either type module
|
|
8
|
-
* @module Either
|
|
9
|
-
* @category Core
|
|
10
|
-
*/
|
|
11
|
-
export type Either<L extends Type, R extends Type> = {
|
|
12
|
-
readonly _tag: "Left" | "Right";
|
|
13
|
-
value: L | R;
|
|
14
|
-
isLeft: () => boolean;
|
|
15
|
-
isRight: () => boolean;
|
|
16
|
-
getOrElse: (defaultValue: R) => R;
|
|
17
|
-
getOrThrow: () => R;
|
|
18
|
-
map: <U extends Type>(f: (value: R) => U) => Either<L, U>;
|
|
19
|
-
merge: <L1 extends Type, R1 extends Type>(other: Either<L1, R1>) => Either<L | L1, [R, R1]>;
|
|
20
|
-
mapAsync: <U extends Type>(f: (value: R) => Promise<U>) => Promise<Either<L, U>>;
|
|
21
|
-
flatMap: <U extends Type>(f: (value: R) => Either<L, U>) => Either<L, U>;
|
|
22
|
-
flatMapAsync: <U extends Type>(f: (value: R) => Promise<Either<L, U>>) => Promise<Either<L, U>>;
|
|
23
|
-
toOption: () => Option<R>;
|
|
24
|
-
toList: () => List<R>;
|
|
25
|
-
toString: () => string;
|
|
26
|
-
[Symbol.iterator]: () => Iterator<R>;
|
|
27
|
-
yield: () => Generator<R, void, unknown>;
|
|
28
|
-
traverse: <U extends Type>(f: (value: R) => Either<L, U>) => Either<L, U[]>;
|
|
29
|
-
lazyMap: <U extends Type>(f: (value: R) => U) => Generator<Either<L, U>, void, unknown>;
|
|
30
|
-
tap: (f: (value: R) => void) => Either<L, R>;
|
|
31
|
-
tapLeft: (f: (value: L) => void) => Either<L, R>;
|
|
32
|
-
mapLeft: <L2 extends Type>(f: (value: L) => L2) => Either<L2, R>;
|
|
33
|
-
bimap: <L2 extends Type, R2 extends Type>(fl: (value: L) => L2, fr: (value: R) => R2) => Either<L2, R2>;
|
|
34
|
-
fold: <T extends Type>(onLeft: (value: L) => T, onRight: (value: R) => T) => T;
|
|
35
|
-
swap: () => Either<R, L>;
|
|
36
|
-
} & Typeable<"Left" | "Right"> & Valuable<"Left" | "Right", L | R> & PromiseLike<R> & AsyncFunctor<R>;
|
|
37
|
-
export type TestEither<L extends Type, R extends Type> = Either<L, R> & Functor<R> & AsyncFunctor<R>;
|
|
38
|
-
export declare const Right: <L extends Type, R extends Type>(value: R) => Either<L, R>;
|
|
39
|
-
export declare const Left: <L extends Type, R extends Type>(value: L) => Either<L, R>;
|
|
40
|
-
export declare const isRight: <L extends Type, R extends Type>(either: Either<L, R>) => either is Either<L, R> & {
|
|
41
|
-
value: R;
|
|
42
|
-
};
|
|
43
|
-
export declare const isLeft: <L extends Type, R extends Type>(either: Either<L, R>) => either is Either<L, R> & {
|
|
44
|
-
value: L;
|
|
45
|
-
};
|
|
46
|
-
export declare const tryCatch: <L extends Type, R extends Type>(f: () => R, onError: (error: unknown) => L) => Either<L, R>;
|
|
47
|
-
export declare const TypeCheckRight: <L extends Type, R extends Type>(value: R) => TestEither<L, R>;
|
|
48
|
-
export declare const TypeCheckLeft: <L extends Type, R extends Type>(value: L) => TestEither<L, R>;
|
|
49
|
-
export declare const tryCatchAsync: <L extends Type, R extends Type>(f: () => Promise<R>, onError: (error: unknown) => L) => Promise<Either<L, R>>;
|
|
50
|
-
export declare const Either: {
|
|
51
|
-
sequence: <L extends Type, R extends Type>(eithers: Either<L, R>[]) => Either<L, R[]>;
|
|
52
|
-
traverse: <L extends Type, R extends Type, U extends Type>(arr: R[], f: (value: R) => Either<L, U>) => Either<L, U[]>;
|
|
53
|
-
fromNullable: <L extends Type, R extends Type>(value: R | null | undefined, leftValue: L) => Either<L, R>;
|
|
54
|
-
fromPredicate: <L extends Type, R extends Type>(value: R, predicate: (value: R) => boolean, leftValue: L) => Either<L, R>;
|
|
55
|
-
ap: <L extends Type, R extends Type, U extends Type>(eitherF: Either<L, (value: R) => U>, eitherV: Either<L, R>) => Either<L, U>;
|
|
56
|
-
fromPromise: <L, R>(promise: Promise<R>, onRejected: (reason: unknown) => L) => Promise<Either<L, R>>;
|
|
57
|
-
};
|
package/dist/error/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './ParseError';
|