functype 0.8.61 → 0.8.62

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/Map-BNxKlujn.mjs +46 -0
  2. package/dist/Map-BNxKlujn.mjs.map +1 -0
  3. package/dist/branded/Brand.d.ts +46 -0
  4. package/dist/branded/index.d.ts +1 -48
  5. package/dist/branded/index.mjs +23 -2
  6. package/dist/branded/index.mjs.map +1 -1
  7. package/dist/collections/index.d.ts +8 -0
  8. package/dist/companion/Companion.d.ts +23 -0
  9. package/dist/companion/index.d.ts +1 -0
  10. package/dist/core/base/Base.d.ts +10 -0
  11. package/dist/core/base/index.d.ts +1 -0
  12. package/dist/core/index.d.ts +4 -0
  13. package/dist/core/info/Info.d.ts +26 -0
  14. package/dist/core/info/index.d.ts +1 -0
  15. package/dist/core/task/Task.d.ts +57 -0
  16. package/dist/core/task/index.d.ts +1 -0
  17. package/dist/core/throwable/Throwable.d.ts +18 -0
  18. package/dist/core/throwable/index.d.ts +1 -0
  19. package/dist/either/Either.d.ts +57 -0
  20. package/dist/either/index.d.ts +1 -3
  21. package/dist/either/index.mjs +13 -2
  22. package/dist/either/index.mjs.map +1 -1
  23. package/dist/error/ParseError.d.ts +6 -0
  24. package/dist/error/index.d.ts +1 -0
  25. package/dist/fpromise/FPromise.d.ts +369 -0
  26. package/dist/fpromise/index.d.ts +2 -3
  27. package/dist/fpromise/index.mjs +6 -2
  28. package/dist/fpromise/index.mjs.map +1 -1
  29. package/dist/fpromise/retry.d.ts +106 -0
  30. package/dist/functor/index.d.ts +18 -0
  31. package/dist/hkt/index.d.ts +49 -0
  32. package/dist/identity/Identity.d.ts +5 -0
  33. package/dist/identity/index.d.ts +1 -0
  34. package/dist/index-CgMYHgdG.mjs +1286 -0
  35. package/dist/index-CgMYHgdG.mjs.map +1 -0
  36. package/dist/index.d.ts +28 -3
  37. package/dist/index.mjs +174 -2
  38. package/dist/index.mjs.map +1 -1
  39. package/dist/iterable/index.d.ts +25 -0
  40. package/dist/list/List.d.ts +45 -0
  41. package/dist/list/index.d.ts +1 -3
  42. package/dist/list/index.mjs +5 -2
  43. package/dist/list/index.mjs.map +1 -1
  44. package/dist/map/Map.d.ts +19 -0
  45. package/dist/map/index.d.ts +2 -3
  46. package/dist/map/index.mjs +7 -2
  47. package/dist/map/index.mjs.map +1 -1
  48. package/dist/map/shim.d.ts +2 -0
  49. package/dist/option/Option.d.ts +164 -0
  50. package/dist/option/index.d.ts +1 -870
  51. package/dist/option/index.mjs +7 -2
  52. package/dist/option/index.mjs.map +1 -1
  53. package/dist/serializable/Serializable.d.ts +15 -0
  54. package/dist/serializable/index.d.ts +1 -0
  55. package/dist/set/Set.d.ts +16 -0
  56. package/dist/set/index.d.ts +2 -3
  57. package/dist/set/index.mjs +5 -2
  58. package/dist/set/index.mjs.map +1 -1
  59. package/dist/set/shim.d.ts +2 -0
  60. package/dist/try/Try.d.ts +20 -0
  61. package/dist/try/index.d.ts +1 -3
  62. package/dist/try/index.mjs +44 -2
  63. package/dist/try/index.mjs.map +1 -1
  64. package/dist/tuple/Tuple.d.ts +11 -0
  65. package/dist/tuple/index.d.ts +1 -1
  66. package/dist/tuple/index.mjs +27 -2
  67. package/dist/tuple/index.mjs.map +1 -1
  68. package/dist/typeable/Typeable.d.ts +10 -0
  69. package/dist/typeable/index.d.ts +1 -0
  70. package/dist/util/index.d.ts +3 -0
  71. package/dist/util/isIterable.d.ts +1 -0
  72. package/dist/valuable/Valuable.d.ts +13 -0
  73. package/dist/valuable/index.d.ts +1 -0
  74. package/package.json +7 -6
  75. package/dist/Tuple-GXgoHfiN.d.ts +0 -54
  76. package/dist/chunk-A3EHNBZM.mjs +0 -2
  77. package/dist/chunk-A3EHNBZM.mjs.map +0 -1
  78. package/dist/chunk-OQWAJKZJ.mjs +0 -2
  79. package/dist/chunk-OQWAJKZJ.mjs.map +0 -1
  80. package/dist/chunk-TQJDL6YW.mjs +0 -2
  81. package/dist/chunk-TQJDL6YW.mjs.map +0 -1
@@ -0,0 +1,46 @@
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
@@ -0,0 +1 @@
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;"}
@@ -0,0 +1,46 @@
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,48 +1 @@
1
- type Unbrand<T> = T extends Brand<string, infer U> ? U : never;
2
- type ExtractBrand<T> = T extends Brand<infer K, unknown> ? K : never;
3
- /**
4
- * Brand is a utility for creating nominal typing in TypeScript
5
- * It allows for creating distinct types that are structurally identical
6
- * but considered different by TypeScript's type system
7
- */
8
- type Brand<K extends string, T> = T & {
9
- readonly __brand: K;
10
- };
11
- /**
12
- * Helper to create a branded type
13
- * @param value - The value to brand
14
- * @returns The branded value
15
- */
16
- 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
- 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
- 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
- declare function createBrander<K extends string, T>(brand: K): (value: T) => Brand<K, T>;
41
- type BrandedString<K extends string> = Brand<K, string>;
42
- declare const BrandedString: <K extends string>(brand: K) => (value: string) => BrandedString<K>;
43
- type BrandedNumber<K extends string> = Brand<K, number>;
44
- declare const BrandedNumber: <K extends string>(brand: K) => (value: number) => BrandedNumber<K>;
45
- type BrandedBoolean<K extends string> = Brand<K, boolean>;
46
- declare const BrandedBoolean: <K extends string>(brand: K) => (value: boolean) => BrandedBoolean<K>;
47
-
48
- export { Brand, BrandedBoolean, BrandedNumber, BrandedString, type ExtractBrand, type Unbrand, createBrander, hasBrand, unbrand };
1
+ export * from './Brand';
@@ -1,2 +1,23 @@
1
- export{a as Brand,g as BrandedBoolean,f as BrandedNumber,e as BrandedString,d as createBrander,c as hasBrand,b as unbrand}from'../chunk-TQJDL6YW.mjs';//# sourceMappingURL=index.mjs.map
2
- //# sourceMappingURL=index.mjs.map
1
+ function t(n, r) {
2
+ return r;
3
+ }
4
+ function d(n) {
5
+ return n;
6
+ }
7
+ function e(n, r) {
8
+ return n != null;
9
+ }
10
+ function a(n) {
11
+ return (r) => t(n, r);
12
+ }
13
+ const o = (n) => (r) => t(n, r), u = (n) => (r) => t(n, r), c = (n) => (r) => t(n, r);
14
+ export {
15
+ t as Brand,
16
+ c as BrandedBoolean,
17
+ u as BrandedNumber,
18
+ o as BrandedString,
19
+ a as createBrander,
20
+ e as hasBrand,
21
+ d as unbrand
22
+ };
23
+ //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/branded/Brand.ts"],"sourcesContent":["/**\n * Brand is a utility for creating nominal typing in TypeScript\n * It allows for creating distinct types that are structurally identical\n * but considered different by TypeScript's type system\n */\n\n// The brand symbol type\nexport type Brand<K extends string, T> = T & { readonly __brand: K }\n\n// Utility type to extract the underlying type from a branded type\nexport type Unbrand<T> = T extends Brand<string, infer U> ? U : never\n\n// Utility type to extract the brand from a branded type\nexport type ExtractBrand<T> = T extends Brand<infer K, unknown> ? K : never\n\n/**\n * Helper to create a branded type\n * @param value - The value to brand\n * @returns The branded value\n */\nexport function Brand<K extends string, T>(brand: K, value: T): Brand<K, T> {\n return value as Brand<K, T>\n}\n\n/**\n * Helper to remove a brand from a value\n * @param branded - The branded value\n * @returns The original value without the brand\n */\nexport function unbrand<T>(branded: Brand<string, T>): T {\n return branded as T\n}\n\n/**\n * Type guard for checking if a value has a specific brand\n * @param value - The value to check\n * @param brand - The brand to check for\n * @returns True if the value has the specified brand\n *\n * Note: Since brands are phantom types that exist only at compile time,\n * this function can only provide a runtime approximation. It always returns true\n * for non-null values, as we have no way to actually check the brand at runtime.\n * This function is primarily for API consistency and documentation purposes.\n */\nexport function hasBrand<K extends string, T>(value: unknown, brand: K): value is Brand<K, T> {\n // In a phantom type system, we can't actually check the brand at runtime\n // We can only verify the value exists\n return value !== null && value !== undefined\n}\n\n/**\n * Create a branded type constructor for a specific brand\n * @param brand - The brand name\n * @returns A function that brands values with the specified brand\n */\nexport function createBrander<K extends string, T>(brand: K) {\n return (value: T): Brand<K, T> => Brand(brand, value)\n}\n\n// Common branded primitive types\nexport type BrandedString<K extends string> = Brand<K, string>\nexport type BrandedNumber<K extends string> = Brand<K, number>\nexport type BrandedBoolean<K extends string> = Brand<K, boolean>\n\n// Factory for common primitive branded types\nexport const BrandedString =\n <K extends string>(brand: K) =>\n (value: string): BrandedString<K> =>\n Brand(brand, value)\n\nexport const BrandedNumber =\n <K extends string>(brand: K) =>\n (value: number): BrandedNumber<K> =>\n Brand(brand, value)\n\nexport const BrandedBoolean =\n <K extends string>(brand: K) =>\n (value: boolean): BrandedBoolean<K> =>\n Brand(brand, value)\n"],"names":["Brand","brand","value","unbrand","branded","hasBrand","createBrander","BrandedString","BrandedNumber","BrandedBoolean"],"mappings":"AAoBgB,SAAAA,EAA2BC,GAAUC,GAAuB;AACnE,SAAAA;AACT;AAOO,SAASC,EAAWC,GAA8B;AAChD,SAAAA;AACT;AAagB,SAAAC,EAA8BH,GAAgBD,GAAgC;AAGrF,SAAAC,KAAU;AACnB;AAOO,SAASI,EAAmCL,GAAU;AAC3D,SAAO,CAACC,MAA0BF,EAAMC,GAAOC,CAAK;AACtD;AAQO,MAAMK,IACX,CAAmBN,MACnB,CAACC,MACCF,EAAMC,GAAOC,CAAK,GAETM,IACX,CAAmBP,MACnB,CAACC,MACCF,EAAMC,GAAOC,CAAK,GAETO,IACX,CAAmBR,MACnB,CAACC,MACCF,EAAMC,GAAOC,CAAK;"}
@@ -0,0 +1,8 @@
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>;
@@ -0,0 +1,23 @@
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;
@@ -0,0 +1 @@
1
+ export * from './Companion';
@@ -0,0 +1,10 @@
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
+ };
@@ -0,0 +1 @@
1
+ export * from './Base';
@@ -0,0 +1,4 @@
1
+ export * from './base';
2
+ export * from './info';
3
+ export * from './task';
4
+ export * from './throwable';
@@ -0,0 +1,26 @@
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 {};
@@ -0,0 +1 @@
1
+ export * from './Info';
@@ -0,0 +1,57 @@
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
+ };
@@ -0,0 +1 @@
1
+ export * from './Task';
@@ -0,0 +1,18 @@
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 {};
@@ -0,0 +1 @@
1
+ export * from './Throwable';
@@ -0,0 +1,57 @@
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,3 +1 @@
1
- import '../Tuple-GXgoHfiN.js';
2
- export { E as Either, a as Left, R as Right, T as TestEither, d as TypeCheckLeft, c as TypeCheckRight, b as isLeft, i as isRight, t as tryCatch, e as tryCatchAsync } from '../option/index.js';
3
- import '../branded/index.js';
1
+ export * from './Either';
@@ -1,2 +1,13 @@
1
- export{q as Either,j as Left,i as Right,o as TypeCheckLeft,n as TypeCheckRight,l as isLeft,k as isRight,m as tryCatch,p as tryCatchAsync}from'../chunk-A3EHNBZM.mjs';import'../chunk-OQWAJKZJ.mjs';import'../chunk-TQJDL6YW.mjs';//# sourceMappingURL=index.mjs.map
2
- //# sourceMappingURL=index.mjs.map
1
+ import { E as s, L as e, R as h, b as i, T as c, a as r, i as y, t as f, c as C } from "../index-CgMYHgdG.mjs";
2
+ export {
3
+ s as Either,
4
+ e as Left,
5
+ h as Right,
6
+ i as TypeCheckLeft,
7
+ c as TypeCheckRight,
8
+ r as isLeft,
9
+ y as isRight,
10
+ f as tryCatch,
11
+ C as tryCatchAsync
12
+ };
13
+ //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,6 @@
1
+ export declare const ParseError: (message?: string) => Error & {
2
+ name: "ParseError";
3
+ };
4
+ export type ParseError = Error & {
5
+ name: "ParseError";
6
+ };
@@ -0,0 +1 @@
1
+ export * from './ParseError';