@nicolastoulemont/std 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/dist/adt/index.d.mts +1 -1
  2. package/dist/adt/index.mjs +1 -1
  3. package/dist/{adt-DraJkmij.mjs → adt-DH37Pprw.mjs} +53 -53
  4. package/dist/adt-DH37Pprw.mjs.map +1 -0
  5. package/dist/{apply-fn.types-CXDoeA7D.d.mts → apply-fn.types-0g_9eXRy.d.mts} +1 -1
  6. package/dist/{apply-fn.types-CXDoeA7D.d.mts.map → apply-fn.types-0g_9eXRy.d.mts.map} +1 -1
  7. package/dist/brand/index.d.mts +2 -2
  8. package/dist/brand/index.mjs +2 -2
  9. package/dist/{brand-CTaxGuU9.mjs → brand-BqcqFXj5.mjs} +6 -6
  10. package/dist/{brand-CTaxGuU9.mjs.map → brand-BqcqFXj5.mjs.map} +1 -1
  11. package/dist/chunk-DRYujVrt.mjs +18 -0
  12. package/dist/data/index.d.mts +1 -1
  13. package/dist/data/index.mjs +1 -1
  14. package/dist/{data-DgzWI4R_.mjs → data-Cg8ySt6-.mjs} +13 -13
  15. package/dist/data-Cg8ySt6-.mjs.map +1 -0
  16. package/dist/discriminator.types-D-UbMmAD.d.mts +7 -0
  17. package/dist/discriminator.types-D-UbMmAD.d.mts.map +1 -0
  18. package/dist/either/index.d.mts +2 -2
  19. package/dist/either/index.mjs +2 -2
  20. package/dist/{either-CnOBUH7a.mjs → either-jkBX8xS1.mjs} +181 -44
  21. package/dist/either-jkBX8xS1.mjs.map +1 -0
  22. package/dist/{equality-YMebYwm1.mjs → equality-C2l3BIi8.mjs} +28 -28
  23. package/dist/equality-C2l3BIi8.mjs.map +1 -0
  24. package/dist/err/index.d.mts +2 -2
  25. package/dist/err/index.mjs +2 -2
  26. package/dist/{err-BqQApH9r.mjs → err-BM-svBaK.mjs} +20 -13
  27. package/dist/err-BM-svBaK.mjs.map +1 -0
  28. package/dist/flow/index.d.mts +1 -1
  29. package/dist/flow/index.mjs +1 -1
  30. package/dist/{flow-pRdnqmMY.mjs → flow-D4cE0EAg.mjs} +10 -3
  31. package/dist/flow-D4cE0EAg.mjs.map +1 -0
  32. package/dist/fx/index.d.mts +3 -0
  33. package/dist/fx/index.mjs +4 -0
  34. package/dist/fx-B-0MxGTM.mjs +1306 -0
  35. package/dist/fx-B-0MxGTM.mjs.map +1 -0
  36. package/dist/fx.types-DpIQILok.mjs +13 -0
  37. package/dist/fx.types-DpIQILok.mjs.map +1 -0
  38. package/dist/fx.types-aTmhyidu.d.mts +133 -0
  39. package/dist/fx.types-aTmhyidu.d.mts.map +1 -0
  40. package/dist/index-BO6bxBeo.d.mts +457 -0
  41. package/dist/index-BO6bxBeo.d.mts.map +1 -0
  42. package/dist/{index-tkgTLCoq.d.mts → index-BOrJQBPO.d.mts} +2 -2
  43. package/dist/{index-tkgTLCoq.d.mts.map → index-BOrJQBPO.d.mts.map} +1 -1
  44. package/dist/{index-zC2zAtZY.d.mts → index-CLlcoy8B.d.mts} +2 -2
  45. package/dist/{index-zC2zAtZY.d.mts.map → index-CLlcoy8B.d.mts.map} +1 -1
  46. package/dist/index-CLspOlBH.d.mts +737 -0
  47. package/dist/index-CLspOlBH.d.mts.map +1 -0
  48. package/dist/{index-BR7takNf.d.mts → index-CQxzD1YM.d.mts} +63 -24
  49. package/dist/index-CQxzD1YM.d.mts.map +1 -0
  50. package/dist/index-ClxPiGP9.d.mts +886 -0
  51. package/dist/index-ClxPiGP9.d.mts.map +1 -0
  52. package/dist/index-Cydt5ocm.d.mts +221 -0
  53. package/dist/index-Cydt5ocm.d.mts.map +1 -0
  54. package/dist/index-D5tzehjf.d.mts +476 -0
  55. package/dist/index-D5tzehjf.d.mts.map +1 -0
  56. package/dist/{index-BCrD3pEs.d.mts → index-EmWRCTY3.d.mts} +18 -18
  57. package/dist/index-EmWRCTY3.d.mts.map +1 -0
  58. package/dist/{index-Cp_4sFun.d.mts → index-FySViSfh.d.mts} +136 -41
  59. package/dist/index-FySViSfh.d.mts.map +1 -0
  60. package/dist/index-USQPafrR.d.mts +288 -0
  61. package/dist/index-USQPafrR.d.mts.map +1 -0
  62. package/dist/index.d.mts +27 -789
  63. package/dist/index.d.mts.map +1 -1
  64. package/dist/index.mjs +13 -1391
  65. package/dist/option/index.d.mts +3 -3
  66. package/dist/option/index.mjs +3 -2
  67. package/dist/{option-CKHDOVea.mjs → option-C2QpGffy.mjs} +149 -29
  68. package/dist/option-C2QpGffy.mjs.map +1 -0
  69. package/dist/option.types-BiAiZ8Ks.mjs +33 -0
  70. package/dist/option.types-BiAiZ8Ks.mjs.map +1 -0
  71. package/dist/option.types-CVvowfmd.d.mts +165 -0
  72. package/dist/option.types-CVvowfmd.d.mts.map +1 -0
  73. package/dist/pipe/index.d.mts +1 -1
  74. package/dist/pipe/index.mjs +1 -1
  75. package/dist/{pipe-GYxZNkPB.mjs → pipe-BF4G4SLo.mjs} +2 -2
  76. package/dist/{pipe-GYxZNkPB.mjs.map → pipe-BF4G4SLo.mjs.map} +1 -1
  77. package/dist/pipeable-DYNrUps7.mjs +92 -0
  78. package/dist/pipeable-DYNrUps7.mjs.map +1 -0
  79. package/dist/pipeable-Dr0d_q4F.d.mts +27 -0
  80. package/dist/pipeable-Dr0d_q4F.d.mts.map +1 -0
  81. package/dist/predicate/index.d.mts +2 -2
  82. package/dist/predicate/index.mjs +2 -2
  83. package/dist/{predicate-BZkZmo-W.mjs → predicate-Dt9Qsbav.mjs} +2 -2
  84. package/dist/{predicate-BZkZmo-W.mjs.map → predicate-Dt9Qsbav.mjs.map} +1 -1
  85. package/dist/result/index.d.mts +3 -3
  86. package/dist/result/index.mjs +2 -2
  87. package/dist/{result-C5tPWR60.mjs → result-DhYA-J-M.mjs} +158 -38
  88. package/dist/result-DhYA-J-M.mjs.map +1 -0
  89. package/dist/result.types-_W95221K.d.mts +150 -0
  90. package/dist/result.types-_W95221K.d.mts.map +1 -0
  91. package/package.json +1 -9
  92. package/dist/adt-DraJkmij.mjs.map +0 -1
  93. package/dist/data-DgzWI4R_.mjs.map +0 -1
  94. package/dist/discriminator.types-DCkkrCj4.d.mts +0 -7
  95. package/dist/discriminator.types-DCkkrCj4.d.mts.map +0 -1
  96. package/dist/either-CnOBUH7a.mjs.map +0 -1
  97. package/dist/equality/index.d.mts +0 -86
  98. package/dist/equality/index.d.mts.map +0 -1
  99. package/dist/equality/index.mjs +0 -3
  100. package/dist/equality-YMebYwm1.mjs.map +0 -1
  101. package/dist/err-BqQApH9r.mjs.map +0 -1
  102. package/dist/flow-pRdnqmMY.mjs.map +0 -1
  103. package/dist/fn/index.d.mts +0 -2
  104. package/dist/fn/index.mjs +0 -3
  105. package/dist/fn-DFHj-EVA.mjs +0 -10
  106. package/dist/fn-DFHj-EVA.mjs.map +0 -1
  107. package/dist/gen/index.d.mts +0 -3
  108. package/dist/gen/index.mjs +0 -3
  109. package/dist/gen-DF-FXNdy.mjs +0 -99
  110. package/dist/gen-DF-FXNdy.mjs.map +0 -1
  111. package/dist/index-B3z7T6Dz.d.mts +0 -57
  112. package/dist/index-B3z7T6Dz.d.mts.map +0 -1
  113. package/dist/index-BCrD3pEs.d.mts.map +0 -1
  114. package/dist/index-BFhV56qy.d.mts +0 -105
  115. package/dist/index-BFhV56qy.d.mts.map +0 -1
  116. package/dist/index-BLG9B4bn.d.mts +0 -116
  117. package/dist/index-BLG9B4bn.d.mts.map +0 -1
  118. package/dist/index-BR7takNf.d.mts.map +0 -1
  119. package/dist/index-BiFc2xWF.d.mts +0 -211
  120. package/dist/index-BiFc2xWF.d.mts.map +0 -1
  121. package/dist/index-BwVaI5d0.d.mts +0 -79
  122. package/dist/index-BwVaI5d0.d.mts.map +0 -1
  123. package/dist/index-CckxkaUd.d.mts +0 -80
  124. package/dist/index-CckxkaUd.d.mts.map +0 -1
  125. package/dist/index-Cp_4sFun.d.mts.map +0 -1
  126. package/dist/index-DbfMra4p.d.mts +0 -72
  127. package/dist/index-DbfMra4p.d.mts.map +0 -1
  128. package/dist/index.mjs.map +0 -1
  129. package/dist/is-promise-BEl3eGZg.mjs +0 -11
  130. package/dist/is-promise-BEl3eGZg.mjs.map +0 -1
  131. package/dist/option-CKHDOVea.mjs.map +0 -1
  132. package/dist/option.types-eqVODMIy.d.mts +0 -89
  133. package/dist/option.types-eqVODMIy.d.mts.map +0 -1
  134. package/dist/result-C5tPWR60.mjs.map +0 -1
  135. package/dist/result.types-Bd8a43Fg.d.mts +0 -174
  136. package/dist/result.types-Bd8a43Fg.d.mts.map +0 -1
  137. /package/dist/{result-D7XJ96pv.mjs → result-BmqdTN5o.mjs} +0 -0
@@ -101,26 +101,26 @@ function deepEquals(a, b) {
101
101
  * Create an equals method for a specific record type.
102
102
  *
103
103
  * Returns a function that compares two values of the same record type.
104
- * Returns false if either value doesn't have the expected __typename.
104
+ * Returns false if either value doesn't have the expected _tag.
105
105
  *
106
- * @template Typename - The discriminator string literal type
107
- * @template T - The record's data type (excluding __typename)
108
- * @param __typename - The expected __typename discriminator value
106
+ * @template Tag - The discriminator string literal type
107
+ * @template T - The record's data type (excluding _tag)
108
+ * @param _tag - The expected _tag discriminator value
109
109
  * @returns A binary equality function for the record type
110
110
  *
111
111
  * @example
112
112
  * ```ts
113
113
  * const equalsPoint = createEqualsMethod<'Point', { x: number; y: number }>('Point')
114
114
  * equalsPoint(
115
- * { __typename: 'Point', x: 1, y: 2 },
116
- * { __typename: 'Point', x: 1, y: 2 }
115
+ * { _tag: 'Point', x: 1, y: 2 },
116
+ * { _tag: 'Point', x: 1, y: 2 }
117
117
  * ) // true
118
118
  * ```
119
119
  */
120
- function createEqualsMethod(__typename) {
120
+ function createEqualsMethod(_tag) {
121
121
  return (a, b) => {
122
122
  if (a === b) return true;
123
- if (a.__typename !== __typename || b.__typename !== __typename) return false;
123
+ if (a._tag !== _tag || b._tag !== _tag) return false;
124
124
  return deepEquals(a, b);
125
125
  };
126
126
  }
@@ -128,22 +128,22 @@ function createEqualsMethod(__typename) {
128
128
  * Create a hash method for a specific record type.
129
129
  *
130
130
  * Returns a function that computes a hash code for values of the record type.
131
- * Returns 0 if the value doesn't have the expected __typename.
131
+ * Returns 0 if the value doesn't have the expected _tag.
132
132
  *
133
- * @template Typename - The discriminator string literal type
134
- * @template T - The record's data type (excluding __typename)
135
- * @param __typename - The expected __typename discriminator value
133
+ * @template Tag - The discriminator string literal type
134
+ * @template T - The record's data type (excluding _tag)
135
+ * @param _tag - The expected _tag discriminator value
136
136
  * @returns A unary hash function for the record type
137
137
  *
138
138
  * @example
139
139
  * ```ts
140
140
  * const hashPoint = createHashMethod<'Point', { x: number; y: number }>('Point')
141
- * hashPoint({ __typename: 'Point', x: 1, y: 2 }) // number
141
+ * hashPoint({ _tag: 'Point', x: 1, y: 2 }) // number
142
142
  * ```
143
143
  */
144
- function createHashMethod(__typename) {
144
+ function createHashMethod(_tag) {
145
145
  return (value) => {
146
- if (value.__typename !== __typename) return 0;
146
+ if (value._tag !== _tag) return 0;
147
147
  return deepHash(value);
148
148
  };
149
149
  }
@@ -151,24 +151,24 @@ function createHashMethod(__typename) {
151
151
  * Create an equals method for an ADT (any variant).
152
152
  *
153
153
  * Returns a function that compares two ADT values for structural equality.
154
- * Values must have the same __typename and be a known variant.
154
+ * Values must have the same _tag and be a known variant.
155
155
  *
156
- * @template T - The ADT type (union of all variants with __typename)
157
- * @param typenames - Array of valid __typename values for this ADT
156
+ * @template T - The ADT type (union of all variants with _tag)
157
+ * @param tags - Array of valid _tag values for this ADT
158
158
  * @returns A binary equality function for any variant of the ADT
159
159
  *
160
160
  * @example
161
161
  * ```ts
162
162
  * const equalsShape = createADTEqualsMethod<Circle | Square>(['Circle', 'Square'])
163
163
  * equalsShape(circle1, circle2) // true if structurally equal
164
- * equalsShape(circle, square) // false (different __typename)
164
+ * equalsShape(circle, square) // false (different _tag)
165
165
  * ```
166
166
  */
167
- function createADTEqualsMethod(typenames) {
167
+ function createADTEqualsMethod(tags) {
168
168
  return (a, b) => {
169
169
  if (a === b) return true;
170
- if (a.__typename !== b.__typename) return false;
171
- if (!typenames.includes(a.__typename)) return false;
170
+ if (a._tag !== b._tag) return false;
171
+ if (!tags.includes(a._tag)) return false;
172
172
  return deepEquals(a, b);
173
173
  };
174
174
  }
@@ -176,10 +176,10 @@ function createADTEqualsMethod(typenames) {
176
176
  * Create a hash method for an ADT (any variant).
177
177
  *
178
178
  * Returns a function that computes a hash code for any variant of the ADT.
179
- * Returns 0 if the value's __typename is not a known variant.
179
+ * Returns 0 if the value's _tag is not a known variant.
180
180
  *
181
- * @template T - The ADT type (union of all variants with __typename)
182
- * @param typenames - Array of valid __typename values for this ADT
181
+ * @template T - The ADT type (union of all variants with _tag)
182
+ * @param tags - Array of valid _tag values for this ADT
183
183
  * @returns A unary hash function for any variant of the ADT
184
184
  *
185
185
  * @example
@@ -189,13 +189,13 @@ function createADTEqualsMethod(typenames) {
189
189
  * hashShape(square) // number
190
190
  * ```
191
191
  */
192
- function createADTHashMethod(typenames) {
192
+ function createADTHashMethod(tags) {
193
193
  return (value) => {
194
- if (!typenames.includes(value.__typename)) return 0;
194
+ if (!tags.includes(value._tag)) return 0;
195
195
  return deepHash(value);
196
196
  };
197
197
  }
198
198
 
199
199
  //#endregion
200
200
  export { deepEquals as a, createHashMethod as i, createADTHashMethod as n, deepHash as o, createEqualsMethod as r, createADTEqualsMethod as t };
201
- //# sourceMappingURL=equality-YMebYwm1.mjs.map
201
+ //# sourceMappingURL=equality-C2l3BIi8.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"equality-C2l3BIi8.mjs","names":[],"sources":["../src/equality/equality.ts"],"sourcesContent":["import type { Discriminator } from \"../shared/discriminator.types\"\n\n// ============================================================================\n// Hashing (FNV-1a inspired algorithm)\n// ============================================================================\n\nconst FNV_OFFSET = 2166136261\nconst FNV_PRIME = 16777619\n\n/**\n * Compute a 32-bit hash code for any value using an FNV-1a inspired algorithm.\n *\n * Handles: primitives, null, undefined, Date, arrays, and plain objects.\n * Object keys are sorted for deterministic hashing regardless of insertion order.\n *\n * @param value - The value to hash (any type)\n * @returns A 32-bit unsigned integer hash code\n *\n * @example\n * ```ts\n * deepHash({ a: 1, b: 2 }) // deterministic number\n * deepHash({ b: 2, a: 1 }) // same number (keys sorted)\n * deepHash([1, 2, 3]) === deepHash([1, 2, 3]) // true\n * ```\n */\nexport function deepHash(value: unknown): number {\n let hash = FNV_OFFSET\n\n // \"null\" as hex\n if (value === null) return hash ^ 0x6e756c6c\n // \"unde\" as hex\n if (value === undefined) return hash ^ 0x756e6465\n\n /* oxlint-disable unicorn/prefer-math-trunc, no-case-declarations, switch-exhaustiveness-check -- Bitwise ops are intentional for FNV-1a hash: | 0 truncates to signed 32-bit, >>> 0 converts to unsigned 32-bit (Math.trunc cannot do this). Default case handles function, symbol, bigint. */\n switch (typeof value) {\n case \"boolean\":\n return hash ^ (value ? 1 : 0)\n\n case \"number\": {\n // Handle special cases: \"NaN\" as hex\n if (Number.isNaN(value)) return hash ^ 0x4e614e\n if (!Number.isFinite(value)) return hash ^ (value > 0 ? 0x496e66 : 0x2d496e66)\n // Mix the number bits into hash\n return hash ^ (value | 0) ^ ((value * 1000000) | 0)\n }\n\n case \"string\":\n for (let i = 0; i < value.length; i++) {\n hash ^= value.codePointAt(i)!\n hash = Math.imul(hash, FNV_PRIME)\n }\n // Convert to unsigned 32-bit\n return hash >>> 0\n\n case \"object\": {\n if (value instanceof Date) {\n return hash ^ deepHash(value.getTime())\n }\n\n if (Array.isArray(value)) {\n // \"[]\" as hex\n hash ^= 0x5b5d\n for (let i = 0; i < value.length; i++) {\n hash ^= deepHash(value[i])\n hash = Math.imul(hash, FNV_PRIME)\n }\n return hash >>> 0\n }\n\n // Plain object: \"{}\" as hex\n hash ^= 0x7b7d\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for object iteration\n const obj = value as Record<string, unknown>\n // Sort keys for consistency\n const keys = Object.keys(obj).toSorted()\n for (const key of keys) {\n hash ^= deepHash(key)\n hash = Math.imul(hash, FNV_PRIME)\n hash ^= deepHash(obj[key])\n hash = Math.imul(hash, FNV_PRIME)\n }\n return hash >>> 0\n }\n\n default:\n // Handles: function, symbol, bigint\n return hash\n }\n /* oxlint-enable unicorn/prefer-math-trunc, no-case-declarations */\n}\n\n// ============================================================================\n// Equality\n// ============================================================================\n\n/**\n * Deep structural equality comparison for two values.\n *\n * Compares by value rather than reference. Handles:\n * - Primitives (===)\n * - null and undefined\n * - Date objects (by timestamp)\n * - Arrays (element-wise, same length required)\n * - Plain objects (key-value pairs, same keys required)\n *\n * @param a - First value to compare\n * @param b - Second value to compare\n * @returns true if values are structurally equal\n *\n * @example\n * ```ts\n * deepEquals({ x: 1 }, { x: 1 }) // true\n * deepEquals([1, 2], [1, 2]) // true\n * deepEquals(new Date(0), new Date(0)) // true\n * deepEquals({ a: 1 }, { a: 1, b: 2 }) // false (different keys)\n * ```\n */\nexport function deepEquals(a: unknown, b: unknown): boolean {\n // Same reference or both null/undefined\n if (a === b) return true\n\n // Different types\n if (typeof a !== typeof b) return false\n\n // Handle null\n if (a === null || b === null) return false\n\n // Primitives (already checked === above)\n if (typeof a !== \"object\") return false\n\n // Date comparison\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime()\n }\n\n // Array comparison\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length) return false\n return a.every((item, index) => deepEquals(item, b[index]))\n }\n\n // Plain object comparison\n if (Array.isArray(a) !== Array.isArray(b)) return false\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for object comparison\n const aObj = a as Record<string, unknown>\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for object comparison\n const bObj = b as Record<string, unknown>\n\n const aKeys = Object.keys(aObj)\n const bKeys = Object.keys(bObj)\n\n if (aKeys.length !== bKeys.length) return false\n\n return aKeys.every((key) => deepEquals(aObj[key], bObj[key]))\n}\n\n// ============================================================================\n// Factory Functions\n// ============================================================================\n\n/**\n * Create an equals method for a specific record type.\n *\n * Returns a function that compares two values of the same record type.\n * Returns false if either value doesn't have the expected _tag.\n *\n * @template Tag - The discriminator string literal type\n * @template T - The record's data type (excluding _tag)\n * @param _tag - The expected _tag discriminator value\n * @returns A binary equality function for the record type\n *\n * @example\n * ```ts\n * const equalsPoint = createEqualsMethod<'Point', { x: number; y: number }>('Point')\n * equalsPoint(\n * { _tag: 'Point', x: 1, y: 2 },\n * { _tag: 'Point', x: 1, y: 2 }\n * ) // true\n * ```\n */\nexport function createEqualsMethod<Tag extends string, T>(\n _tag: Tag,\n): (a: T & Discriminator<Tag>, b: T & Discriminator<Tag>) => boolean {\n return (a, b) => {\n if (a === b) return true\n if (a._tag !== _tag || b._tag !== _tag) return false\n return deepEquals(a, b)\n }\n}\n\n/**\n * Create a hash method for a specific record type.\n *\n * Returns a function that computes a hash code for values of the record type.\n * Returns 0 if the value doesn't have the expected _tag.\n *\n * @template Tag - The discriminator string literal type\n * @template T - The record's data type (excluding _tag)\n * @param _tag - The expected _tag discriminator value\n * @returns A unary hash function for the record type\n *\n * @example\n * ```ts\n * const hashPoint = createHashMethod<'Point', { x: number; y: number }>('Point')\n * hashPoint({ _tag: 'Point', x: 1, y: 2 }) // number\n * ```\n */\nexport function createHashMethod<Tag extends string, T>(_tag: Tag): (value: T & Discriminator<Tag>) => number {\n return (value) => {\n if (value._tag !== _tag) return 0\n return deepHash(value)\n }\n}\n\n/**\n * Create an equals method for an ADT (any variant).\n *\n * Returns a function that compares two ADT values for structural equality.\n * Values must have the same _tag and be a known variant.\n *\n * @template T - The ADT type (union of all variants with _tag)\n * @param tags - Array of valid _tag values for this ADT\n * @returns A binary equality function for any variant of the ADT\n *\n * @example\n * ```ts\n * const equalsShape = createADTEqualsMethod<Circle | Square>(['Circle', 'Square'])\n * equalsShape(circle1, circle2) // true if structurally equal\n * equalsShape(circle, square) // false (different _tag)\n * ```\n */\nexport function createADTEqualsMethod<T extends { readonly _tag: string }>(tags: string[]): (a: T, b: T) => boolean {\n return (a, b) => {\n if (a === b) return true\n if (a._tag !== b._tag) return false\n if (!tags.includes(a._tag)) return false\n return deepEquals(a, b)\n }\n}\n\n/**\n * Create a hash method for an ADT (any variant).\n *\n * Returns a function that computes a hash code for any variant of the ADT.\n * Returns 0 if the value's _tag is not a known variant.\n *\n * @template T - The ADT type (union of all variants with _tag)\n * @param tags - Array of valid _tag values for this ADT\n * @returns A unary hash function for any variant of the ADT\n *\n * @example\n * ```ts\n * const hashShape = createADTHashMethod<Circle | Square>(['Circle', 'Square'])\n * hashShape(circle) // number\n * hashShape(square) // number\n * ```\n */\nexport function createADTHashMethod<T extends { readonly _tag: string }>(tags: string[]): (value: T) => number {\n return (value) => {\n if (!tags.includes(value._tag)) return 0\n return deepHash(value)\n }\n}\n"],"mappings":"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"}
@@ -1,2 +1,2 @@
1
- import { a as TaggedError$1, i as ErrorTag, n as TaggedError, o as TaggedErrorFactory, r as ErrorData, s as TaggedErrorInstance, t as Err } from "../index-BR7takNf.mjs";
2
- export { Err, ErrorData, ErrorTag, TaggedError, TaggedErrorFactory, TaggedErrorInstance, TaggedError$1 as TaggedErrorType };
1
+ import { a as ErrorData, c as TaggedErrorFactory, i as tagged, l as TaggedErrorInstance, n as TaggedError, o as ErrorTag, r as is, s as TaggedError$1, t as Err } from "../index-CQxzD1YM.mjs";
2
+ export { Err, ErrorData, ErrorTag, TaggedError, TaggedErrorFactory, TaggedErrorInstance, TaggedError$1 as TaggedErrorType, is, tagged };
@@ -1,3 +1,3 @@
1
- import { n as TaggedError, t as Err } from "../err-BqQApH9r.mjs";
1
+ import { i as tagged, n as TaggedError, r as is, t as Err } from "../err-BM-svBaK.mjs";
2
2
 
3
- export { Err, TaggedError };
3
+ export { Err, TaggedError, is, tagged };
@@ -1,3 +1,5 @@
1
+ import { t as FxTypeId } from "./fx.types-DpIQILok.mjs";
2
+
1
3
  //#region src/err/err.ts
2
4
  /**
3
5
  * Create a constructor function for a tagged error type.
@@ -5,7 +7,7 @@
5
7
  * If the error has data, returns a function that requires the data object.
6
8
  *
7
9
  * @template E - The tagged error type
8
- * @param tag - The error tag (must match E's __typename)
10
+ * @param tag - The error tag (must match E's _tag)
9
11
  * @returns A constructor function for the error type
10
12
  *
11
13
  * @example
@@ -14,18 +16,18 @@
14
16
  * type NotFoundError = TaggedError<"NotFoundError", { resourceId: string }>
15
17
  * const NotFound = Err.tagged<NotFoundError>("NotFoundError")
16
18
  * const err = NotFound({ resourceId: "user-123" })
17
- * // { __typename: "NotFoundError", resourceId: "user-123" }
19
+ * // { _tag: "NotFoundError", resourceId: "user-123" }
18
20
  *
19
21
  * // Error without data
20
22
  * type UnauthorizedError = TaggedError<"UnauthorizedError">
21
23
  * const Unauthorized = Err.tagged<UnauthorizedError>("UnauthorizedError")
22
24
  * const err = Unauthorized()
23
- * // { __typename: "UnauthorizedError" }
25
+ * // { _tag: "UnauthorizedError" }
24
26
  * ```
25
27
  */
26
28
  const tagged = (tag) => {
27
29
  return ((data) => ({
28
- __typename: tag,
30
+ _tag: tag,
29
31
  ...data
30
32
  }));
31
33
  };
@@ -45,7 +47,7 @@ const tagged = (tag) => {
45
47
  * class NotFoundError extends TaggedError("NotFoundError")<{ id: string }> {}
46
48
  * const err = new NotFoundError({ id: "123" })
47
49
  * err.id // "123"
48
- * err.__typename // "NotFoundError"
50
+ * err._tag // "NotFoundError"
49
51
  * err.stack // Error stack trace
50
52
  *
51
53
  * // Error without data
@@ -53,7 +55,7 @@ const tagged = (tag) => {
53
55
  * const err2 = new UnauthorizedError()
54
56
  *
55
57
  * // Direct yielding in Do computation
56
- * const program = gen(function* () {
58
+ * const program = Fx.gen(function* () {
57
59
  * yield* new NotFoundError({ id: "123" }) // Short-circuits with error
58
60
  * })
59
61
  *
@@ -65,8 +67,13 @@ const tagged = (tag) => {
65
67
  */
66
68
  function TaggedError(tag) {
67
69
  return class TaggedErrorImpl extends Error {
68
- static __typename = tag;
69
- __typename = tag;
70
+ static _tag = tag;
71
+ _tag = tag;
72
+ [FxTypeId] = {
73
+ _A: () => void 0,
74
+ _E: () => this,
75
+ _R: () => void 0
76
+ };
70
77
  constructor(...args) {
71
78
  super(tag);
72
79
  this.name = tag;
@@ -111,12 +118,12 @@ function TaggedError(tag) {
111
118
  * ```
112
119
  */
113
120
  const is = (tag) => {
114
- return (error) => typeof error === "object" && error !== null && "__typename" in error && error.__typename === tag;
121
+ return (error) => typeof error === "object" && error !== null && "_tag" in error && error._tag === tag;
115
122
  };
116
123
  /**
117
124
  * Err namespace containing utilities for creating and checking tagged errors.
118
125
  *
119
- * Tagged errors are plain objects with a `__typename` discriminator field,
126
+ * Tagged errors are plain objects with a `_tag` discriminator field,
120
127
  * making them serializable and easy to pattern match.
121
128
  *
122
129
  * @example
@@ -140,7 +147,7 @@ const is = (tag) => {
140
147
  * }
141
148
  *
142
149
  * // Use with Do computation
143
- * const program = gen(function* () {
150
+ * const program = Fx.gen(function* () {
144
151
  * const user = yield* findUser("123")
145
152
  * return user
146
153
  * })
@@ -165,5 +172,5 @@ const Err = {
165
172
  };
166
173
 
167
174
  //#endregion
168
- export { TaggedError as n, Err as t };
169
- //# sourceMappingURL=err-BqQApH9r.mjs.map
175
+ export { tagged as i, TaggedError as n, is as r, Err as t };
176
+ //# sourceMappingURL=err-BM-svBaK.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"err-BM-svBaK.mjs","names":[],"sources":["../src/err/err.ts"],"sourcesContent":["import { FxTypeId } from \"../fx/fx.types\"\nimport type { TaggedError, TaggedErrorFactory } from \"./err.types\"\n\n/**\n * Helper type to extract data fields from a TaggedError (excluding _tag and Fx protocol)\n */\ntype DataOf<E extends TaggedError<string>> = Omit<E, \"_tag\" | typeof FxTypeId | typeof Symbol.iterator>\n\n/**\n * Helper type to check if data is empty (only has _tag)\n */\ntype IsEmptyData<Data> = keyof Data extends never ? true : false\n\n/**\n * Create a constructor function for a tagged error type.\n * If the error has no additional data, returns a function that takes no arguments.\n * If the error has data, returns a function that requires the data object.\n *\n * @template E - The tagged error type\n * @param tag - The error tag (must match E's _tag)\n * @returns A constructor function for the error type\n *\n * @example\n * ```ts\n * // Error with data\n * type NotFoundError = TaggedError<\"NotFoundError\", { resourceId: string }>\n * const NotFound = Err.tagged<NotFoundError>(\"NotFoundError\")\n * const err = NotFound({ resourceId: \"user-123\" })\n * // { _tag: \"NotFoundError\", resourceId: \"user-123\" }\n *\n * // Error without data\n * type UnauthorizedError = TaggedError<\"UnauthorizedError\">\n * const Unauthorized = Err.tagged<UnauthorizedError>(\"UnauthorizedError\")\n * const err = Unauthorized()\n * // { _tag: \"UnauthorizedError\" }\n * ```\n */\nexport const tagged: <E extends TaggedError<string>>(\n tag: E[\"_tag\"],\n) => IsEmptyData<DataOf<E>> extends true ? () => E : (data: DataOf<E>) => E = (tag) => {\n return ((data?: object) => ({ _tag: tag, ...data })) as never\n}\n\n/**\n * Create a class-based tagged error type (Effect-style syntax).\n * Returns a class that can be extended to create custom error types.\n * Errors are native Error objects with proper stack traces and instanceof support.\n * Implements Yieldable protocol so errors can be directly yielded in Do computations.\n *\n * @template Tag - The error tag (discriminator string)\n * @param tag - The error tag\n * @returns A class that can be extended with custom data\n *\n * @example\n * ```ts\n * // Error with data\n * class NotFoundError extends TaggedError(\"NotFoundError\")<{ id: string }> {}\n * const err = new NotFoundError({ id: \"123\" })\n * err.id // \"123\"\n * err._tag // \"NotFoundError\"\n * err.stack // Error stack trace\n *\n * // Error without data\n * class UnauthorizedError extends TaggedError(\"UnauthorizedError\") {}\n * const err2 = new UnauthorizedError()\n *\n * // Direct yielding in Do computation\n * const program = Fx.gen(function* () {\n * yield* new NotFoundError({ id: \"123\" }) // Short-circuits with error\n * })\n *\n * // instanceof checks work\n * if (err instanceof NotFoundError) {\n * console.log(err.id)\n * }\n * ```\n */\nexport function TaggedError<Tag extends string>(tag: Tag): TaggedErrorFactory<Tag> {\n return class TaggedErrorImpl<Data extends object = object> extends Error {\n static readonly _tag: Tag = tag\n readonly _tag: Tag = tag\n\n readonly [FxTypeId] = {\n _A: () => undefined as never,\n _E: () => this as TaggedErrorImpl<Data>,\n _R: () => undefined as never,\n }\n\n constructor(...args: keyof Data extends never ? [] : [data: Data]) {\n super(tag)\n this.name = tag\n const data = args[0]\n if (data) Object.assign(this, data)\n Object.setPrototypeOf(this, new.target.prototype)\n }\n\n *[Symbol.iterator](): Generator<this, never, unknown> {\n yield this\n throw new Error(\"Unreachable: Do should short-circuit on error\")\n }\n } as unknown as TaggedErrorFactory<Tag>\n}\n\n/**\n * Create a type guard for a tagged error type.\n * Returns a curried function that checks if a value is the specified error type.\n *\n * @template E - The tagged error type to check for\n * @param tag - The error tag to match\n * @returns A type guard function\n *\n * @example\n * ```ts\n * type NotFoundError = TaggedError<\"NotFoundError\", { id: string }>\n *\n * const error: unknown = getError()\n *\n * if (Err.is<NotFoundError>(\"NotFoundError\")(error)) {\n * console.log(error.id) // TypeScript knows error is NotFoundError\n * }\n *\n * // Works with union error types\n * type AppError = NotFoundError | ValidationError | DbError\n *\n * function handleError(error: AppError) {\n * if (Err.is<NotFoundError>(\"NotFoundError\")(error)) {\n * // Handle not found\n * } else if (Err.is<ValidationError>(\"ValidationError\")(error)) {\n * // Handle validation error\n * }\n * }\n * ```\n */\nexport const is = <E extends TaggedError<string>>(tag: E[\"_tag\"]): ((error: unknown) => error is E) => {\n return (error: unknown): error is E =>\n typeof error === \"object\" && error !== null && \"_tag\" in error && error._tag === tag\n}\n\n/**\n * Err namespace containing utilities for creating and checking tagged errors.\n *\n * Tagged errors are plain objects with a `_tag` discriminator field,\n * making them serializable and easy to pattern match.\n *\n * @example\n * ```ts\n * import { Err, Result, Do } from \"@repo/std\"\n * import type { TaggedError } from \"@repo/std\"\n *\n * // Define error types\n * type NotFoundError = TaggedError<\"NotFoundError\", { resourceId: string }>\n * type ValidationError = TaggedError<\"ValidationError\", { field: string; message: string }>\n *\n * // Create constructors\n * const NotFound = Err.tagged<NotFoundError>(\"NotFoundError\")\n * const Validation = Err.tagged<ValidationError>(\"ValidationError\")\n *\n * // Use with Result\n * function findUser(id: string): Result<User, NotFoundError> {\n * const user = db.find(id)\n * if (!user) return Result.err(NotFound({ resourceId: id }))\n * return Result.ok(user)\n * }\n *\n * // Use with Do computation\n * const program = Fx.gen(function* () {\n * const user = yield* findUser(\"123\")\n * return user\n * })\n *\n * // Pattern match on error types\n * pipe(\n * program.run(),\n * Result.match({\n * ok: (user) => console.log(user),\n * err: (error) => {\n * if (Err.is<NotFoundError>(\"NotFoundError\")(error)) {\n * console.log(`Not found: ${error.resourceId}`)\n * }\n * }\n * })\n * )\n * ```\n */\nexport const Err = {\n tagged,\n is,\n} as const\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,UAEkE,QAAQ;AACrF,UAAS,UAAmB;EAAE,MAAM;EAAK,GAAG;EAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCpD,SAAgB,YAAgC,KAAmC;AACjF,QAAO,MAAM,wBAAsD,MAAM;EACvE,OAAgB,OAAY;EAC5B,AAAS,OAAY;EAErB,CAAU,YAAY;GACpB,UAAU;GACV,UAAU;GACV,UAAU;GACX;EAED,YAAY,GAAG,MAAoD;AACjE,SAAM,IAAI;AACV,QAAK,OAAO;GACZ,MAAM,OAAO,KAAK;AAClB,OAAI,KAAM,QAAO,OAAO,MAAM,KAAK;AACnC,UAAO,eAAe,MAAM,IAAI,OAAO,UAAU;;EAGnD,EAAE,OAAO,YAA6C;AACpD,SAAM;AACN,SAAM,IAAI,MAAM,gDAAgD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCtE,MAAa,MAAqC,QAAqD;AACrG,SAAQ,UACN,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,SAAS,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDrF,MAAa,MAAM;CACjB;CACA;CACD"}
@@ -1,2 +1,2 @@
1
- import { t as flow } from "../index-tkgTLCoq.mjs";
1
+ import { t as flow } from "../index-BOrJQBPO.mjs";
2
2
  export { flow };
@@ -1,3 +1,3 @@
1
- import { t as flow } from "../flow-pRdnqmMY.mjs";
1
+ import { t as flow } from "../flow-D4cE0EAg.mjs";
2
2
 
3
3
  export { flow };
@@ -1,5 +1,12 @@
1
- import { t as isPromise } from "./is-promise-BEl3eGZg.mjs";
1
+ //#region src/shared/is-promise.ts
2
+ /**
3
+ * Check if a value is a Promise.
4
+ */
5
+ function isPromise(value) {
6
+ return value instanceof Promise;
7
+ }
2
8
 
9
+ //#endregion
3
10
  //#region src/flow/flow.ts
4
11
  function flow(...fns) {
5
12
  return ((...args) => {
@@ -17,5 +24,5 @@ const resolveAsync = async (result, funs) => {
17
24
  };
18
25
 
19
26
  //#endregion
20
- export { flow as t };
21
- //# sourceMappingURL=flow-pRdnqmMY.mjs.map
27
+ export { isPromise as n, flow as t };
28
+ //# sourceMappingURL=flow-D4cE0EAg.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flow-D4cE0EAg.mjs","names":[],"sources":["../src/shared/is-promise.ts","../src/flow/flow.ts"],"sourcesContent":["/**\n * Check if a value is a Promise.\n */\nexport function isPromise(value: unknown): value is Promise<unknown> {\n return value instanceof Promise\n}\n","import { isPromise } from \"../shared/is-promise\"\nimport type { λ } from \"../shared/lambda.types\"\nimport type { FlowdFun } from \"./flow.types\"\n\n/**\n * Given a list of functions returns a function that will execute the given\n * functions one after another, always passing the result of the previous\n * function as an argument to the next function.\n *\n * If one of the given functions returns a promise, the promise will be resolved\n * before being passed to the next function.\n *\n * Type inference: This function provides automatic type inference for chains of\n * 1-15 functions. Each function's parameter type is automatically inferred from\n * the previous function's return type. For chains longer than 15 functions,\n * types must be explicitly specified.\n *\n * Async support: Functions can return Promises. The runtime automatically awaits\n * Promises before passing values to subsequent functions, and parameter types\n * use `Awaited<T>` to reflect this behavior. The final return type will be\n * Promise<T> if any function returns a Promise.\n *\n * @see {@link pipe} for immediate execution with an initial value\n *\n * @example\n * ```typescript\n * const join = (...chars: string[]) => chars.join('')\n * flow(join, parseInt)('1', '2', '3') // -> 123\n *\n * const square = (n: number) => n ** 2\n *\n * // this is equivalent to: square(square(square(2)))\n * flow(square, square, square)(2) // -> 256\n *\n * // Type inference in action\n * const fn = flow(\n * (n: number) => n * 2, // First function must be typed\n * (n) => n + 1, // n: number (inferred!)\n * (n) => n.toString() // n: number (inferred!)\n * )\n *\n * // also works with promises:\n * // fetchNumber :: async () => Promise<number>\n * flow(fetchNumber, n => n.toString()) // async () => Promise<string>\n * ```\n */\n// 1 function\nexport function flow<A extends unknown[], B>(f1: (...args: A) => B): FlowdFun<[typeof f1]>\n// 2 functions\nexport function flow<A extends unknown[], B, C>(\n f1: (...args: A) => B,\n f2: (arg: Awaited<B>) => C,\n): FlowdFun<[typeof f1, typeof f2]>\n// 3 functions\nexport function flow<A extends unknown[], B, C, D>(\n f1: (...args: A) => B,\n f2: (arg: Awaited<B>) => C,\n f3: (arg: Awaited<C>) => D,\n): FlowdFun<[typeof f1, typeof f2, typeof f3]>\n// 4 functions\nexport function flow<A extends unknown[], B, C, D, E>(\n f1: (...args: A) => B,\n f2: (arg: Awaited<B>) => C,\n f3: (arg: Awaited<C>) => D,\n f4: (arg: Awaited<D>) => E,\n): FlowdFun<[typeof f1, typeof f2, typeof f3, typeof f4]>\n// 5 functions\nexport function flow<A extends unknown[], B, C, D, E, F>(\n f1: (...args: A) => B,\n f2: (arg: Awaited<B>) => C,\n f3: (arg: Awaited<C>) => D,\n f4: (arg: Awaited<D>) => E,\n f5: (arg: Awaited<E>) => F,\n): FlowdFun<[typeof f1, typeof f2, typeof f3, typeof f4, typeof f5]>\n// 6 functions\nexport function flow<A extends unknown[], B, C, D, E, F, G>(\n f1: (...args: A) => B,\n f2: (arg: Awaited<B>) => C,\n f3: (arg: Awaited<C>) => D,\n f4: (arg: Awaited<D>) => E,\n f5: (arg: Awaited<E>) => F,\n f6: (arg: Awaited<F>) => G,\n): FlowdFun<[typeof f1, typeof f2, typeof f3, typeof f4, typeof f5, typeof f6]>\n// 7 functions\nexport function flow<A extends unknown[], B, C, D, E, F, G, H>(\n f1: (...args: A) => B,\n f2: (arg: Awaited<B>) => C,\n f3: (arg: Awaited<C>) => D,\n f4: (arg: Awaited<D>) => E,\n f5: (arg: Awaited<E>) => F,\n f6: (arg: Awaited<F>) => G,\n f7: (arg: Awaited<G>) => H,\n): FlowdFun<[typeof f1, typeof f2, typeof f3, typeof f4, typeof f5, typeof f6, typeof f7]>\n// 8 functions\nexport function flow<A extends unknown[], B, C, D, E, F, G, H, I>(\n f1: (...args: A) => B,\n f2: (arg: Awaited<B>) => C,\n f3: (arg: Awaited<C>) => D,\n f4: (arg: Awaited<D>) => E,\n f5: (arg: Awaited<E>) => F,\n f6: (arg: Awaited<F>) => G,\n f7: (arg: Awaited<G>) => H,\n f8: (arg: Awaited<H>) => I,\n): FlowdFun<[typeof f1, typeof f2, typeof f3, typeof f4, typeof f5, typeof f6, typeof f7, typeof f8]>\n// 9 functions\nexport function flow<A extends unknown[], B, C, D, E, F, G, H, I, J>(\n f1: (...args: A) => B,\n f2: (arg: Awaited<B>) => C,\n f3: (arg: Awaited<C>) => D,\n f4: (arg: Awaited<D>) => E,\n f5: (arg: Awaited<E>) => F,\n f6: (arg: Awaited<F>) => G,\n f7: (arg: Awaited<G>) => H,\n f8: (arg: Awaited<H>) => I,\n f9: (arg: Awaited<I>) => J,\n): FlowdFun<[typeof f1, typeof f2, typeof f3, typeof f4, typeof f5, typeof f6, typeof f7, typeof f8, typeof f9]>\n// 10 functions\nexport function flow<A extends unknown[], B, C, D, E, F, G, H, I, J, K>(\n f1: (...args: A) => B,\n f2: (arg: Awaited<B>) => C,\n f3: (arg: Awaited<C>) => D,\n f4: (arg: Awaited<D>) => E,\n f5: (arg: Awaited<E>) => F,\n f6: (arg: Awaited<F>) => G,\n f7: (arg: Awaited<G>) => H,\n f8: (arg: Awaited<H>) => I,\n f9: (arg: Awaited<I>) => J,\n f10: (arg: Awaited<J>) => K,\n): FlowdFun<\n [typeof f1, typeof f2, typeof f3, typeof f4, typeof f5, typeof f6, typeof f7, typeof f8, typeof f9, typeof f10]\n>\n// 11 functions\nexport function flow<A extends unknown[], B, C, D, E, F, G, H, I, J, K, L>(\n f1: (...args: A) => B,\n f2: (arg: Awaited<B>) => C,\n f3: (arg: Awaited<C>) => D,\n f4: (arg: Awaited<D>) => E,\n f5: (arg: Awaited<E>) => F,\n f6: (arg: Awaited<F>) => G,\n f7: (arg: Awaited<G>) => H,\n f8: (arg: Awaited<H>) => I,\n f9: (arg: Awaited<I>) => J,\n f10: (arg: Awaited<J>) => K,\n f11: (arg: Awaited<K>) => L,\n): FlowdFun<\n [\n typeof f1,\n typeof f2,\n typeof f3,\n typeof f4,\n typeof f5,\n typeof f6,\n typeof f7,\n typeof f8,\n typeof f9,\n typeof f10,\n typeof f11,\n ]\n>\n// 12 functions\nexport function flow<A extends unknown[], B, C, D, E, F, G, H, I, J, K, L, M>(\n f1: (...args: A) => B,\n f2: (arg: Awaited<B>) => C,\n f3: (arg: Awaited<C>) => D,\n f4: (arg: Awaited<D>) => E,\n f5: (arg: Awaited<E>) => F,\n f6: (arg: Awaited<F>) => G,\n f7: (arg: Awaited<G>) => H,\n f8: (arg: Awaited<H>) => I,\n f9: (arg: Awaited<I>) => J,\n f10: (arg: Awaited<J>) => K,\n f11: (arg: Awaited<K>) => L,\n f12: (arg: Awaited<L>) => M,\n): FlowdFun<\n [\n typeof f1,\n typeof f2,\n typeof f3,\n typeof f4,\n typeof f5,\n typeof f6,\n typeof f7,\n typeof f8,\n typeof f9,\n typeof f10,\n typeof f11,\n typeof f12,\n ]\n>\n// 13 functions\nexport function flow<A extends unknown[], B, C, D, E, F, G, H, I, J, K, L, M, N>(\n f1: (...args: A) => B,\n f2: (arg: Awaited<B>) => C,\n f3: (arg: Awaited<C>) => D,\n f4: (arg: Awaited<D>) => E,\n f5: (arg: Awaited<E>) => F,\n f6: (arg: Awaited<F>) => G,\n f7: (arg: Awaited<G>) => H,\n f8: (arg: Awaited<H>) => I,\n f9: (arg: Awaited<I>) => J,\n f10: (arg: Awaited<J>) => K,\n f11: (arg: Awaited<K>) => L,\n f12: (arg: Awaited<L>) => M,\n f13: (arg: Awaited<M>) => N,\n): FlowdFun<\n [\n typeof f1,\n typeof f2,\n typeof f3,\n typeof f4,\n typeof f5,\n typeof f6,\n typeof f7,\n typeof f8,\n typeof f9,\n typeof f10,\n typeof f11,\n typeof f12,\n typeof f13,\n ]\n>\n// 14 functions\nexport function flow<A extends unknown[], B, C, D, E, F, G, H, I, J, K, L, M, N, O>(\n f1: (...args: A) => B,\n f2: (arg: Awaited<B>) => C,\n f3: (arg: Awaited<C>) => D,\n f4: (arg: Awaited<D>) => E,\n f5: (arg: Awaited<E>) => F,\n f6: (arg: Awaited<F>) => G,\n f7: (arg: Awaited<G>) => H,\n f8: (arg: Awaited<H>) => I,\n f9: (arg: Awaited<I>) => J,\n f10: (arg: Awaited<J>) => K,\n f11: (arg: Awaited<K>) => L,\n f12: (arg: Awaited<L>) => M,\n f13: (arg: Awaited<M>) => N,\n f14: (arg: Awaited<N>) => O,\n): FlowdFun<\n [\n typeof f1,\n typeof f2,\n typeof f3,\n typeof f4,\n typeof f5,\n typeof f6,\n typeof f7,\n typeof f8,\n typeof f9,\n typeof f10,\n typeof f11,\n typeof f12,\n typeof f13,\n typeof f14,\n ]\n>\n// 15 functions\nexport function flow<A extends unknown[], B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>(\n f1: (...args: A) => B,\n f2: (arg: Awaited<B>) => C,\n f3: (arg: Awaited<C>) => D,\n f4: (arg: Awaited<D>) => E,\n f5: (arg: Awaited<E>) => F,\n f6: (arg: Awaited<F>) => G,\n f7: (arg: Awaited<G>) => H,\n f8: (arg: Awaited<H>) => I,\n f9: (arg: Awaited<I>) => J,\n f10: (arg: Awaited<J>) => K,\n f11: (arg: Awaited<K>) => L,\n f12: (arg: Awaited<L>) => M,\n f13: (arg: Awaited<M>) => N,\n f14: (arg: Awaited<N>) => O,\n f15: (arg: Awaited<O>) => P,\n): FlowdFun<\n [\n typeof f1,\n typeof f2,\n typeof f3,\n typeof f4,\n typeof f5,\n typeof f6,\n typeof f7,\n typeof f8,\n typeof f9,\n typeof f10,\n typeof f11,\n typeof f12,\n typeof f13,\n typeof f14,\n typeof f15,\n ]\n>\n// Implementation signature (fallback for 16+ functions)\nexport function flow<Fns extends [λ, ...λ[]]>(...fns: Fns): FlowdFun<Fns> {\n // oxlint-disable-next-line\n return ((...args) => {\n // oxlint-disable-next-line\n let nextArgs: unknown[] = args\n\n for (let i = 0; i < fns.length; i++) {\n // oxlint-disable-next-line\n const [result] = (nextArgs = [fns[i]?.(...nextArgs)])\n if (isPromise(result)) return resolveAsync(result, fns.slice(i + 1))\n }\n\n return nextArgs[0]\n }) as FlowdFun<Fns>\n}\n\nconst resolveAsync = async (result: unknown, funs: λ[]) => {\n // oxlint-disable-next-line\n for (const fun of funs) result = fun(await result)\n return await result\n}\n"],"mappings":";;;;AAGA,SAAgB,UAAU,OAA2C;AACnE,QAAO,iBAAiB;;;;;ACgS1B,SAAgB,KAA8B,GAAG,KAAyB;AAExE,UAAS,GAAG,SAAS;EAEnB,IAAI,WAAsB;AAE1B,OAAK,IAAI,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK;GAEnC,MAAM,CAAC,UAAW,WAAW,CAAC,IAAI,KAAK,GAAG,SAAS,CAAC;AACpD,OAAI,UAAU,OAAO,CAAE,QAAO,aAAa,QAAQ,IAAI,MAAM,IAAI,EAAE,CAAC;;AAGtE,SAAO,SAAS;;;AAIpB,MAAM,eAAe,OAAO,QAAiB,SAAc;AAEzD,MAAK,MAAM,OAAO,KAAM,UAAS,IAAI,MAAM,OAAO;AAClD,QAAO,MAAM"}
@@ -0,0 +1,3 @@
1
+ import { a as FxError, c as FxSuccess, d as FxYield, f as FxYieldable, g as isServiceRequest, h as SyncFx, i as Fx$1, l as FxTypeId, m as ServiceRequest, n as AsyncFxGenerator, o as FxGenerator, p as RunnableFx, r as AsyncFxYieldable, s as FxRequirements, t as AsyncFx, u as FxValue } from "../fx.types-aTmhyidu.mjs";
2
+ import { A as isFxDefect, C as isServiceClass, D as err, E as FxDefect, M as run, O as fn, S as ServiceOf, T as Fx, _ as createScope, a as Layer$1, b as ServiceClass, c as LayerROut, d as UnprovidedDeps, f as MemoMap, g as ScopeTag, h as ScopeService, i as Layer, j as ok, k as gen, l as MergeError, m as ExcludeScope, n as provideContext, o as LayerError, p as createMemoMap, r as provideService, s as LayerRIn, t as provide, u as MergeROut, v as Context, w as serviceTag, x as ServiceKey, y as Service } from "../index-CLspOlBH.mjs";
3
+ export { AsyncFx, AsyncFxGenerator, AsyncFxYieldable, Context, Context as ContextType, ExcludeScope, Fx, FxDefect, FxError, FxGenerator, Fx$1 as FxProtocol, Fx$1 as FxType, FxRequirements, FxSuccess, FxTypeId, FxValue, FxYield, FxYieldable, Layer, LayerError, LayerRIn, LayerROut, Layer$1 as LayerType, MemoMap, MergeError, MergeROut, RunnableFx, ScopeTag as Scope, ScopeService, Service, ServiceClass, ServiceKey, ServiceOf, ServiceRequest, SyncFx, UnprovidedDeps, createMemoMap, createScope, err, fn, gen, isFxDefect, isServiceClass, isServiceRequest, ok, provide, provideContext, provideService, run, serviceTag };
@@ -0,0 +1,4 @@
1
+ import { n as isServiceRequest, t as FxTypeId } from "../fx.types-DpIQILok.mjs";
2
+ import { _ as gen, a as createMemoMap, b as run, c as Layer, d as isServiceClass, f as serviceTag, g as fn, h as err, i as MemoMap, l as Context, m as FxDefect, n as provideContext, o as ScopeTag, p as Fx, r as provideService, s as createScope, t as provide, u as Service, v as isFxDefect, y as ok } from "../fx-B-0MxGTM.mjs";
3
+
4
+ export { Context, Fx, FxDefect, FxTypeId, Layer, MemoMap, ScopeTag as Scope, Service, createMemoMap, createScope, err, fn, gen, isFxDefect, isServiceClass, isServiceRequest, ok, provide, provideContext, provideService, run, serviceTag };