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.
Files changed (81) hide show
  1. package/dist/Tuple-DfdXAbL_.d.ts +52 -0
  2. package/dist/branded/index.d.ts +48 -1
  3. package/dist/branded/index.mjs +2 -23
  4. package/dist/branded/index.mjs.map +1 -1
  5. package/dist/chunk-3DIRMZSK.mjs +2 -0
  6. package/dist/chunk-3DIRMZSK.mjs.map +1 -0
  7. package/dist/chunk-PXFJPCM7.mjs +2 -0
  8. package/dist/chunk-PXFJPCM7.mjs.map +1 -0
  9. package/dist/chunk-TQJDL6YW.mjs +2 -0
  10. package/dist/chunk-TQJDL6YW.mjs.map +1 -0
  11. package/dist/either/index.d.ts +3 -1
  12. package/dist/either/index.mjs +2 -13
  13. package/dist/either/index.mjs.map +1 -1
  14. package/dist/fpromise/index.d.ts +3 -2
  15. package/dist/fpromise/index.mjs +2 -6
  16. package/dist/fpromise/index.mjs.map +1 -1
  17. package/dist/index.d.ts +3 -28
  18. package/dist/index.mjs +2 -174
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/list/index.d.ts +3 -1
  21. package/dist/list/index.mjs +2 -5
  22. package/dist/list/index.mjs.map +1 -1
  23. package/dist/map/index.d.ts +3 -2
  24. package/dist/map/index.mjs +2 -7
  25. package/dist/map/index.mjs.map +1 -1
  26. package/dist/option/index.d.ts +870 -1
  27. package/dist/option/index.mjs +2 -7
  28. package/dist/option/index.mjs.map +1 -1
  29. package/dist/set/index.d.ts +3 -2
  30. package/dist/set/index.mjs +2 -5
  31. package/dist/set/index.mjs.map +1 -1
  32. package/dist/try/index.d.ts +3 -1
  33. package/dist/try/index.mjs +2 -44
  34. package/dist/try/index.mjs.map +1 -1
  35. package/dist/tuple/index.d.ts +1 -1
  36. package/dist/tuple/index.mjs +2 -27
  37. package/dist/tuple/index.mjs.map +1 -1
  38. package/package.json +6 -7
  39. package/dist/Map-BNxKlujn.mjs +0 -46
  40. package/dist/Map-BNxKlujn.mjs.map +0 -1
  41. package/dist/branded/Brand.d.ts +0 -46
  42. package/dist/collections/index.d.ts +0 -8
  43. package/dist/companion/Companion.d.ts +0 -23
  44. package/dist/companion/index.d.ts +0 -1
  45. package/dist/core/base/Base.d.ts +0 -10
  46. package/dist/core/base/index.d.ts +0 -1
  47. package/dist/core/index.d.ts +0 -4
  48. package/dist/core/info/Info.d.ts +0 -26
  49. package/dist/core/info/index.d.ts +0 -1
  50. package/dist/core/task/Task.d.ts +0 -57
  51. package/dist/core/task/index.d.ts +0 -1
  52. package/dist/core/throwable/Throwable.d.ts +0 -18
  53. package/dist/core/throwable/index.d.ts +0 -1
  54. package/dist/either/Either.d.ts +0 -57
  55. package/dist/error/ParseError.d.ts +0 -6
  56. package/dist/error/index.d.ts +0 -1
  57. package/dist/fpromise/FPromise.d.ts +0 -369
  58. package/dist/fpromise/retry.d.ts +0 -106
  59. package/dist/functor/index.d.ts +0 -18
  60. package/dist/hkt/index.d.ts +0 -49
  61. package/dist/identity/Identity.d.ts +0 -5
  62. package/dist/identity/index.d.ts +0 -1
  63. package/dist/index-CgMYHgdG.mjs +0 -1286
  64. package/dist/index-CgMYHgdG.mjs.map +0 -1
  65. package/dist/iterable/index.d.ts +0 -25
  66. package/dist/list/List.d.ts +0 -45
  67. package/dist/map/Map.d.ts +0 -19
  68. package/dist/map/shim.d.ts +0 -2
  69. package/dist/option/Option.d.ts +0 -164
  70. package/dist/serializable/Serializable.d.ts +0 -15
  71. package/dist/serializable/index.d.ts +0 -1
  72. package/dist/set/Set.d.ts +0 -16
  73. package/dist/set/shim.d.ts +0 -2
  74. package/dist/try/Try.d.ts +0 -20
  75. package/dist/tuple/Tuple.d.ts +0 -11
  76. package/dist/typeable/Typeable.d.ts +0 -10
  77. package/dist/typeable/index.d.ts +0 -1
  78. package/dist/util/index.d.ts +0 -3
  79. package/dist/util/isIterable.d.ts +0 -1
  80. package/dist/valuable/Valuable.d.ts +0 -13
  81. package/dist/valuable/index.d.ts +0 -1
@@ -1,7 +1,2 @@
1
- import { N as e, O as s, S as m } from "../index-CgMYHgdG.mjs";
2
- export {
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,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
@@ -1,2 +1,3 @@
1
- export * from './Set';
2
- export * from './shim';
1
+ export { S as Set } from '../option/index.js';
2
+ import '../Tuple-DfdXAbL_.js';
3
+ import '../branded/index.js';
@@ -1,5 +1,2 @@
1
- import { f as o } from "../index-CgMYHgdG.mjs";
2
- export {
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
@@ -1 +1,3 @@
1
- export * from './Try';
1
+ export { h as Try } from '../option/index.js';
2
+ import '../Tuple-DfdXAbL_.js';
3
+ import '../branded/index.js';
@@ -1,44 +1,2 @@
1
- import { k as e, R as o, L as i } from "../index-CgMYHgdG.mjs";
2
- const a = (t) => ({
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/try/Try.ts"],"sourcesContent":["import stringify from \"safe-stable-stringify\"\n\nimport { Either, Left, Right } from \"@/either/Either\"\nimport { Typeable } from \"@/typeable/Typeable\"\nimport { Valuable } from \"@/valuable/Valuable\"\n\ntype TypeNames = \"Success\" | \"Failure\"\n\nexport type Try<T> = {\n readonly _tag: TypeNames\n readonly error: Error | undefined\n isSuccess: () => boolean\n isFailure: () => boolean\n get: () => T\n getOrElse: (defaultValue: T) => T\n orElse: (alternative: Try<T>) => Try<T>\n orThrow: (error: Error) => T\n toEither: () => Either<Error, T>\n map: <U>(f: (value: T) => U) => Try<U>\n flatMap: <U>(f: (value: T) => Try<U>) => Try<U>\n toString: () => string\n} & Typeable<TypeNames> &\n Valuable<TypeNames, T | Error>\n\nconst Success = <T>(value: T): Try<T> => ({\n _tag: \"Success\",\n error: undefined,\n isSuccess: () => true,\n isFailure: () => false,\n get: () => value,\n getOrElse: (_defaultValue: T) => value,\n orElse: (_alternative: Try<T>) => Success(value),\n orThrow: (_error: Error) => value,\n toEither: () => Right<Error, T>(value),\n map: <U>(f: (value: T) => U) => Try(() => f(value)),\n flatMap: <U>(f: (value: T) => Try<U>) => f(value),\n toString: () => `Success(${stringify(value)})`,\n toValue: () => ({ _tag: \"Success\", value }),\n})\n\nconst Failure = <T>(error: Error): Try<T> => ({\n _tag: \"Failure\",\n error,\n isSuccess: () => false,\n isFailure: () => true,\n get: () => {\n throw error\n },\n getOrElse: (defaultValue: T) => defaultValue,\n orElse: (alternative: Try<T>) => alternative,\n orThrow: (error: Error) => {\n throw error\n },\n toEither: () => Left<Error, T>(error),\n map: <U>(_f: (value: T) => U) => Failure<U>(error),\n flatMap: <U>(_f: (value: T) => Try<U>) => Failure<U>(error),\n toString: () => `Failure(${stringify(error)}))`,\n toValue: () => ({ _tag: \"Failure\", value: error }),\n})\n\nexport const Try = <T>(f: () => T): Try<T> => {\n try {\n return Success(f())\n } catch (error) {\n return Failure(error instanceof Error ? error : new Error(String(error)))\n }\n}\n"],"names":["Success","value","_defaultValue","_alternative","_error","Right","f","Try","stringify","Failure","error","defaultValue","alternative","Left","_f"],"mappings":";AAwBA,MAAMA,IAAU,CAAIC,OAAsB;AAAA,EACxC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,WAAW,MAAM;AAAA,EACjB,WAAW,MAAM;AAAA,EACjB,KAAK,MAAMA;AAAA,EACX,WAAW,CAACC,MAAqBD;AAAA,EACjC,QAAQ,CAACE,MAAyBH,EAAQC,CAAK;AAAA,EAC/C,SAAS,CAACG,MAAkBH;AAAA,EAC5B,UAAU,MAAMI,EAAgBJ,CAAK;AAAA,EACrC,KAAK,CAAIK,MAAuBC,EAAI,MAAMD,EAAEL,CAAK,CAAC;AAAA,EAClD,SAAS,CAAIK,MAA4BA,EAAEL,CAAK;AAAA,EAChD,UAAU,MAAM,WAAWO,EAAUP,CAAK,CAAC;AAAA,EAC3C,SAAS,OAAO,EAAE,MAAM,WAAW,OAAAA,EAAM;AAC3C,IAEMQ,IAAU,CAAIC,OAA0B;AAAA,EAC5C,MAAM;AAAA,EACN,OAAAA;AAAA,EACA,WAAW,MAAM;AAAA,EACjB,WAAW,MAAM;AAAA,EACjB,KAAK,MAAM;AACH,UAAAA;AAAA,EACR;AAAA,EACA,WAAW,CAACC,MAAoBA;AAAA,EAChC,QAAQ,CAACC,MAAwBA;AAAA,EACjC,SAAS,CAACF,MAAiB;AACnBA,UAAAA;AAAAA,EACR;AAAA,EACA,UAAU,MAAMG,EAAeH,CAAK;AAAA,EACpC,KAAK,CAAII,MAAwBL,EAAWC,CAAK;AAAA,EACjD,SAAS,CAAII,MAA6BL,EAAWC,CAAK;AAAA,EAC1D,UAAU,MAAM,WAAWF,EAAUE,CAAK,CAAC;AAAA,EAC3C,SAAS,OAAO,EAAE,MAAM,WAAW,OAAOA,EAAM;AAClD,IAEaH,IAAM,CAAID,MAAuB;AACxC,MAAA;AACK,WAAAN,EAAQM,GAAG;AAAA,WACXI,GAAO;AACP,WAAAD,EAAQC,aAAiB,QAAQA,IAAQ,IAAI,MAAM,OAAOA,CAAK,CAAC,CAAC;AAAA,EAAA;AAE5E;"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
@@ -1 +1 @@
1
- export * from './Tuple';
1
+ export { b as Tuple } from '../Tuple-DfdXAbL_.js';
@@ -1,27 +1,2 @@
1
- const n = (t) => ({
2
- _tag: "Tuple",
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/tuple/Tuple.ts"],"sourcesContent":["import type { ArrayFunctor, ArrayType } from \"@/functor\"\nimport { Typeable } from \"@/typeable/Typeable\"\nimport { Valuable } from \"@/valuable/Valuable\"\n\nexport type Tuple<T extends ArrayType> = {\n get<K extends number>(index: K): T[K]\n\n map<U extends ArrayType>(f: (value: T) => U): Tuple<U>\n\n flatMap<U extends ArrayType>(f: (value: T) => Tuple<U>): Tuple<U>\n\n toArray(): T\n\n [Symbol.iterator](): Iterator<T[number]>\n} & ArrayFunctor<T> &\n Typeable<\"Tuple\"> &\n Valuable<\"Tuple\", T>\n\nexport const Tuple = <T extends ArrayType>(values: T): Tuple<T> => {\n return {\n _tag: \"Tuple\",\n map: <U extends ArrayType>(f: (value: T) => U): Tuple<U> => {\n const mapValue = f(values)\n return Tuple(mapValue)\n },\n\n flatMap: <U extends ArrayType>(f: (value: T) => Tuple<U>): Tuple<U> => {\n return f(values)\n },\n\n get: <K extends number>(index: K): T[K] => {\n return values[index]\n },\n\n toArray: (): T => {\n return values\n },\n [Symbol.iterator](): Iterator<T[number]> {\n let index = 0\n return {\n next: (): IteratorResult<T[number]> => {\n if (index < values.length) {\n return {\n value: values[index++],\n done: false,\n }\n } else {\n return {\n value: undefined,\n done: true,\n }\n }\n },\n }\n },\n toValue: () => ({ _tag: \"Tuple\", value: values }),\n }\n}\n"],"names":["Tuple","values","f","mapValue","index"],"mappings":"AAkBa,MAAAA,IAAQ,CAAsBC,OAClC;AAAA,EACL,MAAM;AAAA,EACN,KAAK,CAAsBC,MAAiC;AACpD,UAAAC,IAAWD,EAAED,CAAM;AACzB,WAAOD,EAAMG,CAAQ;AAAA,EACvB;AAAA,EAEA,SAAS,CAAsBD,MACtBA,EAAED,CAAM;AAAA,EAGjB,KAAK,CAAmBG,MACfH,EAAOG,CAAK;AAAA,EAGrB,SAAS,MACAH;AAAA,EAET,CAAC,OAAO,QAAQ,IAAyB;AACvC,QAAIG,IAAQ;AACL,WAAA;AAAA,MACL,MAAM,MACAA,IAAQH,EAAO,SACV;AAAA,QACL,OAAOA,EAAOG,GAAO;AAAA,QACrB,MAAM;AAAA,MACR,IAEO;AAAA,QACL,OAAO;AAAA,QACP,MAAM;AAAA,MACR;AAAA,IAGN;AAAA,EACF;AAAA,EACA,SAAS,OAAO,EAAE,MAAM,SAAS,OAAOH,EAAO;AACjD;"}
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.62",
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": "vite build --watch --mode development",
121
- "build:prod": "pnpm compile && pnpm test && vite build --mode production",
122
- "build:watch": "vite 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}\" ",
@@ -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;"}
@@ -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,8 +0,0 @@
1
- import { List } from '../list/List';
2
- import { Set } from '../set/Set';
3
- export type Converters<A> = {
4
- toList(): List<A>;
5
- toSet(): Set<A>;
6
- toString(): string;
7
- };
8
- export type Collection<A> = Converters<A>;
@@ -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';
@@ -1,10 +0,0 @@
1
- /**
2
- * Base Object from which most other objects inherit
3
- * @param type
4
- * @param body
5
- * @constructor
6
- */
7
- export declare function Base<T>(type: string, body: T): T & {
8
- toString(): string;
9
- _tag: string;
10
- };
@@ -1 +0,0 @@
1
- export * from './Base';
@@ -1,4 +0,0 @@
1
- export * from './base';
2
- export * from './info';
3
- export * from './task';
4
- export * from './throwable';
@@ -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';
@@ -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';
@@ -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
- };
@@ -1,6 +0,0 @@
1
- export declare const ParseError: (message?: string) => Error & {
2
- name: "ParseError";
3
- };
4
- export type ParseError = Error & {
5
- name: "ParseError";
6
- };
@@ -1 +0,0 @@
1
- export * from './ParseError';