@nicolastoulemont/std 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/dist/adt/index.d.mts +1 -1
  2. package/dist/adt/index.mjs +1 -3
  3. package/dist/adt-DZmVJG4P.mjs +2 -0
  4. package/dist/adt-DZmVJG4P.mjs.map +1 -0
  5. package/dist/{apply-fn.types-0g_9eXRy.d.mts → apply-fn.types-CMgY6WQe.d.mts} +1 -1
  6. package/dist/{apply-fn.types-0g_9eXRy.d.mts.map → apply-fn.types-CMgY6WQe.d.mts.map} +1 -1
  7. package/dist/brand/index.d.mts +1 -1
  8. package/dist/brand/index.mjs +1 -3
  9. package/dist/brand-BUqMmkzC.mjs +2 -0
  10. package/dist/{brand-BqcqFXj5.mjs.map → brand-BUqMmkzC.mjs.map} +1 -1
  11. package/dist/data/index.d.mts +1 -1
  12. package/dist/data/index.mjs +1 -3
  13. package/dist/data-DzqKBCQg.mjs +2 -0
  14. package/dist/data-DzqKBCQg.mjs.map +1 -0
  15. package/dist/{discriminator.types-D-UbMmAD.d.mts → discriminator.types-DkThfvNE.d.mts} +1 -1
  16. package/dist/discriminator.types-DkThfvNE.d.mts.map +1 -0
  17. package/dist/either/index.d.mts +2 -2
  18. package/dist/either/index.mjs +1 -3
  19. package/dist/either-BDY9T5oz.mjs +2 -0
  20. package/dist/either-BDY9T5oz.mjs.map +1 -0
  21. package/dist/equality-D2EJvZm4.mjs +2 -0
  22. package/dist/{equality-C2l3BIi8.mjs.map → equality-D2EJvZm4.mjs.map} +1 -1
  23. package/dist/err/index.d.mts +1 -1
  24. package/dist/err/index.mjs +1 -3
  25. package/dist/err-CYs4b1RV.mjs +2 -0
  26. package/dist/{err-BM-svBaK.mjs.map → err-CYs4b1RV.mjs.map} +1 -1
  27. package/dist/flow/index.d.mts +1 -1
  28. package/dist/flow/index.mjs +1 -3
  29. package/dist/flow-CxKQ5yac.mjs +2 -0
  30. package/dist/{flow-D4cE0EAg.mjs.map → flow-CxKQ5yac.mjs.map} +1 -1
  31. package/dist/fx/index.d.mts +3 -3
  32. package/dist/fx/index.mjs +1 -4
  33. package/dist/fx-C4UuWCqP.mjs +2 -0
  34. package/dist/fx-C4UuWCqP.mjs.map +1 -0
  35. package/dist/fx.types-CXTwEa1G.mjs +2 -0
  36. package/dist/{fx.types-DpIQILok.mjs.map → fx.types-CXTwEa1G.mjs.map} +1 -1
  37. package/dist/{fx.types-aTmhyidu.d.mts → fx.types-DO-8yG4c.d.mts} +1 -1
  38. package/dist/{fx.types-aTmhyidu.d.mts.map → fx.types-DO-8yG4c.d.mts.map} +1 -1
  39. package/dist/{index-USQPafrR.d.mts → index-78LWwTds.d.mts} +1 -1
  40. package/dist/{index-USQPafrR.d.mts.map → index-78LWwTds.d.mts.map} +1 -1
  41. package/dist/{index-BO6bxBeo.d.mts → index-BQ5wVDSP.d.mts} +8 -24
  42. package/dist/index-BQ5wVDSP.d.mts.map +1 -0
  43. package/dist/{index-BOrJQBPO.d.mts → index-BahMvQpA.d.mts} +2 -2
  44. package/dist/{index-BOrJQBPO.d.mts.map → index-BahMvQpA.d.mts.map} +1 -1
  45. package/dist/{index-ClxPiGP9.d.mts → index-Bs5TTFlK.d.mts} +40 -44
  46. package/dist/index-Bs5TTFlK.d.mts.map +1 -0
  47. package/dist/{index-D5tzehjf.d.mts → index-BuLJRX1e.d.mts} +11 -11
  48. package/dist/{index-D5tzehjf.d.mts.map → index-BuLJRX1e.d.mts.map} +1 -1
  49. package/dist/{index-CQxzD1YM.d.mts → index-CDio8mJY.d.mts} +4 -4
  50. package/dist/{index-CQxzD1YM.d.mts.map → index-CDio8mJY.d.mts.map} +1 -1
  51. package/dist/{index-FySViSfh.d.mts → index-DLlx9jiG.d.mts} +5 -105
  52. package/dist/index-DLlx9jiG.d.mts.map +1 -0
  53. package/dist/{index-Cydt5ocm.d.mts → index-DjjJIDaA.d.mts} +2 -2
  54. package/dist/{index-Cydt5ocm.d.mts.map → index-DjjJIDaA.d.mts.map} +1 -1
  55. package/dist/{index-EmWRCTY3.d.mts → index-DtAPrec7.d.mts} +2 -2
  56. package/dist/{index-EmWRCTY3.d.mts.map → index-DtAPrec7.d.mts.map} +1 -1
  57. package/dist/{index-CLlcoy8B.d.mts → index-IdejL485.d.mts} +2 -2
  58. package/dist/{index-CLlcoy8B.d.mts.map → index-IdejL485.d.mts.map} +1 -1
  59. package/dist/{index-CLspOlBH.d.mts → index-UYodvXes.d.mts} +200 -91
  60. package/dist/index-UYodvXes.d.mts.map +1 -0
  61. package/dist/index.d.mts +16 -40
  62. package/dist/index.mjs +1 -15
  63. package/dist/option/index.d.mts +3 -3
  64. package/dist/option/index.mjs +1 -4
  65. package/dist/option-Qiv7Ls7L.mjs +2 -0
  66. package/dist/option-Qiv7Ls7L.mjs.map +1 -0
  67. package/dist/option.types-By5UOfC2.mjs +2 -0
  68. package/dist/option.types-By5UOfC2.mjs.map +1 -0
  69. package/dist/{option.types-CVvowfmd.d.mts → option.types-Cluybn30.d.mts} +22 -20
  70. package/dist/option.types-Cluybn30.d.mts.map +1 -0
  71. package/dist/pipe/index.d.mts +1 -1
  72. package/dist/pipe/index.mjs +1 -3
  73. package/dist/pipe-BROILDeC.mjs +2 -0
  74. package/dist/{pipe-BF4G4SLo.mjs.map → pipe-BROILDeC.mjs.map} +1 -1
  75. package/dist/{pipeable-Dr0d_q4F.d.mts → pipeable-KHu4D8ol.d.mts} +1 -1
  76. package/dist/{pipeable-Dr0d_q4F.d.mts.map → pipeable-KHu4D8ol.d.mts.map} +1 -1
  77. package/dist/pipeable-rQvolRqh.mjs +2 -0
  78. package/dist/{pipeable-DYNrUps7.mjs.map → pipeable-rQvolRqh.mjs.map} +1 -1
  79. package/dist/predicate/index.d.mts +1 -1
  80. package/dist/predicate/index.mjs +1 -3
  81. package/dist/predicate-DvXnfmeJ.mjs +2 -0
  82. package/dist/{predicate-Dt9Qsbav.mjs.map → predicate-DvXnfmeJ.mjs.map} +1 -1
  83. package/dist/result/index.d.mts +2 -2
  84. package/dist/result/index.mjs +1 -3
  85. package/dist/result-B68pxC7l.mjs +2 -0
  86. package/dist/result-B68pxC7l.mjs.map +1 -0
  87. package/dist/result-uRORQlAQ.mjs +1 -0
  88. package/dist/{result.types-_W95221K.d.mts → result.types-fIbuBwVQ.d.mts} +129 -20
  89. package/dist/result.types-fIbuBwVQ.d.mts.map +1 -0
  90. package/package.json +1 -1
  91. package/dist/adt-DH37Pprw.mjs +0 -318
  92. package/dist/adt-DH37Pprw.mjs.map +0 -1
  93. package/dist/brand-BqcqFXj5.mjs +0 -165
  94. package/dist/chunk-DRYujVrt.mjs +0 -18
  95. package/dist/data-Cg8ySt6-.mjs +0 -244
  96. package/dist/data-Cg8ySt6-.mjs.map +0 -1
  97. package/dist/discriminator.types-D-UbMmAD.d.mts.map +0 -1
  98. package/dist/either-jkBX8xS1.mjs +0 -735
  99. package/dist/either-jkBX8xS1.mjs.map +0 -1
  100. package/dist/equality-C2l3BIi8.mjs +0 -201
  101. package/dist/err-BM-svBaK.mjs +0 -176
  102. package/dist/flow-D4cE0EAg.mjs +0 -28
  103. package/dist/fx-B-0MxGTM.mjs +0 -1306
  104. package/dist/fx-B-0MxGTM.mjs.map +0 -1
  105. package/dist/fx.types-DpIQILok.mjs +0 -13
  106. package/dist/index-BO6bxBeo.d.mts.map +0 -1
  107. package/dist/index-CLspOlBH.d.mts.map +0 -1
  108. package/dist/index-ClxPiGP9.d.mts.map +0 -1
  109. package/dist/index-FySViSfh.d.mts.map +0 -1
  110. package/dist/index.d.mts.map +0 -1
  111. package/dist/option-C2QpGffy.mjs +0 -530
  112. package/dist/option-C2QpGffy.mjs.map +0 -1
  113. package/dist/option.types-BiAiZ8Ks.mjs +0 -33
  114. package/dist/option.types-BiAiZ8Ks.mjs.map +0 -1
  115. package/dist/option.types-CVvowfmd.d.mts.map +0 -1
  116. package/dist/pipe-BF4G4SLo.mjs +0 -10
  117. package/dist/pipeable-DYNrUps7.mjs +0 -92
  118. package/dist/predicate-Dt9Qsbav.mjs +0 -293
  119. package/dist/result-BmqdTN5o.mjs +0 -1
  120. package/dist/result-DhYA-J-M.mjs +0 -542
  121. package/dist/result-DhYA-J-M.mjs.map +0 -1
  122. package/dist/result.types-_W95221K.d.mts.map +0 -1
@@ -1,2 +1,2 @@
1
- import { _ as VariantNames, a as record, c as CodecDef, d as Infer, f as InferInput, g as ValidationError, h as RecordObject, i as data, l as CodecError, m as RecordDef, n as MatchHandlers, o as ADT, p as InferOutput, r as match, s as CodecConstraint, t as createCodecError, u as ExtractSchema, v as VariantOf } from "../index-FySViSfh.mjs";
1
+ import { _ as VariantNames, a as record, c as CodecDef, d as Infer, f as InferInput, g as ValidationError, h as RecordObject, i as data, l as CodecError, m as RecordDef, n as MatchHandlers, o as ADT, p as InferOutput, r as match, s as CodecConstraint, t as createCodecError, u as ExtractSchema, v as VariantOf } from "../index-DLlx9jiG.mjs";
2
2
  export { ADT, CodecConstraint, CodecDef, CodecError, ExtractSchema, Infer, InferInput, InferOutput, MatchHandlers, RecordDef, RecordObject, ValidationError, VariantNames, VariantOf, createCodecError, data, match, record };
@@ -1,3 +1 @@
1
- import { i as createCodecError, n as data, r as record, t as match } from "../adt-DH37Pprw.mjs";
2
-
3
- export { createCodecError, data, match, record };
1
+ import{i as e,n as t,r as n,t as r}from"../adt-DZmVJG4P.mjs";export{e as createCodecError,t as data,r as match,n as record};
@@ -0,0 +1,2 @@
1
+ import{i as e,n as t,r as n,t as r}from"./equality-D2EJvZm4.mjs";import{n as i}from"./flow-CxKQ5yac.mjs";import{f as a,r as o}from"./result-B68pxC7l.mjs";function s(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function c(e){return typeof e==`function`&&`_record`in e&&e._record===!0}function l(e){return e.issues?o({issues:e.issues.map(e=>({message:e.message,path:e.path?.map(e=>typeof e==`object`&&`key`in e?e.key:e)}))}):a(e.value)}function u(e,t,n){let r=e[`~standard`].validate(t);if(i(r))throw Error(`Async validation not supported. Schema for "${n}" returned a Promise. Use a synchronous schema or handle async validation separately.`);return l(r)}function d(e){return t=>s(t)&&`_tag`in t&&t._tag===e}function f(e){let t=new Set(e);return e=>s(e)&&`_tag`in e&&typeof e._tag==`string`&&t.has(e._tag)}function p(e,t,n,r){return n!==void 0&&r!==void 0?{kind:e,message:t,cause:n,validationIssues:r}:n===void 0?r===void 0?{kind:e,message:t}:{kind:e,message:t,validationIssues:r}:{kind:e,message:t,cause:n}}function m(e){return{to:e=>JSON.stringify(e),from:e=>{try{let t=JSON.parse(e);if(typeof t==`object`&&t&&`_tag`in t){let{_tag:e,...n}=t;return n}return t}catch{return null}}}}function h(e,t,n){let r=m(e),i={json:n=>{let i=u(t,{...n,_tag:e},e);if(i._tag===`Err`)return o(p(`ValidationError`,`Cannot encode invalid data: ${i.error.issues.map(e=>e.message).join(`, `)}`,void 0,i.error.issues));try{return a(r.to(i.value))}catch(e){return o(p(`EncodingError`,`JSON encoding failed: ${e instanceof Error?e.message:String(e)}`,e))}}};if(n)for(let[r,s]of Object.entries(n))i[r]=n=>{let i=u(t,{...n,_tag:e},e);if(i._tag===`Err`)return o(p(`ValidationError`,`Cannot encode invalid data: ${i.error.issues.map(e=>e.message).join(`, `)}`,void 0,i.error.issues));try{return a(s.to(i.value))}catch(e){return o(p(`EncodingError`,`Encoding with codec '${r}' failed: ${e instanceof Error?e.message:String(e)}`,e))}};return i}function g(e,t,n){let r=m(e),i={json:n=>{let i=r.from(n);if(i===null)return o(p(`DecodingError`,`Invalid JSON format`));let s=u(t,{...i,_tag:e},e);return s._tag===`Err`?o(p(`ValidationError`,`Decoded data failed schema validation`,void 0,s.error.issues)):a({...s.value,_tag:e})}};if(n)for(let[r,s]of Object.entries(n))i[r]=n=>{let i;try{i=s.from(n)}catch(e){return o(p(`DecodingError`,`Decoding with codec '${r}' threw an error`,e))}if(i===null)return o(p(`DecodingError`,`Codec '${r}' failed to decode input`));let c=u(t,{...i,_tag:e},e);return c._tag===`Err`?o(p(`ValidationError`,`Decoded data failed schema validation`,void 0,c.error.issues)):a({...c.value,_tag:e})};return i}function _(t,r,i){let s=d(t),c=h(t,r,i),l=g(t,r,i),f=n(t),p=e(t),m=e=>{let n=u(r,{...e,_tag:t},t);return n._tag===`Err`?o(n.error):a({...n.value,_tag:t})};return m._record=!0,m._tag=t,m.schema=r,i&&(m.codecs=i),m.is=s,m.to=c,m.from=l,m.equals=f,m.hash=p,m}function v(e,n){let i=Object.keys(n),a={};for(let[e,t]of Object.entries(n))c(t)?t._tag===e?a[e]=t:t.codecs?a[e]=_(e,t.schema,t.codecs):a[e]=_(e,t.schema):a[e]=_(e,t);return{_name:e,is:f(i),equals:r(i),hash:t(i),...a}}function y(e,t){let n=t[e._tag];return n(e)}export{p as i,v as n,_ as r,y as t};
2
+ //# sourceMappingURL=adt-DZmVJG4P.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adt-DZmVJG4P.mjs","names":["data"],"sources":["../src/shared/is-plain-object.ts","../src/adt/adt.utils.ts","../src/adt/adt.codec.ts","../src/adt/adt.record.ts","../src/adt/adt.data.ts","../src/adt/adt.match.ts"],"sourcesContent":["/**\n * Check if a value is a plain object.\n * A plain object is an object created with `{}`, `Object.create(null)`, or `new Object()`.\n * Arrays, functions, dates, maps, etc. are not considered plain objects.\n */\nexport function isPlainObject(value: unknown): value is Record<PropertyKey, unknown> {\n if (value === null || typeof value !== \"object\") {\n return false\n }\n\n const proto = Object.getPrototypeOf(value)\n return proto === null || proto === Object.prototype\n}\n","import { ok, err } from \"../result/result\"\nimport type { Result } from \"../result/result.types\"\nimport { isPlainObject } from \"../shared/is-plain-object\"\nimport { isPromise } from \"../shared/is-promise\"\nimport type { RecordObject, ValidationError } from \"./adt.types\"\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\"\n\n/**\n * Check if a value is a RecordObject created by record().\n * RecordObjects are callable functions with static properties.\n */\nexport function isRecord(value: unknown): value is RecordObject {\n return typeof value === \"function\" && \"_record\" in value && value[\"_record\"] === true\n}\n\n/**\n * Wrap Standard Schema validation result into our Result type.\n */\nfunction wrapValidationResult<T>(result: StandardSchemaV1.Result<T>): Result<T, ValidationError> {\n if (result.issues) {\n return err({\n issues: result.issues.map((issue) => ({\n message: issue.message,\n path: issue.path?.map((segment) => (typeof segment === \"object\" && \"key\" in segment ? segment.key : segment)),\n })),\n })\n }\n return ok(result.value)\n}\n\n/**\n * Validate data using a Standard Schema, enforcing sync-only validation.\n * Throws if the schema returns a Promise.\n */\nexport function validateSync<T>(\n schema: StandardSchemaV1<unknown, T>,\n data: unknown,\n _tag: string,\n): Result<T, ValidationError> {\n const result = schema[\"~standard\"].validate(data)\n\n if (isPromise(result)) {\n throw new Error(\n `Async validation not supported. Schema for \"${_tag}\" returned a Promise. ` +\n `Use a synchronous schema or handle async validation separately.`,\n )\n }\n\n return wrapValidationResult(result)\n}\n\n/**\n * Create a type guard function for a specific _tag.\n */\nexport function createIsGuard<Tag extends string, T>(\n _tag: Tag,\n): (value: unknown) => value is T & { readonly _tag: Tag } {\n return (value: unknown): value is T & { readonly _tag: Tag } => {\n return isPlainObject(value) && \"_tag\" in value && value[\"_tag\"] === _tag\n }\n}\n\n/**\n * Create a type guard function for multiple _tags (ADT root guard).\n */\nexport function createIsAnyGuard<T>(_tags: readonly string[]): (value: unknown) => value is T {\n const _tagSet = new Set(_tags)\n return (value: unknown): value is T => {\n return isPlainObject(value) && \"_tag\" in value && typeof value[\"_tag\"] === \"string\" && _tagSet.has(value[\"_tag\"])\n }\n}\n","import { ok, err } from \"../result/result\"\nimport type { Result } from \"../result/result.types\"\nimport type { Discriminator } from \"../shared/discriminator.types\"\nimport type {\n CodecConstraint,\n CodecDef,\n CodecError,\n InferInput,\n InferOutput,\n ValidationError,\n ToMethods,\n FromMethods,\n} from \"./adt.types\"\nimport { validateSync } from \"./adt.utils\"\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\"\n\n/**\n * Create a CodecError with consistent structure.\n */\nexport function createCodecError(\n kind: CodecError[\"kind\"],\n message: string,\n cause?: unknown,\n validationIssues?: ValidationError[\"issues\"],\n): CodecError {\n if (cause !== undefined && validationIssues !== undefined) {\n return { kind, message, cause, validationIssues }\n }\n if (cause !== undefined) {\n return { kind, message, cause }\n }\n if (validationIssues !== undefined) {\n return { kind, message, validationIssues }\n }\n return { kind, message }\n}\n\n/**\n * Built-in JSON codec that works with any schema.\n * Encodes to JSON string and decodes with JSON.parse.\n */\nfunction createJsonCodec<Tag extends string, S extends StandardSchemaV1>(\n _tag: Tag,\n): CodecDef<InferOutput<S> & Discriminator<Tag>, string, InferInput<S>> {\n return {\n to: (value) => {\n // JSON.stringify can throw for circular references, BigInt, etc.\n // We let it throw and catch it in the wrapper\n return JSON.stringify(value)\n },\n /* oxlint-disable no-unsafe-assignment, no-unsafe-type-assertion, no-unsafe-return -- Required for JSON parsing which returns unknown types */\n from: (input: string) => {\n try {\n const parsed = JSON.parse(input)\n // Return parsed object without _tag - it will be added during validation\n if (typeof parsed === \"object\" && parsed !== null && \"_tag\" in parsed) {\n const { _tag: _, ...rest } = parsed\n return rest as InferInput<S>\n }\n return parsed\n } catch {\n return null\n }\n },\n /* oxlint-enable no-unsafe-assignment, no-unsafe-type-assertion, no-unsafe-return */\n }\n}\n\n/**\n * Create the \"to\" methods object with JSON codec and custom codecs.\n * All methods return Result<T, CodecError> for consistent error handling.\n */\nexport function createToMethods<\n Tag extends string,\n S extends StandardSchemaV1,\n Codecs extends CodecConstraint<Tag, S> | undefined = undefined,\n>(_tag: Tag, schema: S, customCodecs?: Codecs): ToMethods<S, Codecs> {\n type Output = InferOutput<S> & Discriminator<Tag>\n\n const jsonCodec = createJsonCodec<Tag, S>(_tag)\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const to: Record<string, (value: InferInput<S>) => Result<any, CodecError>> = {\n json: (value: InferInput<S>): Result<string, CodecError> => {\n // First, create a validated record to ensure we're encoding valid data\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for spreading generic input into object\n const taggedInput = { ...(value as object), _tag }\n const result = validateSync(schema, taggedInput, _tag)\n\n if (result._tag === \"Err\") {\n return err(\n createCodecError(\n \"ValidationError\",\n `Cannot encode invalid data: ${result.error.issues.map((i) => i.message).join(\", \")}`,\n undefined,\n result.error.issues,\n ),\n )\n }\n\n try {\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for validated value cast\n return ok(jsonCodec.to(result.value as Output))\n } catch (e) {\n return err(\n createCodecError(\"EncodingError\", `JSON encoding failed: ${e instanceof Error ? e.message : String(e)}`, e),\n )\n }\n },\n }\n\n // Add custom codecs\n if (customCodecs) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n for (const [name, codec] of Object.entries(customCodecs) as Array<[string, CodecDef<Output, any, any>]>) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n to[name] = (value: InferInput<S>): Result<any, CodecError> => {\n // Validate input first\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for spreading generic input\n const taggedInput = { ...(value as object), _tag }\n const result = validateSync(schema, taggedInput, _tag)\n\n if (result._tag === \"Err\") {\n return err(\n createCodecError(\n \"ValidationError\",\n `Cannot encode invalid data: ${result.error.issues.map((i) => i.message).join(\", \")}`,\n undefined,\n result.error.issues,\n ),\n )\n }\n\n try {\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for validated value cast\n return ok(codec.to(result.value as Output))\n } catch (e) {\n return err(\n createCodecError(\n \"EncodingError\",\n `Encoding with codec '${name}' failed: ${e instanceof Error ? e.message : String(e)}`,\n e,\n ),\n )\n }\n }\n }\n }\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for generic return type\n return to as ToMethods<S, Codecs>\n}\n\n/**\n * Create the \"from\" methods object with JSON codec and custom codecs.\n * All methods return Result<T, CodecError> for consistent error handling.\n */\nexport function createFromMethods<\n Tag extends string,\n S extends StandardSchemaV1,\n Codecs extends CodecConstraint<Tag, S> | undefined = undefined,\n>(_tag: Tag, schema: S, customCodecs?: Codecs): FromMethods<Tag, S, Codecs> {\n type Output = InferOutput<S> & Discriminator<Tag>\n\n const jsonCodec = createJsonCodec<Tag, S>(_tag)\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const from: Record<string, (input: any) => Result<Output, CodecError>> = {\n json: (input: string): Result<Output, CodecError> => {\n // Decode\n const decoded = jsonCodec.from(input)\n if (decoded === null) {\n return err(createCodecError(\"DecodingError\", \"Invalid JSON format\"))\n }\n\n // Validate through schema\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for spreading decoded value\n const taggedInput = { ...(decoded as object), _tag }\n const result = validateSync(schema, taggedInput, _tag)\n\n if (result._tag === \"Err\") {\n return err(\n createCodecError(\"ValidationError\", \"Decoded data failed schema validation\", undefined, result.error.issues),\n )\n }\n\n // Ensure _tag in output\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for output construction\n const output = { ...(result.value as object), _tag } as Output\n return ok(output)\n },\n }\n\n // Add custom codecs\n if (customCodecs) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n for (const [name, codec] of Object.entries(customCodecs) as Array<[string, CodecDef<Output, any, any>]>) {\n from[name] = (input: unknown): Result<Output, CodecError> => {\n // Decode\n let decoded: unknown\n try {\n decoded = codec.from(input)\n } catch (e) {\n return err(createCodecError(\"DecodingError\", `Decoding with codec '${name}' threw an error`, e))\n }\n\n if (decoded === null) {\n return err(createCodecError(\"DecodingError\", `Codec '${name}' failed to decode input`))\n }\n\n // Validate through schema\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for spreading decoded value\n const taggedInput = { ...(decoded as object), _tag }\n const result = validateSync(schema, taggedInput, _tag)\n\n if (result._tag === \"Err\") {\n return err(\n createCodecError(\n \"ValidationError\",\n \"Decoded data failed schema validation\",\n undefined,\n result.error.issues,\n ),\n )\n }\n\n // Ensure _tag in output\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for output construction\n const output = { ...(result.value as object), _tag } as Output\n return ok(output)\n }\n }\n }\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for generic return type\n return from as FromMethods<Tag, S, Codecs>\n}\n","import { createEqualsMethod, createHashMethod } from \"../equality/equality\"\nimport { ok, err } from \"../result/result\"\nimport type { Result } from \"../result/result.types\"\nimport type { Discriminator } from \"../shared/discriminator.types\"\nimport { createToMethods, createFromMethods } from \"./adt.codec\"\nimport type { CodecConstraint, InferInput, InferOutput, RecordObject, ValidationError } from \"./adt.types\"\nimport { createIsGuard, validateSync } from \"./adt.utils\"\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\"\n\n/**\n * Create a standalone tagged record from a Standard Schema with optional codecs.\n *\n * Records can be used independently or composed into an ADT via data().\n * All defaults should be defined at the schema level (e.g., Zod's .default()).\n *\n * @template Tag - The string literal type for the _tag discriminator\n * @template S - The Standard Schema type for validation\n * @template Codecs - Optional codec definitions for custom serialization formats\n * @param _tag - The _tag discriminator value\n * @param schema - A Standard Schema compliant validator\n * @param codecs - Optional codec definitions for custom serialization formats\n * @returns A callable RecordObject with is(), to, and from methods\n *\n * @see {@link data} for composing records into discriminated unions\n * @see {@link tagged} for unvalidated tagged value constructors\n *\n * @example\n * ```ts\n * const CircleSchema = z.object({\n * radius: z.number().positive(),\n * color: z.string().default('blue')\n * })\n *\n * // Basic record with JSON codec (always included)\n * const Circle = record('Circle', CircleSchema)\n *\n * const result = Circle({ radius: 10 })\n * // { ok: true, value: { _tag: 'Circle', radius: 10, color: 'blue' } }\n *\n * Circle.is(someValue) // type guard\n *\n * const json = Circle.to.json({ radius: 10 }) // JSON string\n * const result2 = Circle.from.json(json) // Result<Circle, CodecError>\n *\n * // Record with custom codec\n * const Circle2 = record('Circle', CircleSchema, {\n * graphic: {\n * to: (circle) => `(${circle.radius})`,\n * from: (input: string) => {\n * const match = input.match(/^\\((\\d+)\\)$/)\n * return match ? { radius: parseInt(match[1]!) } : null\n * }\n * }\n * })\n *\n * const graphic = Circle2.to.graphic({ radius: 10 }) // \"(10)\"\n * const result3 = Circle2.from.graphic(\"(10)\") // Result<Circle, CodecError>\n * ```\n */\n// Overload: with codecs\nexport function record<Tag extends string, S extends StandardSchemaV1, Codecs extends CodecConstraint<Tag, S>>(\n _tag: Tag,\n schema: S,\n codecs: Codecs,\n): RecordObject<Tag, S, Codecs>\n\n// Overload: without codecs\nexport function record<Tag extends string, S extends StandardSchemaV1>(_tag: Tag, schema: S): RecordObject<Tag, S>\n\n// Implementation\nexport function record<\n Tag extends string,\n S extends StandardSchemaV1,\n Codecs extends CodecConstraint<Tag, S> | undefined,\n>(_tag: Tag, schema: S, codecs?: Codecs): RecordObject<Tag, S, Codecs> {\n type Output = InferOutput<S> & Discriminator<Tag>\n\n const isGuard = createIsGuard<Tag, Output>(_tag)\n const to = createToMethods(_tag, schema, codecs)\n const from = createFromMethods(_tag, schema, codecs)\n const equals = createEqualsMethod<Tag, InferOutput<S>>(_tag)\n const hash = createHashMethod<Tag, InferOutput<S>>(_tag)\n\n // Constructor function\n const constructor = (input: InferInput<S>): Result<Output, ValidationError> => {\n // Add _tag to the input before validation\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for spreading generic input\n const taggedInput = { ...(input as object), _tag }\n\n // Validate using the schema\n const result = validateSync(schema, taggedInput, _tag)\n\n if (result._tag === \"Err\") {\n return err(result.error)\n }\n\n // Ensure _tag is in the output (schema might strip unknown keys)\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for output construction\n const output = { ...(result.value as object), _tag } as Output\n return ok(output)\n }\n\n // Attach static properties to constructor function\n constructor._record = true as const\n constructor._tag = _tag\n constructor.schema = schema\n if (codecs) {\n // oxlint-disable-next-line no-unsafe-type-assertion -- Conditional assignment of codecs\n ;(constructor as { codecs?: Codecs }).codecs = codecs\n }\n constructor.is = isGuard\n constructor.to = to\n constructor.from = from\n constructor.equals = equals\n constructor.hash = hash\n\n return constructor as RecordObject<Tag, S, Codecs>\n}\n","import { createADTEqualsMethod, createADTHashMethod } from \"../equality/equality\"\nimport { record } from \"./adt.record\"\nimport type { ADT, RecordDef, RecordObject } from \"./adt.types\"\nimport { createIsAnyGuard, isRecord } from \"./adt.utils\"\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\"\n\n/**\n * Compose records or schemas into a discriminated union (ADT).\n *\n * Accepts either:\n * - Pre-built RecordObjects from record() (codecs are preserved)\n * - Raw Standard Schema validators (will be wrapped internally)\n *\n * When using pre-built records, the object key overrides the original _tag.\n *\n * @template R - Record of variant names to RecordObjects or StandardSchema validators\n * @param name - The name of this ADT (for identification)\n * @param records - An object mapping _tag names to RecordObjects or schemas\n * @returns An ADT object with accessors for each variant\n *\n * @see {@link record} for creating individual record types\n * @see {@link match} for exhaustive pattern matching on ADT values\n *\n * @example\n * ```ts\n * // From pre-built records\n * const Circle = record('Circle', CircleSchema)\n * const Square = record('Square', SquareSchema)\n * const Shape = data('Shape', { Circle, Square })\n *\n * // From raw schemas (JSON codec is automatically included)\n * const Shape = data('Shape', {\n * Circle: CircleSchema,\n * Square: SquareSchema\n * })\n *\n * // JSON codec works on all variants\n * Shape.Circle.to.json({ radius: 10 })\n * Shape.Circle.from.json(jsonString)\n *\n * // Mixed\n * const Shape = data('Shape', {\n * Circle, // Pre-built record\n * Square: SquareSchema // Raw schema\n * })\n *\n * // Usage\n * Shape.Circle({ radius: 10 })\n * Shape.is(someValue) // type guard for any variant\n * Shape.Circle.is(someValue) // type guard for Circle\n * ```\n */\nexport function data<R extends Record<string, RecordDef>>(name: string, records: R): ADT<R> {\n const tags = Object.keys(records)\n const variants: Record<string, RecordObject> = {}\n\n for (const [_tag, def] of Object.entries(records)) {\n if (isRecord(def)) {\n // Pre-built RecordObject - key overrides original _tag\n if (def._tag === _tag) {\n // _tag matches key, use as-is (preserves codecs)\n variants[_tag] = def\n // oxlint-disable-next-line strict-boolean-expressions -- codecs can be undefined\n } else if (def.codecs) {\n // _tag differs from key - create new record with key as _tag\n // Preserve codecs\n variants[_tag] = record(_tag, def.schema, def.codecs)\n } else {\n // _tag differs from key and no codecs\n variants[_tag] = record(_tag, def.schema)\n }\n } else {\n // Raw schema - wrap in record\n // Note: Even without custom codecs, this still gets JSON codec!\n // oxlint-disable-next-line no-unsafe-type-assertion -- def is a StandardSchemaV1 in this branch\n variants[_tag] = record(_tag, def as StandardSchemaV1)\n }\n }\n\n // Create the root type guard for any variant\n const isAnyVariant = createIsAnyGuard(tags)\n const equals = createADTEqualsMethod(tags)\n const hash = createADTHashMethod(tags)\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for generic ADT return type\n return {\n _name: name,\n is: isAnyVariant,\n equals,\n hash,\n ...variants,\n } as ADT<R>\n}\n","/**\n * Handler functions for each variant in a discriminated union.\n * Each key maps to a function that receives the variant value and returns TResult.\n *\n * @template T - The discriminated union type (must have readonly _tag)\n * @template TResult - The return type of all handlers\n */\nexport type MatchHandlers<T extends { readonly _tag: string }, TResult> = {\n [K in T[\"_tag\"]]: (value: Extract<T, { readonly _tag: K }>) => TResult\n}\n\n/**\n * Exhaustive pattern matching for discriminated unions.\n *\n * TypeScript will error if any variant is missing from handlers,\n * ensuring exhaustive handling of all cases.\n *\n * @template T - The discriminated union type (must have readonly _tag)\n * @template TResult - The return type of all handlers\n * @template Handlers - The handler object type (inferred)\n * @param value - A discriminated union value with _tag\n * @param handlers - An object with a handler function for each variant\n * @returns The result of calling the matching handler\n *\n * @see {@link data} for creating discriminated unions\n * @see {@link record} for creating individual record types\n *\n * @example\n * ```ts\n * const Shape = data('Shape', { Circle, Square })\n * type Shape = Infer<typeof Shape>\n *\n * function describeShape(shape: Shape): string {\n * return match(shape, {\n * Circle: (c) => `Circle with radius ${c.radius}`,\n * Square: (s) => `Square with size ${s.size}`,\n * })\n * }\n * ```\n */\nexport function match<\n T extends { readonly _tag: string },\n TResult,\n Handlers extends MatchHandlers<T, TResult> = MatchHandlers<T, TResult>,\n>(value: T, handlers: Handlers): TResult {\n const tag = value._tag as keyof Handlers\n const handler = handlers[tag]\n // oxlint-disable-next-line no-explicit-any, no-unsafe-argument, no-unsafe-type-assertion -- Required for variant dispatch\n return handler(value as any)\n}\n"],"mappings":"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"}
@@ -5,4 +5,4 @@ type λ<TA extends any[] = any[], TR = any> = (...args: TA) => TR;
5
5
  type ApplyFn<F extends λ, Arg> = F extends ((arg: Arg) => infer R) ? R : F extends ((arg: any) => infer R) ? R : never;
6
6
  //#endregion
7
7
  export { λ as n, ApplyFn as t };
8
- //# sourceMappingURL=apply-fn.types-0g_9eXRy.d.mts.map
8
+ //# sourceMappingURL=apply-fn.types-CMgY6WQe.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"apply-fn.types-0g_9eXRy.d.mts","names":[],"sources":["../src/shared/lambda.types.ts","../src/shared/apply-fn.types.ts"],"sourcesContent":[],"mappings":";KACY,kDAAkD,OAAO;;;ACMzD,KAAA,OAAO,CAAA,UAAW,CAAX,EAAA,GAAA,CAAA,GAAqB,CAArB,UAAA,CAAA,GAAA,EAAqC,GAArC,EAAA,GAAA,KAAA,EAAA,IAAA,CAAA,GAEf,CAFe,UAAA,CAAA,GAAA,EAAA,GAAA,EAAA,GAAA,KAAA,EAAA,IAAA,CAAA,GAAA,KAAA"}
1
+ {"version":3,"file":"apply-fn.types-CMgY6WQe.d.mts","names":[],"sources":["../src/shared/lambda.types.ts","../src/shared/apply-fn.types.ts"],"sourcesContent":[],"mappings":";KACY,kDAAkD,OAAO;;;ACMzD,KAAA,OAAO,CAAA,UAAW,CAAX,EAAA,GAAA,CAAA,GAAqB,CAArB,UAAA,CAAA,GAAA,EAAqC,GAArC,EAAA,GAAA,KAAA,EAAA,IAAA,CAAA,GAEf,CAFe,UAAA,CAAA,GAAA,EAAA,GAAA,EAAA,GAAA,KAAA,EAAA,IAAA,CAAA,GAAA,KAAA"}
@@ -1,2 +1,2 @@
1
- import { a as unsafeMake, c as BrandKey, d as Unbrand, i as refine, l as BrandRefinement, n as is, o as Brand$1, r as make, s as BrandError, t as Brand, u as Branded } from "../index-Cydt5ocm.mjs";
1
+ import { a as unsafeMake, c as BrandKey, d as Unbrand, i as refine, l as BrandRefinement, n as is, o as Brand$1, r as make, s as BrandError, t as Brand, u as Branded } from "../index-DjjJIDaA.mjs";
2
2
  export { Brand, BrandError, BrandKey, BrandRefinement, Brand$1 as BrandType, Branded, Unbrand, is, make, refine, unsafeMake };
@@ -1,3 +1 @@
1
- import { a as unsafeMake, i as refine, n as is, r as make, t as Brand } from "../brand-BqcqFXj5.mjs";
2
-
3
- export { Brand, is, make, refine, unsafeMake };
1
+ import{a as e,i as t,n,r,t as i}from"../brand-BUqMmkzC.mjs";export{i as Brand,n as is,r as make,t as refine,e as unsafeMake};
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./result-B68pxC7l.mjs";const t=e=>e,n=e=>e,r=e=>t=>e(t),i=(t,n)=>r=>{if(!t(r)){let t=typeof n==`function`?n(r):n??`Brand validation failed`;return e.err({_tag:`BrandError`,value:r,message:t})}return e.ok(r)},a={make:t,unsafeMake:n,is:r,refine:i};export{n as a,i,r as n,t as r,a as t};
2
+ //# sourceMappingURL=brand-BUqMmkzC.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"brand-BqcqFXj5.mjs","names":[],"sources":["../src/brand/brand.ts"],"sourcesContent":["import { Result } from \"../result\"\nimport type { Result as ResultType } from \"../result/result.types\"\nimport type { BrandError, Branded, Unbrand, Validator } from \"./brand.types\"\n\n/**\n * Create a branded value without validation.\n * This is a type-level cast with zero runtime cost.\n *\n * Use this when you trust the value source (e.g., from a database)\n * or when validation happens elsewhere.\n *\n * @template B - The branded type\n * @param value - The value to brand\n * @returns The value as a branded type\n *\n * @example\n * ```ts\n * type UserId = Branded<string, \"UserId\">\n *\n * // Trust the value from database\n * const userId = Brand.make<UserId>(row.id)\n *\n * // Or use in a validated factory\n * function createUserId(input: string): UserId {\n * if (!input.startsWith(\"user_\")) throw new Error(\"Invalid\")\n * return Brand.make<UserId>(input)\n * }\n * ```\n */\nexport const make = <B extends Branded<unknown, string>>(value: Unbrand<B>): B => {\n return value as B\n}\n\n/**\n * Alias for make() - explicitly indicates no validation occurs.\n * Prefer this when readability about the lack of validation is important.\n *\n * @template B - The branded type\n * @param value - The value to brand (unchecked)\n * @returns The value as a branded type\n *\n * @example\n * ```ts\n * type PositiveNumber = Branded<number, \"PositiveNumber\">\n *\n * // Explicitly unsafe - reader knows no validation\n * const n = Brand.unsafeMake<PositiveNumber>(-5) // No error, but logically wrong\n * ```\n */\nexport const unsafeMake = <B extends Branded<unknown, string>>(value: Unbrand<B>): B => {\n return value as B\n}\n\n/**\n * Create a type guard with validation for a branded type.\n * Returns a refinement predicate that narrows to the branded type.\n *\n * @template T - The base type\n * @template K - The brand key (string literal)\n * @param validator - A function that validates the base value\n * @returns A type guard that returns true if validation passes\n *\n * @example\n * ```ts\n * type PositiveNumber = Branded<number, \"PositiveNumber\">\n *\n * const isPositive = Brand.is<number, \"PositiveNumber\">(n => n > 0)\n *\n * const value: number = 42\n * if (isPositive(value)) {\n * // value is now PositiveNumber\n * acceptPositive(value) // OK\n * }\n * ```\n */\nexport const is = <T, K extends string>(validator: Validator<T>): ((value: T) => value is Branded<T, K>) => {\n return (value: T): value is Branded<T, K> => validator(value)\n}\n\n/**\n * Create a validated branded value wrapped in a Result.\n * Returns `Result.ok(brandedValue)` on success, `Result.err(BrandError)` on failure.\n *\n * The returned Result is yieldable in Do computations via `yield*`.\n *\n * @template B - The branded type\n * @param validator - A function that validates the base value\n * @param errorMessage - Optional custom error message (or function)\n * @returns A function that takes a value and returns a Result\n *\n * @example\n * ```ts\n * type Email = Branded<string, \"Email\">\n *\n * const parseEmail = Brand.refine<Email>(\n * s => s.includes(\"@\"),\n * (v) => `Invalid email: ${v}`\n * )\n *\n * // Basic usage\n * const result = parseEmail(\"user@example.com\")\n * // { ok: true, value: \"user@example.com\" }\n *\n * const bad = parseEmail(\"not-an-email\")\n * // { ok: false, error: { _tag: \"BrandError\", value: \"not-an-email\", message: \"...\" } }\n *\n * // With Do computation\n * const computation = Fx.gen(function* () {\n * const email = yield* parseEmail(input)\n * return email\n * })\n *\n * // With pipe\n * pipe(\n * userInput,\n * parseEmail,\n * Result.map(email => sendTo(email)),\n * Result.unwrapOr(defaultEmail)\n * )\n * ```\n */\nexport const refine = <B extends Branded<unknown, string>>(\n validator: Validator<Unbrand<B>>,\n errorMessage?: string | ((value: Unbrand<B>) => string),\n): ((value: Unbrand<B>) => ResultType<B, BrandError<Unbrand<B>>>) => {\n return (value: Unbrand<B>) => {\n if (!validator(value)) {\n const msg = typeof errorMessage === \"function\" ? errorMessage(value) : (errorMessage ?? \"Brand validation failed\")\n return Result.err({ _tag: \"BrandError\" as const, value, message: msg })\n }\n return Result.ok(value as B)\n }\n}\n\n/**\n * Brand namespace containing utilities for nominal typing in TypeScript.\n *\n * Brand types add type-level distinctiveness to primitive types without\n * any runtime overhead. This prevents accidental mixing of semantically\n * different values that share the same structural type.\n *\n * @example\n * ```ts\n * import { Brand } from \"@repo/std\"\n * import type { Branded } from \"@repo/std\"\n *\n * // Define branded types\n * type UserId = Branded<string, \"UserId\">\n * type Email = Branded<string, \"Email\">\n *\n * // Create values\n * const userId = Brand.make<UserId>(\"user-123\")\n * const isValidEmail = Brand.is<Email>(s => s.includes(\"@\"))\n *\n * // Type safety\n * function sendEmail(email: Email) { ... }\n * sendEmail(userId) // Type error! UserId is not Email\n * ```\n */\nexport const Brand = {\n make,\n unsafeMake,\n is,\n refine,\n} as const\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,QAA4C,UAAyB;AAChF,QAAO;;;;;;;;;;;;;;;;;;AAmBT,MAAa,cAAkD,UAAyB;AACtF,QAAO;;;;;;;;;;;;;;;;;;;;;;;;AAyBT,MAAa,MAA2B,cAAoE;AAC1G,SAAQ,UAAqC,UAAU,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6C/D,MAAa,UACX,WACA,iBACmE;AACnE,SAAQ,UAAsB;AAC5B,MAAI,CAAC,UAAU,MAAM,EAAE;GACrB,MAAM,MAAM,OAAO,iBAAiB,aAAa,aAAa,MAAM,GAAI,gBAAgB;AACxF,UAAO,OAAO,IAAI;IAAE,MAAM;IAAuB;IAAO,SAAS;IAAK,CAAC;;AAEzE,SAAO,OAAO,GAAG,MAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BhC,MAAa,QAAQ;CACnB;CACA;CACA;CACA;CACD"}
1
+ {"version":3,"file":"brand-BUqMmkzC.mjs","names":[],"sources":["../src/brand/brand.ts"],"sourcesContent":["import { Result } from \"../result\"\nimport type { Result as ResultType } from \"../result/result.types\"\nimport type { BrandError, Branded, Unbrand, Validator } from \"./brand.types\"\n\n/**\n * Create a branded value without validation.\n * This is a type-level cast with zero runtime cost.\n *\n * Use this when you trust the value source (e.g., from a database)\n * or when validation happens elsewhere.\n *\n * @template B - The branded type\n * @param value - The value to brand\n * @returns The value as a branded type\n *\n * @example\n * ```ts\n * type UserId = Branded<string, \"UserId\">\n *\n * // Trust the value from database\n * const userId = Brand.make<UserId>(row.id)\n *\n * // Or use in a validated factory\n * function createUserId(input: string): UserId {\n * if (!input.startsWith(\"user_\")) throw new Error(\"Invalid\")\n * return Brand.make<UserId>(input)\n * }\n * ```\n */\nexport const make = <B extends Branded<unknown, string>>(value: Unbrand<B>): B => {\n return value as B\n}\n\n/**\n * Alias for make() - explicitly indicates no validation occurs.\n * Prefer this when readability about the lack of validation is important.\n *\n * @template B - The branded type\n * @param value - The value to brand (unchecked)\n * @returns The value as a branded type\n *\n * @example\n * ```ts\n * type PositiveNumber = Branded<number, \"PositiveNumber\">\n *\n * // Explicitly unsafe - reader knows no validation\n * const n = Brand.unsafeMake<PositiveNumber>(-5) // No error, but logically wrong\n * ```\n */\nexport const unsafeMake = <B extends Branded<unknown, string>>(value: Unbrand<B>): B => {\n return value as B\n}\n\n/**\n * Create a type guard with validation for a branded type.\n * Returns a refinement predicate that narrows to the branded type.\n *\n * @template T - The base type\n * @template K - The brand key (string literal)\n * @param validator - A function that validates the base value\n * @returns A type guard that returns true if validation passes\n *\n * @example\n * ```ts\n * type PositiveNumber = Branded<number, \"PositiveNumber\">\n *\n * const isPositive = Brand.is<number, \"PositiveNumber\">(n => n > 0)\n *\n * const value: number = 42\n * if (isPositive(value)) {\n * // value is now PositiveNumber\n * acceptPositive(value) // OK\n * }\n * ```\n */\nexport const is = <T, K extends string>(validator: Validator<T>): ((value: T) => value is Branded<T, K>) => {\n return (value: T): value is Branded<T, K> => validator(value)\n}\n\n/**\n * Create a validated branded value wrapped in a Result.\n * Returns `Result.ok(brandedValue)` on success, `Result.err(BrandError)` on failure.\n *\n * The returned Result is yieldable in Do computations via `yield*`.\n *\n * @template B - The branded type\n * @param validator - A function that validates the base value\n * @param errorMessage - Optional custom error message (or function)\n * @returns A function that takes a value and returns a Result\n *\n * @example\n * ```ts\n * type Email = Branded<string, \"Email\">\n *\n * const parseEmail = Brand.refine<Email>(\n * s => s.includes(\"@\"),\n * (v) => `Invalid email: ${v}`\n * )\n *\n * // Basic usage\n * const result = parseEmail(\"user@example.com\")\n * // { ok: true, value: \"user@example.com\" }\n *\n * const bad = parseEmail(\"not-an-email\")\n * // { ok: false, error: { _tag: \"BrandError\", value: \"not-an-email\", message: \"...\" } }\n *\n * // With Do computation\n * const computation = Fx.gen(function* () {\n * const email = yield* parseEmail(input)\n * return email\n * })\n *\n * // With pipe\n * pipe(\n * userInput,\n * parseEmail,\n * Result.map(email => sendTo(email)),\n * Result.unwrapOr(defaultEmail)\n * )\n * ```\n */\nexport const refine = <B extends Branded<unknown, string>>(\n validator: Validator<Unbrand<B>>,\n errorMessage?: string | ((value: Unbrand<B>) => string),\n): ((value: Unbrand<B>) => ResultType<B, BrandError<Unbrand<B>>>) => {\n return (value: Unbrand<B>) => {\n if (!validator(value)) {\n const msg = typeof errorMessage === \"function\" ? errorMessage(value) : (errorMessage ?? \"Brand validation failed\")\n return Result.err({ _tag: \"BrandError\" as const, value, message: msg })\n }\n return Result.ok(value as B)\n }\n}\n\n/**\n * Brand namespace containing utilities for nominal typing in TypeScript.\n *\n * Brand types add type-level distinctiveness to primitive types without\n * any runtime overhead. This prevents accidental mixing of semantically\n * different values that share the same structural type.\n *\n * @example\n * ```ts\n * import { Brand } from \"@repo/std\"\n * import type { Branded } from \"@repo/std\"\n *\n * // Define branded types\n * type UserId = Branded<string, \"UserId\">\n * type Email = Branded<string, \"Email\">\n *\n * // Create values\n * const userId = Brand.make<UserId>(\"user-123\")\n * const isValidEmail = Brand.is<Email>(s => s.includes(\"@\"))\n *\n * // Type safety\n * function sendEmail(email: Email) { ... }\n * sendEmail(userId) // Type error! UserId is not Email\n * ```\n */\nexport const Brand = {\n make,\n unsafeMake,\n is,\n refine,\n} as const\n"],"mappings":"0CA6BA,MAAa,EAA4C,GAChD,EAmBI,EAAkD,GACtD,EAyBI,EAA2B,GAC9B,GAAqC,EAAU,EAAM,CA6ClD,GACX,EACA,IAEQ,GAAsB,CAC5B,GAAI,CAAC,EAAU,EAAM,CAAE,CACrB,IAAM,EAAM,OAAO,GAAiB,WAAa,EAAa,EAAM,CAAI,GAAgB,0BACxF,OAAO,EAAO,IAAI,CAAE,KAAM,aAAuB,QAAO,QAAS,EAAK,CAAC,CAEzE,OAAO,EAAO,GAAG,EAAW,EA6BnB,EAAQ,CACnB,OACA,aACA,KACA,SACD"}
@@ -1,2 +1,2 @@
1
- import { a as ArrayValue, c as TaggedValue, i as tagged, l as TupleValue, n as tuple, o as StructValue, r as struct, s as TaggedConstructor, t as array } from "../index-EmWRCTY3.mjs";
1
+ import { a as ArrayValue, c as TaggedValue, i as tagged, l as TupleValue, n as tuple, o as StructValue, r as struct, s as TaggedConstructor, t as array } from "../index-DtAPrec7.mjs";
2
2
  export { ArrayValue, StructValue, TaggedConstructor, TaggedValue, TupleValue, array, struct, tagged, tuple };
@@ -1,3 +1 @@
1
- import { i as tagged, n as tuple, r as struct, t as array } from "../data-Cg8ySt6-.mjs";
2
-
3
- export { array, struct, tagged, tuple };
1
+ import{i as e,n as t,r as n,t as r}from"../data-DzqKBCQg.mjs";export{r as array,n as struct,e as tagged,t as tuple};
@@ -0,0 +1,2 @@
1
+ import{a as e,i as t,o as n,r}from"./equality-D2EJvZm4.mjs";function i(e){let n=t=>Object.freeze({...t,_tag:e});return n.is=t=>typeof t==`object`&&!!t&&`_tag`in t&&t._tag===e,n.equals=r(e),n.hash=t(e),n._tag=e,n}const a={enumerable:!1,writable:!1,configurable:!1};function o(t){let r={...t};return Object.defineProperty(r,`equals`,{value:t=>e(r,t),...a}),Object.defineProperty(r,`hash`,{value:()=>n(r),...a}),Object.freeze(r)}function s(...t){let r=[...t];return Object.defineProperty(r,`equals`,{value:t=>e(r,t),...a}),Object.defineProperty(r,`hash`,{value:()=>n(r),...a}),Object.freeze(r)}function c(t){let r=[...t];Object.defineProperty(r,`equals`,{value:t=>e(r,t),...a}),Object.defineProperty(r,`hash`,{value:()=>n(r),...a});let i=r.map.bind(r);Object.defineProperty(r,`map`,{value:e=>c(i(e)),...a});let o=r.filter.bind(r);Object.defineProperty(r,`filter`,{value:e=>c(o(e)),...a});let s=r.slice.bind(r);Object.defineProperty(r,`slice`,{value:(e,t)=>c(s(e,t)),...a});let l=r.concat.bind(r);return Object.defineProperty(r,`concat`,{value:(...e)=>c(l(...e)),...a}),Object.freeze(r)}export{i,s as n,o as r,c as t};
2
+ //# sourceMappingURL=data-DzqKBCQg.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-DzqKBCQg.mjs","names":[],"sources":["../src/data/data.tagged.ts","../src/data/data.utils.ts","../src/data/data.struct.ts","../src/data/data.tuple.ts","../src/data/data.array.ts"],"sourcesContent":["import { createEqualsMethod, createHashMethod } from \"../equality/equality\"\nimport type { Discriminator } from \"../shared/discriminator.types\"\nimport type { TaggedConstructor, TaggedValue } from \"./data.types\"\n\n/**\n * Create a tagged value constructor without schema validation.\n *\n * Unlike record(), this creates values directly without validation.\n * Values are frozen and have structural equality via equals() and hash() methods.\n *\n * @template T - The data shape type (excluding _tag)\n * @param tag - The _tag discriminator value\n * @returns A constructor function with is(), equals(), and hash() methods\n *\n * @see {@link record} for validated records with schema support\n * @see {@link struct} for untagged value objects\n *\n * @example\n * ```ts\n * const Person = tagged<{ name: string; age: number }>(\"Person\")\n *\n * const alice = Person({ name: \"Alice\", age: 30 })\n * // => { _tag: \"Person\", name: \"Alice\", age: 30 }\n *\n * Person.equals(alice, Person({ name: \"Alice\", age: 30 })) // true\n * Person.is(alice) // true\n *\n * // Type guard usage\n * if (Person.is(unknownValue)) {\n * console.log(unknownValue.name) // TypeScript knows it's a Person\n * }\n *\n * // Values are frozen (immutable)\n * alice.name = \"Bob\" // TypeError\n * ```\n */\nexport function tagged<T extends Record<string, unknown>>(tag: string): TaggedConstructor<typeof tag, T> {\n type Output = TaggedValue<typeof tag, T>\n\n // Constructor function\n const constructor = (input: T): Output => {\n return Object.freeze({ ...input, _tag: tag }) as Output\n }\n\n // Type guard\n constructor.is = (value: unknown): value is Output => {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"_tag\" in value &&\n // oxlint-disable-next-line no-unsafe-type-assertion -- Already checked with 'in' operator\n (value as Discriminator)._tag === tag\n )\n }\n\n // Equality (static method on constructor)\n constructor.equals = createEqualsMethod<typeof tag, T>(tag)\n\n // Hashing (static method on constructor)\n constructor.hash = createHashMethod<typeof tag, T>(tag)\n\n // Store tag for reflection\n constructor._tag = tag\n\n return constructor as TaggedConstructor<typeof tag, T>\n}\n","export const nonEnumerablePropertiesDescriptors = {\n enumerable: false,\n writable: false,\n configurable: false,\n} as const\n","import { deepEquals, deepHash } from \"../equality/equality\"\nimport type { StructValue } from \"./data.types\"\nimport { nonEnumerablePropertiesDescriptors } from \"./data.utils\"\n\n/**\n * Create a frozen value object with structural equality.\n *\n * Unlike tagged(), struct() does not add a _tag discriminator.\n * Use this for simple value objects that don't need discrimination.\n *\n * The returned object is frozen (immutable) and has non-enumerable\n * equals() and hash() methods for structural comparison.\n *\n * @template T - The object shape type\n * @param input - The object to wrap\n * @returns A frozen object with equals() and hash() methods\n *\n * @see {@link tagged} for discriminated value objects with _tag\n * @see {@link array} for array value types\n *\n * @example\n * ```ts\n * const point = struct({ x: 10, y: 20 })\n * const point2 = struct({ x: 10, y: 20 })\n *\n * point.equals(point2) // true\n * point.hash() // number\n *\n * // Object is frozen\n * point.x = 5 // TypeError\n *\n * // equals/hash are non-enumerable\n * Object.keys(point) // [\"x\", \"y\"]\n * ```\n */\nexport function struct<T extends Record<string, unknown>>(input: T): StructValue<T> {\n const value = { ...input }\n\n // Add equals method (non-enumerable)\n Object.defineProperty(value, \"equals\", {\n value: (other: T) => deepEquals(value, other),\n ...nonEnumerablePropertiesDescriptors,\n })\n\n // Add hash method (non-enumerable)\n Object.defineProperty(value, \"hash\", {\n value: () => deepHash(value),\n ...nonEnumerablePropertiesDescriptors,\n })\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for generic struct return type\n return Object.freeze(value) as StructValue<T>\n}\n","import { deepEquals, deepHash } from \"../equality/equality\"\nimport type { TupleValue } from \"./data.types\"\nimport { nonEnumerablePropertiesDescriptors } from \"./data.utils\"\n\n/**\n * Create a tuple with structural equality.\n *\n * The returned tuple is frozen (immutable) and has non-enumerable\n * equals() and hash() methods for structural comparison.\n *\n * @template T - The tuple type as a readonly array of element types\n * @param args - The tuple elements\n * @returns A frozen tuple-like array with equals() and hash() methods\n *\n * @see {@link array} for variable-length arrays with equality\n * @see {@link struct} for object value types\n *\n * @example\n * ```ts\n * const t1 = tuple(1, \"hello\", true)\n * const t2 = tuple(1, \"hello\", true)\n *\n * t1.equals(t2) // true\n * t1.hash() // number\n *\n * // Access elements (typed)\n * t1[0] // number\n * t1[1] // string\n * t1[2] // boolean\n *\n * // Tuple is frozen\n * t1[0] = 5 // TypeError\n * ```\n */\nexport function tuple<T extends readonly unknown[]>(...args: T): TupleValue<T> {\n const value = [...args]\n\n // Add equals method (non-enumerable)\n Object.defineProperty(value, \"equals\", {\n value: (other: readonly unknown[]) => deepEquals(value, other),\n ...nonEnumerablePropertiesDescriptors,\n })\n\n // Add hash method (non-enumerable)\n Object.defineProperty(value, \"hash\", {\n value: () => deepHash(value),\n ...nonEnumerablePropertiesDescriptors,\n })\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for generic tuple return type\n return Object.freeze(value) as unknown as TupleValue<T>\n}\n","import { deepEquals, deepHash } from \"../equality/equality\"\nimport type { ArrayValue } from \"./data.types\"\nimport { nonEnumerablePropertiesDescriptors } from \"./data.utils\"\n\n/**\n * Create an array with structural equality.\n *\n * The returned array is frozen (immutable) and has non-enumerable\n * equals() and hash() methods for structural comparison.\n *\n * The map() and filter() methods are overridden to return ArrayValue,\n * enabling method chaining with preserved equality semantics.\n *\n * @template T - The element type of the array\n * @param items - The array elements\n * @returns A frozen array with equals(), hash(), map(), and filter()\n *\n * @see {@link tuple} for fixed-length typed tuples\n * @see {@link struct} for object value types\n *\n * @example\n * ```ts\n * const arr1 = array([1, 2, 3])\n * const arr2 = array([1, 2, 3])\n *\n * arr1.equals(arr2) // true\n * arr1.hash() // number\n *\n * // Chainable operations return ArrayValue\n * arr1.map(x => x * 2) // ArrayValue<number>\n * arr1.filter(x => x > 1) // ArrayValue<number>\n *\n * // Chained equality check\n * arr1.map(x => x * 2).equals(array([2, 4, 6])) // true\n *\n * // Array is frozen\n * arr1[0] = 5 // TypeError\n * arr1.push(4) // TypeError\n * ```\n */\nexport function array<T>(items: readonly T[]): ArrayValue<T> {\n const value = [...items]\n\n // Add equals method (non-enumerable)\n Object.defineProperty(value, \"equals\", {\n value: (other: readonly T[]) => deepEquals(value, other),\n ...nonEnumerablePropertiesDescriptors,\n })\n\n // Add hash method (non-enumerable)\n Object.defineProperty(value, \"hash\", {\n value: () => deepHash(value),\n ...nonEnumerablePropertiesDescriptors,\n })\n\n // Override map to return ArrayValue\n const originalMap = value.map.bind(value)\n Object.defineProperty(value, \"map\", {\n value: <U>(fn: (item: T, index: number, arr: readonly T[]) => U): ArrayValue<U> => {\n return array(originalMap(fn))\n },\n ...nonEnumerablePropertiesDescriptors,\n })\n\n // Override filter to return ArrayValue\n const originalFilter = value.filter.bind(value)\n Object.defineProperty(value, \"filter\", {\n value: (fn: (item: T, index: number, arr: readonly T[]) => boolean): ArrayValue<T> => {\n return array(originalFilter(fn))\n },\n ...nonEnumerablePropertiesDescriptors,\n })\n\n // Override slice to return ArrayValue\n const originalSlice = value.slice.bind(value)\n Object.defineProperty(value, \"slice\", {\n value: (start?: number, end?: number): ArrayValue<T> => {\n return array(originalSlice(start, end))\n },\n ...nonEnumerablePropertiesDescriptors,\n })\n\n // Override concat to return ArrayValue\n const originalConcat = value.concat.bind(value)\n Object.defineProperty(value, \"concat\", {\n value: (...args: readonly (T | readonly T[])[]): ArrayValue<T> => {\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for concat argument spread\n return array(originalConcat(...(args as T[][])))\n },\n ...nonEnumerablePropertiesDescriptors,\n })\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- Required for generic array return type\n return Object.freeze(value) as unknown as ArrayValue<T>\n}\n"],"mappings":"4DAoCA,SAAgB,EAA0C,EAA+C,CAIvG,IAAM,EAAe,GACZ,OAAO,OAAO,CAAE,GAAG,EAAO,KAAM,EAAK,CAAC,CAuB/C,MAnBA,GAAY,GAAM,GAEd,OAAO,GAAU,YACjB,GACA,SAAU,GAET,EAAwB,OAAS,EAKtC,EAAY,OAAS,EAAkC,EAAI,CAG3D,EAAY,KAAO,EAAgC,EAAI,CAGvD,EAAY,KAAO,EAEZ,EChET,MAAa,EAAqC,CAChD,WAAY,GACZ,SAAU,GACV,aAAc,GACf,CC+BD,SAAgB,EAA0C,EAA0B,CAClF,IAAM,EAAQ,CAAE,GAAG,EAAO,CAe1B,OAZA,OAAO,eAAe,EAAO,SAAU,CACrC,MAAQ,GAAa,EAAW,EAAO,EAAM,CAC7C,GAAG,EACJ,CAAC,CAGF,OAAO,eAAe,EAAO,OAAQ,CACnC,UAAa,EAAS,EAAM,CAC5B,GAAG,EACJ,CAAC,CAGK,OAAO,OAAO,EAAM,CCjB7B,SAAgB,EAAoC,GAAG,EAAwB,CAC7E,IAAM,EAAQ,CAAC,GAAG,EAAK,CAevB,OAZA,OAAO,eAAe,EAAO,SAAU,CACrC,MAAQ,GAA8B,EAAW,EAAO,EAAM,CAC9D,GAAG,EACJ,CAAC,CAGF,OAAO,eAAe,EAAO,OAAQ,CACnC,UAAa,EAAS,EAAM,CAC5B,GAAG,EACJ,CAAC,CAGK,OAAO,OAAO,EAAM,CCV7B,SAAgB,EAAS,EAAoC,CAC3D,IAAM,EAAQ,CAAC,GAAG,EAAM,CAGxB,OAAO,eAAe,EAAO,SAAU,CACrC,MAAQ,GAAwB,EAAW,EAAO,EAAM,CACxD,GAAG,EACJ,CAAC,CAGF,OAAO,eAAe,EAAO,OAAQ,CACnC,UAAa,EAAS,EAAM,CAC5B,GAAG,EACJ,CAAC,CAGF,IAAM,EAAc,EAAM,IAAI,KAAK,EAAM,CACzC,OAAO,eAAe,EAAO,MAAO,CAClC,MAAW,GACF,EAAM,EAAY,EAAG,CAAC,CAE/B,GAAG,EACJ,CAAC,CAGF,IAAM,EAAiB,EAAM,OAAO,KAAK,EAAM,CAC/C,OAAO,eAAe,EAAO,SAAU,CACrC,MAAQ,GACC,EAAM,EAAe,EAAG,CAAC,CAElC,GAAG,EACJ,CAAC,CAGF,IAAM,EAAgB,EAAM,MAAM,KAAK,EAAM,CAC7C,OAAO,eAAe,EAAO,QAAS,CACpC,OAAQ,EAAgB,IACf,EAAM,EAAc,EAAO,EAAI,CAAC,CAEzC,GAAG,EACJ,CAAC,CAGF,IAAM,EAAiB,EAAM,OAAO,KAAK,EAAM,CAU/C,OATA,OAAO,eAAe,EAAO,SAAU,CACrC,OAAQ,GAAG,IAEF,EAAM,EAAe,GAAI,EAAe,CAAC,CAElD,GAAG,EACJ,CAAC,CAGK,OAAO,OAAO,EAAM"}
@@ -4,4 +4,4 @@ type Discriminator<Tag extends string = string> = {
4
4
  };
5
5
  //#endregion
6
6
  export { Discriminator as t };
7
- //# sourceMappingURL=discriminator.types-D-UbMmAD.d.mts.map
7
+ //# sourceMappingURL=discriminator.types-DkThfvNE.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discriminator.types-DkThfvNE.d.mts","names":[],"sources":["../src/shared/discriminator.types.ts"],"sourcesContent":[],"mappings":";KAAY;EAAA,SAAA,IAAA,EAA8D,GAAjD"}
@@ -1,2 +1,2 @@
1
- import { A as FlatMapReturn, C as unwrapOr, D as BimapReturn, E as AllObjectReturn, F as RightValue, I as TapReturn, M as MapLeftReturn, N as MapReturn, O as Either$1, P as OrElseReturn, S as toResult, T as AllArrayReturn, _ as right, a as flatMap, b as tapLeft, c as fromPredicate, d as isRight, f as left, g as orElse, h as match, i as filter, j as LeftValue, k as FilterReturn, l as fromResult, m as mapLeft, n as all, o as fromNullable, p as map, r as bimap, s as fromOption, t as Either, u as isLeft, v as swap, w as unwrapOrElse, x as toOption, y as tap } from "../index-ClxPiGP9.mjs";
2
- export { AllArrayReturn, AllObjectReturn, BimapReturn, Either, Either$1 as EitherType, FilterReturn, FlatMapReturn, LeftValue, MapLeftReturn, MapReturn, OrElseReturn, RightValue, TapReturn, all, bimap, filter, flatMap, fromNullable, fromOption, fromPredicate, fromResult, isLeft, isRight, left, map, mapLeft, match, orElse, right, swap, tap, tapLeft, toOption, toResult, unwrapOr, unwrapOrElse };
1
+ import { A as FlatMapReturn, C as unwrapOr, D as BimapReturn, E as AllObjectReturn, F as OrElseReturn, I as Right, L as RightValue, M as LeftValue, N as MapLeftReturn, O as Either$1, P as MapReturn, R as TapReturn, S as toResult, T as AllArrayReturn, _ as right, a as flatMap, b as tapLeft, c as fromPredicate, d as isRight, f as left, g as orElse, h as match, i as filter, j as Left, k as FilterReturn, l as fromResult, m as mapLeft, n as all, o as fromNullable, p as map, r as bimap, s as fromOption, t as Either, u as isLeft, v as swap, w as unwrapOrElse, x as toOption, y as tap } from "../index-Bs5TTFlK.mjs";
2
+ export { AllArrayReturn, AllObjectReturn, BimapReturn, Either, Either$1 as EitherType, FilterReturn, FlatMapReturn, Left, LeftValue, MapLeftReturn, MapReturn, OrElseReturn, Right, RightValue, TapReturn, all, bimap, filter, flatMap, fromNullable, fromOption, fromPredicate, fromResult, isLeft, isRight, left, map, mapLeft, match, orElse, right, swap, tap, tapLeft, toOption, toResult, unwrapOr, unwrapOrElse };
@@ -1,3 +1 @@
1
- import { C as unwrapOr, S as toResult, _ as right, a as flatMap, b as tapLeft, c as fromPredicate, d as isRight, f as left, g as orElse, h as match, i as filter, l as fromResult, m as mapLeft, n as all, o as fromNullable, p as map, r as bimap, s as fromOption, t as Either, u as isLeft, v as swap, w as unwrapOrElse, x as toOption, y as tap } from "../either-jkBX8xS1.mjs";
2
-
3
- export { Either, all, bimap, filter, flatMap, fromNullable, fromOption, fromPredicate, fromResult, isLeft, isRight, left, map, mapLeft, match, orElse, right, swap, tap, tapLeft, toOption, toResult, unwrapOr, unwrapOrElse };
1
+ import{C as e,S as t,_ as n,a as r,b as i,c as a,d as o,f as s,g as c,h as l,i as u,l as d,m as f,n as p,o as m,p as h,r as g,s as _,t as v,u as y,v as b,w as x,x as S,y as C}from"../either-BDY9T5oz.mjs";export{v as Either,p as all,g as bimap,u as filter,r as flatMap,m as fromNullable,_ as fromOption,a as fromPredicate,d as fromResult,y as isLeft,o as isRight,s as left,h as map,f as mapLeft,l as match,c as orElse,n as right,b as swap,C as tap,i as tapLeft,S as toOption,t as toResult,e as unwrapOr,x as unwrapOrElse};
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./fx.types-CXTwEa1G.mjs";import{n as t,t as n}from"./pipeable-rQvolRqh.mjs";import{t as r}from"./result-B68pxC7l.mjs";import{t as i}from"./option-Qiv7Ls7L.mjs";const a=t=>({_tag:`Right`,value:t,[e]:{_A:()=>t,_E:()=>void 0,_R:()=>void 0},pipe:n,*[Symbol.iterator](){return t}}),o=t=>({_tag:`Left`,value:t,[e]:{_A:()=>t,_E:()=>void 0,_R:()=>void 0},pipe:n,*[Symbol.iterator](){return t}}),s=e=>e._tag===`Right`,c=e=>e._tag===`Left`,l=t(2,(e,t)=>{if(e._tag===`Left`)return e;let n=t(e.value);return n instanceof Promise?n.then(a):a(n)}),u=t(2,(e,t)=>{if(e._tag===`Right`)return e;let n=t(e.value);return n instanceof Promise?n.then(o):o(n)}),d=t(3,(e,t,n)=>{if(e._tag===`Right`){let t=n(e.value);return t instanceof Promise?t.then(a):a(t)}let r=t(e.value);return r instanceof Promise?r.then(o):o(r)}),f=t(2,(e,t)=>e._tag===`Left`?e:t(e.value)),p=t(2,(e,t)=>{if(e._tag===`Left`)return e;let n=t(e.value);return n instanceof Promise?n.then(()=>e):e}),m=t(2,(e,t)=>{if(e._tag===`Right`)return e;let n=t(e.value);return n instanceof Promise?n.then(()=>e):e}),h=t(2,(e,t)=>e._tag===`Right`?e:t(e.value)),g=()=>e=>e._tag===`Left`?a(e.value):o(e.value),_=t(3,(e,t,n)=>e._tag===`Left`||t(e.value)?e:o(n(e.value))),v=e=>{if(Array.isArray(e)){let t=[];for(let n of e){if(n._tag===`Left`)return n;t.push(n.value)}return a(t)}let t={};for(let n in e){let r=e[n];if(r._tag===`Left`)return r;t[n]=r.value}return a(t)},y=t(2,(e,t)=>e._tag===`Right`?e.value:t),b=t(2,(e,t)=>e._tag===`Right`?e.value:t(e.value)),x=t(2,(e,t)=>e._tag===`Right`?t.Right(e.value):t.Left(e.value)),S=e=>e._tag===`Ok`?a(e.value):o(e.error),C=e=>e._tag===`Right`?r.ok(e.value):r.err(e.value),w=(e,t)=>e._tag===`Some`?a(e.value):o(t()),T=e=>e._tag===`Right`?i.some(e.value):i.none(),E=(e,t)=>e==null?o(t()):a(e),D=(e,t,n)=>t(e)?a(e):o(n(e)),O={left:o,right:a,isLeft:c,isRight:s,map:l,mapLeft:u,bimap:d,flatMap:f,tap:p,tapLeft:m,orElse:h,swap:g,filter:_,all:v,unwrapOr:y,unwrapOrElse:b,match:x,fromResult:S,toResult:C,fromOption:w,toOption:T,fromNullable:E,fromPredicate:D};export{y as C,C as S,a as _,f as a,m as b,D as c,s as d,o as f,h as g,x as h,_ as i,S as l,u as m,v as n,E as o,l as p,d as r,w as s,O as t,c as u,g as v,b as w,T as x,p as y};
2
+ //# sourceMappingURL=either-BDY9T5oz.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"either-BDY9T5oz.mjs","names":["mapped"],"sources":["../src/either/either.ts"],"sourcesContent":["import { FxTypeId } from \"../fx/fx.types\"\nimport { Option } from \"../option\"\nimport type { Option as OptionType } from \"../option/option.types\"\nimport { Result } from \"../result\"\nimport type { Result as ResultType } from \"../result/result.types\"\nimport { dual } from \"../shared/dual\"\nimport { pipeMethod } from \"../shared/pipeable\"\nimport type {\n Either as EitherType,\n EitherAll,\n EitherBimap,\n EitherFilter,\n EitherFlatMap,\n EitherMap,\n EitherMapLeft,\n EitherMatch,\n EitherOrElse,\n EitherTap,\n EitherTapLeft,\n EitherUnwrapOr,\n EitherUnwrapOrElse,\n} from \"./either.types\"\n\n// ============================================================================\n// Constructors\n// ============================================================================\n\n/**\n * Create a right Either value (success/preferred path).\n *\n * By convention, right represents the correct/preferred outcome.\n * In Fx.gen(), this returns the value without short-circuiting.\n *\n * @param value - The right value\n * @returns An Either in the right state\n *\n * @example\n * ```ts\n * const result = right(42)\n * // => { right: true, value: 42 }\n *\n * // In Fx.gen() - never short-circuits\n * const fx = Fx.gen(function* () {\n * const a = yield* Either.right(10) // Returns 10\n * return a * 2 // Executes, returns 20\n * })\n * ```\n */\nexport const right = <R, L = never>(value: R): EitherType<L, R> => ({\n _tag: \"Right\",\n value,\n [FxTypeId]: {\n _A: () => value as L | R,\n _E: () => undefined as never,\n _R: () => undefined as never,\n },\n pipe: pipeMethod,\n // oxlint-disable-next-line require-yield\n *[Symbol.iterator](): Generator<never, R, unknown> {\n return value\n },\n})\n\n/**\n * Create a left Either value (alternative path).\n *\n * By convention, left represents the alternative outcome.\n * Unlike Result's err(), left doesn't imply an error - it's a valid value.\n *\n * In Fx.gen(), left returns its value without short-circuiting.\n * This is the key difference from Result.err() which short-circuits.\n *\n * @param value - The left value\n * @returns An Either in the left state\n *\n * @example\n * ```ts\n * const cached = left({ source: \"cache\", data: cachedValue })\n * // => { right: false, value: { source: \"cache\", data: cachedValue } }\n *\n * // In Fx.gen() - never short-circuits (unlike Result.err)\n * const fx = Fx.gen(function* () {\n * const a = yield* Either.left(\"cached\") // Returns \"cached\"\n * return a.toUpperCase() // Executes, returns \"CACHED\"\n * })\n * ```\n */\nexport const left = <L, R = never>(value: L): EitherType<L, R> => ({\n _tag: \"Left\",\n value,\n [FxTypeId]: {\n _A: () => value as L | R,\n _E: () => undefined as never,\n _R: () => undefined as never,\n },\n pipe: pipeMethod,\n // oxlint-disable-next-line require-yield\n *[Symbol.iterator](): Generator<never, L, unknown> {\n return value\n },\n})\n\n// ============================================================================\n// Type Guards\n// ============================================================================\n\n/**\n * Type guard to check if an Either is in the right state.\n *\n * @param either - The Either to check\n * @returns True if right, false if left (with type narrowing)\n *\n * @example\n * ```ts\n * const either = right(42)\n * if (isRight(either)) {\n * console.log(either.value) // Type: number\n * }\n * ```\n */\nexport const isRight = <L, R>(either: EitherType<L, R>): either is Extract<EitherType<L, R>, { _tag: \"Right\" }> =>\n either._tag === \"Right\"\n\nexport const isLeft = <L, R>(either: EitherType<L, R>): either is Extract<EitherType<L, R>, { _tag: \"Left\" }> =>\n either._tag === \"Left\"\n\n// ============================================================================\n// Right-biased Transformations\n// ============================================================================\n\n/**\n * Transform the right value of an Either.\n * Left values pass through unchanged.\n *\n * Supports both data-first and data-last calling styles:\n * - Data-first: `map(either, fn)`\n * - Data-last: `pipe(either, map(fn))`\n *\n * Supports async functions.\n *\n * @param fn - Transformation function for right values\n * @returns A curried function that transforms an Either\n *\n * @example\n * ```ts\n * // Data-first (direct call)\n * map(right(5), x => x * 2) // => right(10)\n *\n * // Data-last (curried for pipe)\n * pipe(\n * right(5),\n * map(x => x * 2)\n * ) // => right(10)\n *\n * pipe(\n * left(\"error\"),\n * map(x => x * 2)\n * ) // => left(\"error\")\n *\n * // Async usage\n * await pipe(\n * right(userId),\n * map(async id => await fetchUser(id))\n * ) // => Promise<Either<L, User>>\n * ```\n */\n/* oxlint-disable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion -- Required for overloaded return types in curried functions */\nexport const map: EitherMap = dual(2, (either: EitherType<unknown, unknown>, fn: (value: unknown) => unknown) => {\n if (either._tag === \"Left\") return either as any\n const mapped = fn(either.value)\n if (mapped instanceof Promise) {\n return mapped.then(right) as any\n }\n return right(mapped) as any\n})\n/* oxlint-enable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion */\n\n/**\n * Transform the left value of an Either.\n * Right values pass through unchanged.\n *\n * Supports both data-first and data-last calling styles:\n * - Data-first: `mapLeft(either, fn)`\n * - Data-last: `pipe(either, mapLeft(fn))`\n *\n * Supports async functions.\n *\n * @param fn - Transformation function for left values\n * @returns A curried function that transforms an Either\n *\n * @example\n * ```ts\n * // Data-first (direct call)\n * mapLeft(left(\"error\"), e => e.toUpperCase()) // => left(\"ERROR\")\n *\n * // Data-last (curried for pipe)\n * pipe(\n * left(\"error\"),\n * mapLeft(e => e.toUpperCase())\n * ) // => left(\"ERROR\")\n *\n * pipe(\n * right(42),\n * mapLeft(e => e.toUpperCase())\n * ) // => right(42)\n * ```\n */\n/* oxlint-disable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion -- Required for overloaded return types in curried functions */\nexport const mapLeft: EitherMapLeft = dual(\n 2,\n (either: EitherType<unknown, unknown>, fn: (value: unknown) => unknown) => {\n if (either._tag === \"Right\") return either as any\n const mapped = fn(either.value)\n if (mapped instanceof Promise) {\n return mapped.then(left) as any\n }\n return left(mapped) as any\n },\n)\n/* oxlint-enable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion */\n/**\n * Transform both sides of an Either simultaneously.\n * Unique to Either - not available in Result/Option.\n *\n * Supports both data-first and data-last calling styles:\n * - Data-first: `bimap(either, fnLeft, fnRight)`\n * - Data-last: `pipe(either, bimap(fnLeft, fnRight))`\n *\n * Supports async functions.\n *\n * @param fnLeft - Transformation function for left values\n * @param fnRight - Transformation function for right values\n * @returns A curried function that transforms an Either\n *\n * @example\n * ```ts\n * // Data-first (direct call)\n * bimap(right(5), e => e.toUpperCase(), x => x * 2) // => right(10)\n *\n * // Data-last (curried for pipe)\n * pipe(\n * right(5),\n * bimap(\n * e => e.toUpperCase(),\n * x => x * 2\n * )\n * ) // => right(10)\n *\n * pipe(\n * left(\"error\"),\n * bimap(\n * e => e.toUpperCase(),\n * x => x * 2\n * )\n * ) // => left(\"ERROR\")\n * ```\n */\n/* oxlint-disable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion -- Required for overloaded return types in curried functions */\nexport const bimap: EitherBimap = dual(\n 3,\n (either: EitherType<unknown, unknown>, fnLeft: (value: unknown) => unknown, fnRight: (value: unknown) => unknown) => {\n if (either._tag === \"Right\") {\n const mapped = fnRight(either.value)\n if (mapped instanceof Promise) {\n return mapped.then(right) as any\n }\n return right(mapped) as any\n }\n const mapped = fnLeft(either.value)\n if (mapped instanceof Promise) {\n return mapped.then(left) as any\n }\n return left(mapped) as any\n },\n)\n/* oxlint-enable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion */\n/**\n * Chain operations that return Either.\n * Left values short-circuit the chain.\n *\n * Supports both data-first and data-last calling styles:\n * - Data-first: `flatMap(either, fn)`\n * - Data-last: `pipe(either, flatMap(fn))`\n *\n * Supports async functions. Combines left error unions.\n *\n * @param fn - Function that returns an Either\n * @returns A curried function that chains Eithers\n *\n * @example\n * ```ts\n * // Data-first (direct call)\n * flatMap(right(5), x => right(x * 2)) // => right(10)\n *\n * // Data-last (curried for pipe)\n * pipe(\n * right(5),\n * flatMap(x => right(x * 2)),\n * flatMap(x => right(x + 1))\n * ) // => right(11)\n *\n * pipe(\n * right(5),\n * flatMap(x => left(\"error\")),\n * flatMap(x => right(x + 1)) // Not executed\n * ) // => left(\"error\")\n *\n * // Async usage\n * await pipe(\n * right(userId),\n * flatMap(async id => right(await fetchUser(id))),\n * flatMap(async user => right(await enrichProfile(user)))\n * ) // => Promise<Either<L, EnrichedUser>>\n * ```\n */\n/* oxlint-disable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion -- Required for overloaded return types in curried functions */\nexport const flatMap: EitherFlatMap = dual(\n 2,\n (either: EitherType<unknown, unknown>, fn: (value: unknown) => unknown) => {\n if (either._tag === \"Left\") return either as any\n const result = fn(either.value)\n return result as any\n },\n)\n/* oxlint-enable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion */\n/**\n * Execute a side effect on right values without modifying the Either.\n * Left values pass through unchanged.\n *\n * Supports both data-first and data-last calling styles:\n * - Data-first: `tap(either, fn)`\n * - Data-last: `pipe(either, tap(fn))`\n *\n * Supports async functions.\n *\n * @param fn - Side effect function for right values\n * @returns A curried function that executes side effects\n *\n * @example\n * ```ts\n * // Data-first (direct call)\n * tap(right(42), x => console.log(x)) // Logs: 42, returns right(42)\n *\n * // Data-last (curried for pipe)\n * pipe(\n * right(42),\n * tap(x => console.log(x)), // Logs: 42\n * map(x => x * 2)\n * ) // => right(84)\n * ```\n */\n/* oxlint-disable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion -- Required for overloaded return types in curried functions */\nexport const tap: EitherTap = dual(2, (either: EitherType<unknown, unknown>, fn: (value: unknown) => unknown) => {\n if (either._tag === \"Left\") return either as any\n const result = fn(either.value)\n if (result instanceof Promise) {\n return result.then(() => either) as any\n }\n return either as any\n})\n/* oxlint-enable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion */\n/**\n * Execute a side effect on left values without modifying the Either.\n * Right values pass through unchanged.\n *\n * Supports both data-first and data-last calling styles:\n * - Data-first: `tapLeft(either, fn)`\n * - Data-last: `pipe(either, tapLeft(fn))`\n *\n * Supports async functions.\n *\n * @param fn - Side effect function for left values\n * @returns A curried function that executes side effects\n *\n * @example\n * ```ts\n * // Data-first (direct call)\n * tapLeft(left(\"error\"), e => console.error(e)) // Logs: error, returns left(\"error\")\n *\n * // Data-last (curried for pipe)\n * pipe(\n * left(\"error\"),\n * tapLeft(e => console.error(e)), // Logs: error\n * mapLeft(e => e.toUpperCase())\n * ) // => left(\"ERROR\")\n * ```\n */\n/* oxlint-disable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion -- Required for overloaded return types in curried functions */\nexport const tapLeft: EitherTapLeft = dual(\n 2,\n (either: EitherType<unknown, unknown>, fn: (value: unknown) => unknown) => {\n if (either._tag === \"Right\") return either as any\n const result = fn(either.value)\n if (result instanceof Promise) {\n return result.then(() => either) as any\n }\n return either as any\n },\n)\n/* oxlint-enable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion */\n// ============================================================================\n// Recovery/Fallback\n// ============================================================================\n\n/**\n * Recover from a left value by providing an alternative Either.\n * Right values pass through unchanged.\n *\n * Supports both data-first and data-last calling styles:\n * - Data-first: `orElse(either, fn)`\n * - Data-last: `pipe(either, orElse(fn))`\n *\n * Supports async functions. Combines right value unions.\n *\n * @param fn - Function that returns an alternative Either\n * @returns A curried function that recovers from left\n *\n * @example\n * ```ts\n * // Data-first (direct call)\n * orElse(left(\"error\"), () => right(42)) // => right(42)\n *\n * // Data-last (curried for pipe)\n * pipe(\n * left(\"error\"),\n * orElse(() => right(42))\n * ) // => right(42)\n *\n * pipe(\n * right(10),\n * orElse(() => right(42))\n * ) // => right(10)\n * ```\n */\n/* oxlint-disable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion -- Required for overloaded return types in curried functions */\nexport const orElse: EitherOrElse = dual(2, (either: EitherType<unknown, unknown>, fn: (value: unknown) => unknown) => {\n if (either._tag === \"Right\") return either as any\n const result = fn(either.value)\n return result as any\n})\n/* oxlint-enable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion */\n/**\n * Swap left and right values.\n * Unique to Either - not available in Result/Option.\n *\n * Curried for use with pipe().\n *\n * @returns A curried function that swaps left and right\n *\n * @example\n * ```ts\n * pipe(\n * left(\"error\"),\n * swap()\n * ) // => right(\"error\")\n *\n * pipe(\n * right(42),\n * swap()\n * ) // => left(42)\n * ```\n */\nexport const swap =\n <L, R>() =>\n (either: EitherType<L, R>): EitherType<R, L> =>\n either._tag === \"Left\" ? right(either.value) : left(either.value)\n\n// ============================================================================\n// Filtering\n// ============================================================================\n\n/**\n * Filter right values based on a predicate.\n * Failed predicates convert to left with onFail callback.\n * Left values pass through unchanged.\n *\n * Supports both data-first and data-last calling styles:\n * - Data-first: `filter(either, predicate, onFail)`\n * - Data-last: `pipe(either, filter(predicate, onFail))`\n *\n * @param predicate - Function to test right values\n * @param onFail - Function to produce left value on failure\n * @returns A curried function that filters an Either\n *\n * @example\n * ```ts\n * // Data-first (direct call)\n * filter(right(5), x => x > 3, x => `${x} is too small`) // => right(5)\n *\n * // Data-last (curried for pipe)\n * pipe(\n * right(5),\n * filter(x => x > 3, x => `${x} is too small`)\n * ) // => right(5)\n *\n * pipe(\n * right(2),\n * filter(x => x > 3, x => `${x} is too small`)\n * ) // => left(\"2 is too small\")\n * ```\n */\n/* oxlint-disable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion -- Required for overloaded return types in curried functions */\nexport const filter: EitherFilter = dual(\n 3,\n (\n either: EitherType<unknown, unknown>,\n predicate: (value: unknown) => boolean,\n onFail: (value: unknown) => unknown,\n ) => {\n if (either._tag === \"Left\") return either as any\n return predicate(either.value) ? (either as any) : left(onFail(either.value))\n },\n)\n/* oxlint-enable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion */\n// ============================================================================\n// Combinators\n// ============================================================================\n\n/**\n * Combine multiple Eithers into a single Either.\n * Short-circuits on the first left value.\n *\n * Supports both array and object inputs with full type preservation.\n * For arrays of 1-6 elements, tuple types are inferred automatically.\n * For longer arrays, use `as const` to preserve tuple structure.\n *\n * @param eithers - Array or object of Eithers to combine\n * @returns Either with all right values or first left\n *\n * @example\n * ```ts\n * // Array form - tuple types inferred automatically for up to 6 elements\n * all([right(1), right(\"hello\")])\n * // => right([1, \"hello\"])\n *\n * all([right(1), left(\"error\"), right(3)])\n * // => left(\"error\")\n *\n * // Object form\n * all({ a: right(1), b: right(\"hello\") })\n * // => right({ a: 1, b: \"hello\" })\n * ```\n */\n/* oxlint-disable no-explicit-any, no-unsafe-return, no-unsafe-member-access, strict-boolean-expressions, no-unsafe-assignment -- Required for handling union types in overloaded function */\nexport const all: EitherAll = (eithers: any): any => {\n // Array case\n if (Array.isArray(eithers)) {\n const values: unknown[] = []\n for (const either of eithers) {\n if (either._tag === \"Left\") return either\n values.push(either.value)\n }\n return right(values)\n }\n\n // Object case\n const result: Record<string, unknown> = {}\n for (const key in eithers) {\n const either = eithers[key]\n if (either._tag === \"Left\") return either\n result[key] = either.value\n }\n return right(result)\n}\n/* oxlint-enable no-explicit-any, no-unsafe-return, no-unsafe-member-access, strict-boolean-expressions, no-unsafe-assignment */\n// ============================================================================\n// Extraction\n// ============================================================================\n\n/**\n * Extract the right value or return a default.\n *\n * Supports both data-first and data-last calling styles:\n * - Data-first: `unwrapOr(either, defaultValue)`\n * - Data-last: `pipe(either, unwrapOr(defaultValue))`\n *\n * Uses NoInfer to prevent type inference from the default value.\n *\n * @param defaultValue - Value to return if Either is left\n * @returns A curried function that extracts the value\n *\n * @example\n * ```ts\n * // Data-first (direct call)\n * unwrapOr(right(42), 0) // => 42\n * unwrapOr(left(\"error\"), 0) // => 0\n *\n * // Data-last (curried for pipe)\n * pipe(\n * right(42),\n * unwrapOr(0)\n * ) // => 42\n *\n * pipe(\n * left(\"error\"),\n * unwrapOr(0)\n * ) // => 0\n * ```\n */\nexport const unwrapOr: EitherUnwrapOr = dual(\n 2,\n <L, R>(either: EitherType<L, R>, defaultValue: NoInfer<R>): R => (either._tag === \"Right\" ? either.value : defaultValue),\n)\n\n/**\n * Extract the right value or compute one from the left value.\n *\n * Supports both data-first and data-last calling styles:\n * - Data-first: `unwrapOrElse(either, fn)`\n * - Data-last: `pipe(either, unwrapOrElse(fn))`\n *\n * @param fn - Function to compute default from left value\n * @returns A curried function that extracts the value\n *\n * @example\n * ```ts\n * // Data-first (direct call)\n * unwrapOrElse(right(42), () => 0) // => 42\n * unwrapOrElse(left(\"error\"), e => e.length) // => 5\n *\n * // Data-last (curried for pipe)\n * pipe(\n * right(42),\n * unwrapOrElse(() => 0)\n * ) // => 42\n *\n * pipe(\n * left(\"error\"),\n * unwrapOrElse(e => e.length)\n * ) // => 5\n * ```\n */\nexport const unwrapOrElse: EitherUnwrapOrElse = dual(\n 2,\n <L, R>(either: EitherType<L, R>, fn: (left: L) => R): R => (either._tag === \"Right\" ? either.value : fn(either.value as L)),\n)\n\n/**\n * Pattern match on an Either with handlers for both cases.\n *\n * Supports both data-first and data-last calling styles:\n * - Data-first: `match(either, { Left: ..., Right: ... })`\n * - Data-last: `pipe(either, match({ Left: ..., Right: ... }))`\n *\n * @param handlers - Object with left and right handler functions\n * @returns A curried function that pattern matches\n *\n * @example\n * ```ts\n * // Data-first (direct call)\n * match(right(42), {\n * Left: e => `Error: ${e}`,\n * Right: x => `Success: ${x}`\n * }) // => \"Success: 42\"\n *\n * // Data-last (curried for pipe)\n * pipe(\n * right(42),\n * match({\n * Left: e => `Error: ${e}`,\n * Right: x => `Success: ${x}`\n * })\n * ) // => \"Success: 42\"\n * ```\n */\nexport const match: EitherMatch = dual(\n 2,\n <L, R, U>(either: EitherType<L, R>, handlers: { Left: (value: L) => U; Right: (value: R) => U }): U =>\n either._tag === \"Right\" ? handlers.Right(either.value) : handlers.Left(either.value),\n)\n\n// ============================================================================\n// Conversions\n// ============================================================================\n\n/**\n * Convert a Result to an Either.\n * Result's ok becomes right, err becomes left.\n *\n * @param result - The Result to convert\n * @returns An Either with the same semantics\n *\n * @example\n * ```ts\n * fromResult(Result.ok(42)) // => right(42)\n * fromResult(Result.err(\"error\")) // => left(\"error\")\n * ```\n */\nexport const fromResult = <R, E>(result: ResultType<R, E>): EitherType<E, R> =>\n result._tag === \"Ok\" ? right(result.value) : left(result.error)\n\n/**\n * Convert an Either to a Result.\n * Either's right becomes ok, left becomes err.\n *\n * Curried for use with pipe().\n *\n * @param either - The Either to convert\n * @returns A Result with error semantics\n *\n * @example\n * ```ts\n * pipe(\n * right(42),\n * toResult\n * ) // => Result.ok(42)\n *\n * pipe(\n * left(\"error\"),\n * toResult\n * ) // => Result.err(\"error\")\n * ```\n */\nexport const toResult = <L, R>(either: EitherType<L, R>): ResultType<R, L> =>\n either._tag === \"Right\" ? Result.ok(either.value) : Result.err(either.value)\n\n/**\n * Convert an Option to an Either.\n * Option's some becomes right, none becomes left with onNone callback.\n *\n * @param option - The Option to convert\n * @param onNone - Function to produce left value for none\n * @returns An Either\n *\n * @example\n * ```ts\n * fromOption(Option.some(42), () => \"not found\") // => right(42)\n * fromOption(Option.none(), () => \"not found\") // => left(\"not found\")\n * ```\n */\nexport const fromOption = <R, L>(option: OptionType<R>, onNone: () => L): EitherType<L, R> =>\n option._tag === \"Some\" ? right(option.value) : left(onNone())\n\n/**\n * Convert an Either to an Option.\n * Either's right becomes some, left is discarded.\n *\n * Curried for use with pipe().\n *\n * @param either - The Either to convert\n * @returns An Option (left value is discarded)\n *\n * @example\n * ```ts\n * pipe(\n * right(42),\n * toOption\n * ) // => Option.some(42)\n *\n * pipe(\n * left(\"error\"),\n * toOption\n * ) // => Option.none()\n * ```\n */\nexport const toOption = <L, R>(either: EitherType<L, R>): OptionType<R> =>\n either._tag === \"Right\" ? Option.some(either.value) : Option.none<R>()\n\n/**\n * Convert a nullable value to an Either.\n * null/undefined becomes left with onNull callback, otherwise right.\n *\n * @param value - The nullable value\n * @param onNull - Function to produce left value for null/undefined\n * @returns An Either\n *\n * @example\n * ```ts\n * fromNullable(42, () => \"not found\") // => right(42)\n * fromNullable(null, () => \"not found\") // => left(\"not found\")\n * fromNullable(undefined, () => \"not found\") // => left(\"not found\")\n * ```\n */\nexport const fromNullable = <R, L>(value: R | null | undefined, onNull: () => L): EitherType<L, R> =>\n value === null || value === undefined ? left(onNull()) : right(value)\n\n/**\n * Create an Either from a predicate.\n * Predicate success becomes right, failure becomes left with onFail callback.\n *\n * @param value - The value to test\n * @param predicate - Function to test the value\n * @param onFail - Function to produce left value on failure\n * @returns An Either\n *\n * @example\n * ```ts\n * fromPredicate(5, x => x > 3, x => `${x} is too small`)\n * // => right(5)\n *\n * fromPredicate(2, x => x > 3, x => `${x} is too small`)\n * // => left(\"2 is too small\")\n * ```\n */\nexport const fromPredicate = <R, L>(\n value: R,\n predicate: (value: R) => boolean,\n onFail: (value: R) => L,\n): EitherType<L, R> => (predicate(value) ? right(value) : left(onFail(value)))\n\n// ============================================================================\n// Namespace Export\n// ============================================================================\n\n/**\n * Either namespace containing all utility functions for working with Either types.\n *\n * Either represents a value that can be one of two types: Left<L> or Right<R>.\n * By convention, Right is the \"success\" or preferred path, while Left represents\n * an alternative outcome (not necessarily an error, unlike Result).\n *\n * Use Either when both outcomes are valid and meaningful, not just success/failure.\n * For error handling, prefer Result instead.\n *\n * @see {@link Result} for success/error semantics\n * @see {@link Option} for presence/absence semantics\n *\n * @example\n * ```ts\n * import { Either, pipe } from '@repo/std'\n * import type { Either as EitherType } from '@repo/std'\n *\n * // Either for branching logic (cache vs fresh data)\n * const fetchOrCache = (id: number): EitherType<CachedData, FreshData> =>\n * cache.has(id) ? Either.left(cache.get(id)) : Either.right(fetch(id))\n *\n * const result = pipe(\n * fetchOrCache(1),\n * Either.map(data => data.value),\n * Either.unwrapOr(defaultValue)\n * )\n *\n * // Async example\n * const processed = await pipe(\n * Either.right(userId),\n * Either.map(async id => await fetchUser(id)),\n * Either.flatMap(async user => Either.right(await enrichUser(user)))\n * )\n * ```\n */\nexport const Either = {\n // Constructors\n left,\n right,\n\n // Type guards\n isLeft,\n isRight,\n\n // Transformations\n map,\n mapLeft,\n bimap,\n flatMap,\n tap,\n tapLeft,\n\n // Recovery\n orElse,\n swap,\n\n // Filtering\n filter,\n\n // Combinators\n all,\n\n // Extraction\n unwrapOr,\n unwrapOrElse,\n match,\n\n // Conversions\n fromResult,\n toResult,\n fromOption,\n toOption,\n fromNullable,\n fromPredicate,\n} as const\n"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ const e=16777619;function t(n){let r=2166136261;if(n===null)return r^1853189228;if(n===void 0)return r^1970168933;switch(typeof n){case`boolean`:return r^(n?1:0);case`number`:return Number.isNaN(n)?r^5136718:Number.isFinite(n)?r^(n|0)^(n*1e6|0):r^(n>0?4812390:759787110);case`string`:for(let t=0;t<n.length;t++)r^=n.codePointAt(t),r=Math.imul(r,e);return r>>>0;case`object`:{if(n instanceof Date)return r^t(n.getTime());if(Array.isArray(n)){r^=23389;for(let i=0;i<n.length;i++)r^=t(n[i]),r=Math.imul(r,e);return r>>>0}r^=31613;let i=n,a=Object.keys(i).toSorted();for(let n of a)r^=t(n),r=Math.imul(r,e),r^=t(i[n]),r=Math.imul(r,e);return r>>>0}default:return r}}function n(e,t){if(e===t)return!0;if(typeof e!=typeof t||e===null||t===null||typeof e!=`object`)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length?e.every((e,r)=>n(e,t[r])):!1;if(Array.isArray(e)!==Array.isArray(t))return!1;let r=e,i=t,a=Object.keys(r),o=Object.keys(i);return a.length===o.length?a.every(e=>n(r[e],i[e])):!1}function r(e){return(t,r)=>t===r?!0:t._tag!==e||r._tag!==e?!1:n(t,r)}function i(e){return n=>n._tag===e?t(n):0}function a(e){return(t,r)=>t===r?!0:t._tag!==r._tag||!e.includes(t._tag)?!1:n(t,r)}function o(e){return n=>e.includes(n._tag)?t(n):0}export{n as a,i,o as n,t as o,r,a as t};
2
+ //# sourceMappingURL=equality-D2EJvZm4.mjs.map
@@ -1 +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
+ {"version":3,"file":"equality-D2EJvZm4.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":"AAMA,MACM,EAAY,SAkBlB,SAAgB,EAAS,EAAwB,CAC/C,IAAI,EAAO,WAGX,GAAI,IAAU,KAAM,OAAO,EAAO,WAElC,GAAI,IAAU,IAAA,GAAW,OAAO,EAAO,WAGvC,OAAQ,OAAO,EAAf,CACE,IAAK,UACH,OAAO,GAAQ,EAAQ,EAAI,GAE7B,IAAK,SAKH,OAHI,OAAO,MAAM,EAAM,CAAS,EAAO,QAClC,OAAO,SAAS,EAAM,CAEpB,GAAQ,EAAQ,IAAO,EAAQ,IAAW,GAFb,GAAQ,EAAQ,EAAI,QAAW,WAKrE,IAAK,SACH,IAAK,IAAI,EAAI,EAAG,EAAI,EAAM,OAAQ,IAChC,GAAQ,EAAM,YAAY,EAAE,CAC5B,EAAO,KAAK,KAAK,EAAM,EAAU,CAGnC,OAAO,IAAS,EAElB,IAAK,SAAU,CACb,GAAI,aAAiB,KACnB,OAAO,EAAO,EAAS,EAAM,SAAS,CAAC,CAGzC,GAAI,MAAM,QAAQ,EAAM,CAAE,CAExB,GAAQ,MACR,IAAK,IAAI,EAAI,EAAG,EAAI,EAAM,OAAQ,IAChC,GAAQ,EAAS,EAAM,GAAG,CAC1B,EAAO,KAAK,KAAK,EAAM,EAAU,CAEnC,OAAO,IAAS,EAIlB,GAAQ,MAER,IAAM,EAAM,EAEN,EAAO,OAAO,KAAK,EAAI,CAAC,UAAU,CACxC,IAAK,IAAM,KAAO,EAChB,GAAQ,EAAS,EAAI,CACrB,EAAO,KAAK,KAAK,EAAM,EAAU,CACjC,GAAQ,EAAS,EAAI,GAAK,CAC1B,EAAO,KAAK,KAAK,EAAM,EAAU,CAEnC,OAAO,IAAS,EAGlB,QAEE,OAAO,GA+Bb,SAAgB,EAAW,EAAY,EAAqB,CAE1D,GAAI,IAAM,EAAG,MAAO,GASpB,GANI,OAAO,GAAM,OAAO,GAGpB,IAAM,MAAQ,IAAM,MAGpB,OAAO,GAAM,SAAU,MAAO,GAGlC,GAAI,aAAa,MAAQ,aAAa,KACpC,OAAO,EAAE,SAAS,GAAK,EAAE,SAAS,CAIpC,GAAI,MAAM,QAAQ,EAAE,EAAI,MAAM,QAAQ,EAAE,CAEtC,OADI,EAAE,SAAW,EAAE,OACZ,EAAE,OAAO,EAAM,IAAU,EAAW,EAAM,EAAE,GAAO,CAAC,CADzB,GAKpC,GAAI,MAAM,QAAQ,EAAE,GAAK,MAAM,QAAQ,EAAE,CAAE,MAAO,GAGlD,IAAM,EAAO,EAEP,EAAO,EAEP,EAAQ,OAAO,KAAK,EAAK,CACzB,EAAQ,OAAO,KAAK,EAAK,CAI/B,OAFI,EAAM,SAAW,EAAM,OAEpB,EAAM,MAAO,GAAQ,EAAW,EAAK,GAAM,EAAK,GAAK,CAAC,CAFnB,GA6B5C,SAAgB,EACd,EACmE,CACnE,OAAQ,EAAG,IACL,IAAM,EAAU,GAChB,EAAE,OAAS,GAAQ,EAAE,OAAS,EAAa,GACxC,EAAW,EAAG,EAAE,CAqB3B,SAAgB,EAAwC,EAAsD,CAC5G,MAAQ,IACF,EAAM,OAAS,EACZ,EAAS,EAAM,CADU,EAsBpC,SAAgB,EAA2D,EAAyC,CAClH,OAAQ,EAAG,IACL,IAAM,EAAU,GAChB,EAAE,OAAS,EAAE,MACb,CAAC,EAAK,SAAS,EAAE,KAAK,CAAS,GAC5B,EAAW,EAAG,EAAE,CAqB3B,SAAgB,EAAyD,EAAsC,CAC7G,MAAQ,IACD,EAAK,SAAS,EAAM,KAAK,CACvB,EAAS,EAAM,CADiB"}
@@ -1,2 +1,2 @@
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";
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-CDio8mJY.mjs";
2
2
  export { Err, ErrorData, ErrorTag, TaggedError, TaggedErrorFactory, TaggedErrorInstance, TaggedError$1 as TaggedErrorType, is, tagged };
@@ -1,3 +1 @@
1
- import { i as tagged, n as TaggedError, r as is, t as Err } from "../err-BM-svBaK.mjs";
2
-
3
- export { Err, TaggedError, is, tagged };
1
+ import{i as e,n as t,r as n,t as r}from"../err-CYs4b1RV.mjs";export{r as Err,t as TaggedError,n as is,e as tagged};
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./fx.types-CXTwEa1G.mjs";const t=e=>(t=>({_tag:e,...t}));function n(t){return class extends Error{static _tag=t;_tag=t;[e]={_A:()=>void 0,_E:()=>this,_R:()=>void 0};constructor(...e){super(t),this.name=t;let n=e[0];n&&Object.assign(this,n),Object.setPrototypeOf(this,new.target.prototype)}*[Symbol.iterator](){throw yield this,Error(`Unreachable: Do should short-circuit on error`)}}}const r=e=>t=>typeof t==`object`&&!!t&&`_tag`in t&&t._tag===e,i={tagged:t,is:r};export{t as i,n,r,i as t};
2
+ //# sourceMappingURL=err-CYs4b1RV.mjs.map
@@ -1 +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
+ {"version":3,"file":"err-CYs4b1RV.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":"4CAqCA,MAAa,EAEkE,IACpE,IAAmB,CAAE,KAAM,EAAK,GAAG,EAAM,GAqCpD,SAAgB,EAAgC,EAAmC,CACjF,OAAO,cAA4D,KAAM,CACvE,OAAgB,KAAY,EAC5B,KAAqB,EAErB,CAAU,GAAY,CACpB,OAAU,IAAA,GACV,OAAU,KACV,OAAU,IAAA,GACX,CAED,YAAY,GAAG,EAAoD,CACjE,MAAM,EAAI,CACV,KAAK,KAAO,EACZ,IAAM,EAAO,EAAK,GACd,GAAM,OAAO,OAAO,KAAM,EAAK,CACnC,OAAO,eAAe,KAAM,IAAI,OAAO,UAAU,CAGnD,EAAE,OAAO,WAA6C,CAEpD,MADA,MAAM,KACI,MAAM,gDAAgD,GAmCtE,MAAa,EAAqC,GACxC,GACN,OAAO,GAAU,YAAY,GAAkB,SAAU,GAAS,EAAM,OAAS,EAiDxE,EAAM,CACjB,SACA,KACD"}
@@ -1,2 +1,2 @@
1
- import { t as flow } from "../index-BOrJQBPO.mjs";
1
+ import { t as flow } from "../index-BahMvQpA.mjs";
2
2
  export { flow };
@@ -1,3 +1 @@
1
- import { t as flow } from "../flow-D4cE0EAg.mjs";
2
-
3
- export { flow };
1
+ import{t as e}from"../flow-CxKQ5yac.mjs";export{e as flow};
@@ -0,0 +1,2 @@
1
+ function e(e){return e instanceof Promise}function t(...t){return((...r)=>{let i=r;for(let r=0;r<t.length;r++){let[a]=i=[t[r]?.(...i)];if(e(a))return n(a,t.slice(r+1))}return i[0]})}const n=async(e,t)=>{for(let n of t)e=n(await e);return await e};export{e as n,t};
2
+ //# sourceMappingURL=flow-CxKQ5yac.mjs.map
@@ -1 +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"}
1
+ {"version":3,"file":"flow-CxKQ5yac.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,EAAU,EAA2C,CACnE,OAAO,aAAiB,QCgS1B,SAAgB,EAA8B,GAAG,EAAyB,CAExE,QAAS,GAAG,IAAS,CAEnB,IAAI,EAAsB,EAE1B,IAAK,IAAI,EAAI,EAAG,EAAI,EAAI,OAAQ,IAAK,CAEnC,GAAM,CAAC,GAAW,EAAW,CAAC,EAAI,KAAK,GAAG,EAAS,CAAC,CACpD,GAAI,EAAU,EAAO,CAAE,OAAO,EAAa,EAAQ,EAAI,MAAM,EAAI,EAAE,CAAC,CAGtE,OAAO,EAAS,KAIpB,MAAM,EAAe,MAAO,EAAiB,IAAc,CAEzD,IAAK,IAAM,KAAO,EAAM,EAAS,EAAI,MAAM,EAAO,CAClD,OAAO,MAAM"}
@@ -1,3 +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 };
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-DO-8yG4c.mjs";
2
+ import { A as gen, C as isServiceClass, D as err, E as TaggedMatch, M as run, N as Defect, O as fn, P as Exit, 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 fxMatch, 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-UYodvXes.mjs";
3
+ export { AsyncFx, AsyncFxGenerator, AsyncFxYieldable, Context, Context as ContextType, ExcludeScope, Exit, Exit as ExitType, Defect as ExitDefect, Fx, 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, TaggedMatch, UnprovidedDeps, createMemoMap, createScope, err, fn, gen, isServiceClass, isServiceRequest, fxMatch as match, ok, provide, provideContext, provideService, run, serviceTag };
package/dist/fx/index.mjs CHANGED
@@ -1,4 +1 @@
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 };
1
+ import{n as e,t}from"../fx.types-CXTwEa1G.mjs";import{_ as n,a as r,b as i,c as a,d as o,f as s,g as c,h as l,i as u,l as d,m as f,n as p,o as m,p as h,r as g,s as _,t as v,u as y,v as b,y as x}from"../fx-C4UuWCqP.mjs";export{d as Context,i as Exit,h as Fx,t as FxTypeId,a as Layer,u as MemoMap,m as Scope,y as Service,r as createMemoMap,_ as createScope,f as err,l as fn,n as gen,o as isServiceClass,e as isServiceRequest,c as match,b as ok,v as provide,p as provideContext,g as provideService,x as run,s as serviceTag};