@nicolastoulemont/std 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -11
- package/dist/adt/index.d.mts +1 -1
- package/dist/adt/index.mjs +1 -1
- package/dist/adt-CY8wLJJI.mjs +2 -0
- package/dist/adt-CY8wLJJI.mjs.map +1 -0
- package/dist/data/index.d.mts +1 -1
- package/dist/data/index.mjs +1 -1
- package/dist/data-DqACNS_g.mjs +2 -0
- package/dist/data-DqACNS_g.mjs.map +1 -0
- package/dist/duration/index.d.mts +1 -1
- package/dist/duration/index.mjs +1 -1
- package/dist/{duration-CYoDHcOR.mjs → duration-Bas3mi1N.mjs} +2 -2
- package/dist/{duration-CYoDHcOR.mjs.map → duration-Bas3mi1N.mjs.map} +1 -1
- package/dist/fx/index.d.mts +1 -1
- package/dist/fx/index.mjs +1 -1
- package/dist/{fx-DUXDxwsU.mjs → fx-C_RTDEpv.mjs} +2 -2
- package/dist/{fx-DUXDxwsU.mjs.map → fx-C_RTDEpv.mjs.map} +1 -1
- package/dist/{index-MsJqfQu0.d.mts → index-BD-els5J.d.mts} +2 -2
- package/dist/{index-MsJqfQu0.d.mts.map → index-BD-els5J.d.mts.map} +1 -1
- package/dist/{index-DUki2Bcp.d.mts → index-BaRJVkLo.d.mts} +2 -2
- package/dist/{index-DUki2Bcp.d.mts.map → index-BaRJVkLo.d.mts.map} +1 -1
- package/dist/{index-B4WfexUL.d.mts → index-BipW0MC3.d.mts} +32 -25
- package/dist/index-BipW0MC3.d.mts.map +1 -0
- package/dist/index-BqJ1GWAF.d.mts.map +1 -1
- package/dist/{index-Ctqe1fD1.d.mts → index-CVmgBpDt.d.mts} +2 -2
- package/dist/{index-Ctqe1fD1.d.mts.map → index-CVmgBpDt.d.mts.map} +1 -1
- package/dist/{index-UINIHFuh.d.mts → index-D6pjHqlK.d.mts} +48 -2
- package/dist/index-D6pjHqlK.d.mts.map +1 -0
- package/dist/{index-crtzMG48.d.mts → index-D8gcYvR9.d.mts} +38 -3
- package/dist/index-D8gcYvR9.d.mts.map +1 -0
- package/dist/index-D8rDE60Y.d.mts.map +1 -1
- package/dist/{index-BsPOcZk9.d.mts → index-DfAqfnY0.d.mts} +2 -2
- package/dist/{index-BsPOcZk9.d.mts.map → index-DfAqfnY0.d.mts.map} +1 -1
- package/dist/index.d.mts +8 -8
- package/dist/index.mjs +1 -1
- package/dist/{equality-BX6BUidG.mjs → is-plain-object-BoFjRafL.mjs} +2 -2
- package/dist/is-plain-object-BoFjRafL.mjs.map +1 -0
- package/dist/layer/index.mjs +1 -1
- package/dist/{layer-CKtH7TRL.mjs → layer-C5A-EM0h.mjs} +2 -2
- package/dist/{layer-CKtH7TRL.mjs.map → layer-C5A-EM0h.mjs.map} +1 -1
- package/dist/provide/index.d.mts +1 -1
- package/dist/provide/index.mjs +1 -1
- package/dist/provide-CuccogWx.mjs +2 -0
- package/dist/provide-CuccogWx.mjs.map +1 -0
- package/dist/queue/index.d.mts +1 -1
- package/dist/queue/index.mjs +1 -1
- package/dist/{queue-apiEOlRD.mjs → queue-GYVrD39q.mjs} +2 -2
- package/dist/{queue-apiEOlRD.mjs.map → queue-GYVrD39q.mjs.map} +1 -1
- package/dist/schedule/index.d.mts +1 -1
- package/dist/schedule/index.mjs +1 -1
- package/dist/{schedule-C6iN3oMt.mjs → schedule-B7qV60tO.mjs} +2 -2
- package/dist/{schedule-C6iN3oMt.mjs.map → schedule-B7qV60tO.mjs.map} +1 -1
- package/dist/{schedule-B9K_2Z21.d.mts → schedule-BzPjvMXc.d.mts} +3 -3
- package/dist/{schedule-B9K_2Z21.d.mts.map → schedule-BzPjvMXc.d.mts.map} +1 -1
- package/dist/schema/index.d.mts +1 -1
- package/dist/schema/index.mjs +1 -1
- package/dist/schema-DstB1_VK.mjs +2 -0
- package/dist/schema-DstB1_VK.mjs.map +1 -0
- package/dist/{schema.types-CBEXCwfs.d.mts → schema.types-w1WK4kGS.d.mts} +7 -5
- package/dist/schema.types-w1WK4kGS.d.mts.map +1 -0
- package/package.json +1 -1
- package/dist/adt-CPG_sa8q.mjs +0 -2
- package/dist/adt-CPG_sa8q.mjs.map +0 -1
- package/dist/data-BHYPdqWZ.mjs +0 -2
- package/dist/data-BHYPdqWZ.mjs.map +0 -1
- package/dist/equality-BX6BUidG.mjs.map +0 -1
- package/dist/index-B4WfexUL.d.mts.map +0 -1
- package/dist/index-UINIHFuh.d.mts.map +0 -1
- package/dist/index-crtzMG48.d.mts.map +0 -1
- package/dist/provide--yZE8x-n.mjs +0 -2
- package/dist/provide--yZE8x-n.mjs.map +0 -1
- package/dist/schema-CJ-aaQe8.mjs +0 -2
- package/dist/schema-CJ-aaQe8.mjs.map +0 -1
- package/dist/schema.types-CBEXCwfs.d.mts.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema-CJ-aaQe8.mjs","names":["Result.err"],"sources":["../src/schema/schema.ts"],"sourcesContent":["import { Result } from \"../result\"\nimport type { Result as ResultType } from \"../result/result.types\"\n/**\n * Standard Schema-backed parsing and refinement helpers.\n *\n * **Mental model**\n * - `Schema.parse` is for boundary validation and parsing.\n * - `Schema.refine` is for sync-only in-memory narrowing that preserves the original value shape.\n * - `Schema.is` is for sync-only exact-output narrowing when the schema output is the desired type.\n *\n * **Common tasks**\n * - Parse loose external data into validated subtypes.\n * - Reuse a schema as a type guard for in-memory narrowing with `Schema.refine`.\n * - Name reusable narrowed types with `Schema.Refine<Base, typeof schema>` or `Schema.Infer<typeof schema>`.\n *\n * **Gotchas**\n * - `Schema.parse` may be sync or async based on the schema type you preserve.\n * - `Schema.refine` and `Schema.is` support both data-first and data-last styles.\n * - `Schema.refine` and `Schema.is` are sync-only.\n * - `Schema.refine` must only be used with schemas that prove properties already present on the original value.\n * - `Schema.is` narrows exactly to the schema output, while `Schema.refine` narrows to `Base & Output`.\n *\n * @module\n */\nimport { dual } from \"../shared/dual\"\nimport { isPromise } from \"../shared/is-promise\"\nimport { toThrownValidationError, toValidationResult, validateSync } from \"./schema.shared\"\nimport type { Input, Output, Refine as Refined, SyncRefinementSchema, SyncSchema, ValidationError } from \"./schema.types\"\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\"\n\nexport type {\n Infer,\n Input,\n Output,\n Refine,\n RefinementSchema,\n SyncRefinementSchema,\n SyncSchema,\n ValidationError,\n ValidationIssue,\n} from \"./schema.types\"\n\n/**\n * Create a schema-backed parser.\n *\n * For sync schemas the returned parser is sync.\n * For general Standard Schema values the returned parser is async.\n */\nexport function parse<S extends SyncSchema>(schema: S): (value: Input<S>) => ResultType<Output<S>, ValidationError>\nexport function parse<S extends StandardSchemaV1>(\n schema: S,\n): (value: Input<S>) => Promise<ResultType<Output<S>, ValidationError>>\nexport function parse<S extends StandardSchemaV1>(schema: S) {\n return (value: Input<S>) => {\n try {\n const result = schema[\"~standard\"].validate(value)\n\n if (isPromise(result)) {\n return Promise.resolve(result).then(\n (validated) => toValidationResult(validated),\n (error) => Result.err(toThrownValidationError(error)),\n )\n }\n\n return toValidationResult(result)\n } catch (error) {\n return Result.err(toThrownValidationError(error))\n }\n }\n}\n\n/**\n * Create a sync-only schema-backed type guard that preserves the original value shape.\n *\n * Use this when a schema validates only a subset of a broader in-memory value.\n * The narrowed type is `Base & Output<typeof schema>`, not the exact schema output.\n *\n * Supports both data-first and data-last styles:\n * - Data-first: `Schema.refine(value, schema)`\n * - Data-last: `Schema.refine(schema)(value)`\n *\n * Only use this with sync schemas that prove properties already present on the\n * original value. Transforms, defaults, and coercions are not safe here because\n * they can change the schema output without changing the original input value.\n */\nexport type RefineFn = {\n <S extends SyncSchema, Base extends Input<S>>(value: Base, schema: S): value is Refined<Base, S>\n <S extends SyncSchema>(schema: S): <Base extends Input<S>>(value: Base) => value is Refined<Base, S>\n}\n\n/**\n * Create a sync-only schema-backed type guard.\n *\n * Unlike `Schema.refine`, this narrows exactly to the schema output.\n *\n * This is intended for refinement schemas where the validated output is a\n * subtype of the input value already in memory.\n *\n * Supports both data-first and data-last styles:\n * - Data-first: `Schema.is(value, schema)`\n * - Data-last: `Schema.is(schema)(value)`\n */\nexport type Is = {\n <Base, Sub extends Base>(value: Base, schema: SyncRefinementSchema<Base, Sub>): value is Sub\n <S extends SyncSchema>(value: unknown, schema: S): value is Output<S>\n <Base, Sub extends Base>(schema: SyncRefinementSchema<Base, Sub>): (value: Base) => value is Sub\n <S extends SyncSchema>(schema: S): (value: unknown) => value is Output<S>\n}\n\n/* oxlint-disable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion -- dual() requires a single implementation signature */\nexport const refine: RefineFn = dual(2, (value: unknown, schema: SyncSchema) => {\n return validateSync(schema, value, \"Schema.refine()\")._tag === \"Ok\"\n}) as RefineFn\n\nexport const is: Is = dual(2, (value: unknown, schema: SyncSchema) => {\n return validateSync(schema, value, \"Schema.is()\")._tag === \"Ok\"\n}) as Is\n/* oxlint-enable no-explicit-any, no-unsafe-return, no-unsafe-type-assertion */\n"],"mappings":"qQAoDA,SAAgB,EAAkC,EAAW,CAC3D,MAAQ,IAAoB,CAC1B,GAAI,CACF,IAAM,EAAS,EAAO,aAAa,SAAS,EAAM,CASlD,OAPI,EAAU,EAAO,CACZ,QAAQ,QAAQ,EAAO,CAAC,KAC5B,GAAc,EAAmB,EAAU,CAC3C,GAAUA,EAAW,EAAwB,EAAM,CAAC,CACtD,CAGI,EAAmB,EAAO,OAC1B,EAAO,CACd,OAAOA,EAAW,EAAwB,EAAM,CAAC,GA4CvD,MAAa,EAAmB,EAAK,GAAI,EAAgB,IAChD,EAAa,EAAQ,EAAO,kBAAkB,CAAC,OAAS,KAC/D,CAEW,EAAS,EAAK,GAAI,EAAgB,IACtC,EAAa,EAAQ,EAAO,cAAc,CAAC,OAAS,KAC3D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.types-CBEXCwfs.d.mts","names":[],"sources":["../src/schema/schema.types.ts"],"sourcesContent":[],"mappings":";;;;;;;AAMA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