@willaimg/yatsp 4.3.6
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 +22 -0
- package/compile.cjs +96 -0
- package/compile.d.cts +1 -0
- package/compile.d.ts +1 -0
- package/compile.js +52 -0
- package/index.cjs +52 -0
- package/index.d.cts +3 -0
- package/index.d.ts +3 -0
- package/index.js +7 -0
- package/locales/index.cjs +36 -0
- package/locales/index.d.cts +1 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/mini/index.cjs +51 -0
- package/mini/index.d.cts +3 -0
- package/mini/index.d.ts +3 -0
- package/mini/index.js +3 -0
- package/package.json +142 -0
- package/src/compile.ts +56 -0
- package/src/index.ts +7 -0
- package/src/locales/index.ts +1 -0
- package/src/mini/index.ts +3 -0
- package/src/v3/YatspError.ts +340 -0
- package/src/v3/benchmarks/datetime.ts +58 -0
- package/src/v3/benchmarks/discriminatedUnion.ts +80 -0
- package/src/v3/benchmarks/index.ts +59 -0
- package/src/v3/benchmarks/ipv4.ts +57 -0
- package/src/v3/benchmarks/object.ts +69 -0
- package/src/v3/benchmarks/primitives.ts +162 -0
- package/src/v3/benchmarks/realworld.ts +63 -0
- package/src/v3/benchmarks/string.ts +55 -0
- package/src/v3/benchmarks/union.ts +80 -0
- package/src/v3/errors.ts +13 -0
- package/src/v3/external.ts +6 -0
- package/src/v3/helpers/enumUtil.ts +17 -0
- package/src/v3/helpers/errorUtil.ts +8 -0
- package/src/v3/helpers/parseUtil.ts +176 -0
- package/src/v3/helpers/partialUtil.ts +34 -0
- package/src/v3/helpers/typeAliases.ts +2 -0
- package/src/v3/helpers/util.ts +224 -0
- package/src/v3/index.ts +4 -0
- package/src/v3/locales/en.ts +124 -0
- package/src/v3/standard-schema.ts +113 -0
- package/src/v3/tests/Mocker.ts +54 -0
- package/src/v3/tests/all-errors.test.ts +157 -0
- package/src/v3/tests/anyunknown.test.ts +28 -0
- package/src/v3/tests/array.test.ts +71 -0
- package/src/v3/tests/async-parsing.test.ts +388 -0
- package/src/v3/tests/async-refinements.test.ts +46 -0
- package/src/v3/tests/base.test.ts +29 -0
- package/src/v3/tests/bigint.test.ts +55 -0
- package/src/v3/tests/branded.test.ts +53 -0
- package/src/v3/tests/catch.test.ts +220 -0
- package/src/v3/tests/coerce.test.ts +133 -0
- package/src/v3/tests/complex.test.ts +70 -0
- package/src/v3/tests/custom.test.ts +31 -0
- package/src/v3/tests/date.test.ts +32 -0
- package/src/v3/tests/deepmasking.test.ts +186 -0
- package/src/v3/tests/default.test.ts +112 -0
- package/src/v3/tests/description.test.ts +33 -0
- package/src/v3/tests/discriminated-unions.test.ts +315 -0
- package/src/v3/tests/enum.test.ts +80 -0
- package/src/v3/tests/error.test.ts +586 -0
- package/src/v3/tests/firstparty.test.ts +87 -0
- package/src/v3/tests/firstpartyschematypes.test.ts +21 -0
- package/src/v3/tests/function.test.ts +261 -0
- package/src/v3/tests/generics.test.ts +48 -0
- package/src/v3/tests/instanceof.test.ts +37 -0
- package/src/v3/tests/intersection.test.ts +128 -0
- package/src/v3/tests/language-server.source.ts +76 -0
- package/src/v3/tests/language-server.test.ts +206 -0
- package/src/v3/tests/literal.test.ts +36 -0
- package/src/v3/tests/map.test.ts +110 -0
- package/src/v3/tests/masking.test.ts +4 -0
- package/src/v3/tests/mocker.test.ts +19 -0
- package/src/v3/tests/nan.test.ts +24 -0
- package/src/v3/tests/nativeEnum.test.ts +87 -0
- package/src/v3/tests/nullable.test.ts +42 -0
- package/src/v3/tests/number.test.ts +176 -0
- package/src/v3/tests/object-augmentation.test.ts +29 -0
- package/src/v3/tests/object-in-es5-env.test.ts +29 -0
- package/src/v3/tests/object.test.ts +431 -0
- package/src/v3/tests/optional.test.ts +42 -0
- package/src/v3/tests/parseUtil.test.ts +23 -0
- package/src/v3/tests/parser.test.ts +41 -0
- package/src/v3/tests/partials.test.ts +243 -0
- package/src/v3/tests/pickomit.test.ts +111 -0
- package/src/v3/tests/pipeline.test.ts +29 -0
- package/src/v3/tests/preprocess.test.ts +186 -0
- package/src/v3/tests/primitive.test.ts +440 -0
- package/src/v3/tests/promise.test.ts +90 -0
- package/src/v3/tests/readonly.test.ts +114 -0
- package/src/v3/tests/record.test.ts +171 -0
- package/src/v3/tests/recursive.test.ts +197 -0
- package/src/v3/tests/refine.test.ts +313 -0
- package/src/v3/tests/safeparse.test.ts +27 -0
- package/src/v3/tests/set.test.ts +142 -0
- package/src/v3/tests/standard-schema.test.ts +83 -0
- package/src/v3/tests/string.test.ts +922 -0
- package/src/v3/tests/transformer.test.ts +233 -0
- package/src/v3/tests/tuple.test.ts +90 -0
- package/src/v3/tests/unions.test.ts +57 -0
- package/src/v3/tests/validations.test.ts +133 -0
- package/src/v3/tests/void.test.ts +15 -0
- package/src/v3/types.ts +5162 -0
- package/src/v4/classic/checks.ts +33 -0
- package/src/v4/classic/coerce.ts +27 -0
- package/src/v4/classic/compat.ts +78 -0
- package/src/v4/classic/deep-partial.ts +76 -0
- package/src/v4/classic/errors.ts +97 -0
- package/src/v4/classic/external.ts +57 -0
- package/src/v4/classic/from-json-schema.ts +944 -0
- package/src/v4/classic/in-out.ts +45 -0
- package/src/v4/classic/index.ts +5 -0
- package/src/v4/classic/iso.ts +20 -0
- package/src/v4/classic/parse.ts +88 -0
- package/src/v4/classic/schemas.ts +2994 -0
- package/src/v4/classic/tests/anyunknown.test.ts +26 -0
- package/src/v4/classic/tests/apply.test.ts +86 -0
- package/src/v4/classic/tests/array.test.ts +264 -0
- package/src/v4/classic/tests/assignability.test.ts +402 -0
- package/src/v4/classic/tests/async-parsing.test.ts +381 -0
- package/src/v4/classic/tests/async-refinements.test.ts +68 -0
- package/src/v4/classic/tests/base.test.ts +7 -0
- package/src/v4/classic/tests/bigint.test.ts +89 -0
- package/src/v4/classic/tests/brand.test.ts +106 -0
- package/src/v4/classic/tests/catch.test.ts +604 -0
- package/src/v4/classic/tests/coalesce.test.ts +20 -0
- package/src/v4/classic/tests/codec-examples.test.ts +572 -0
- package/src/v4/classic/tests/codec.test.ts +704 -0
- package/src/v4/classic/tests/coerce.test.ts +160 -0
- package/src/v4/classic/tests/continuability.test.ts +374 -0
- package/src/v4/classic/tests/credit-card.test.ts +76 -0
- package/src/v4/classic/tests/custom.test.ts +40 -0
- package/src/v4/classic/tests/cyclic-data.test.ts +985 -0
- package/src/v4/classic/tests/date.test.ts +92 -0
- package/src/v4/classic/tests/datetime.test.ts +316 -0
- package/src/v4/classic/tests/deep-partial.test.ts +380 -0
- package/src/v4/classic/tests/default-locale.test.ts +32 -0
- package/src/v4/classic/tests/default.test.ts +455 -0
- package/src/v4/classic/tests/describe-meta-checks.test.ts +27 -0
- package/src/v4/classic/tests/description.test.ts +32 -0
- package/src/v4/classic/tests/detached-methods.test.ts +226 -0
- package/src/v4/classic/tests/discriminated-unions.test.ts +942 -0
- package/src/v4/classic/tests/enum.test.ts +305 -0
- package/src/v4/classic/tests/error-utils.test.ts +917 -0
- package/src/v4/classic/tests/error.test.ts +1108 -0
- package/src/v4/classic/tests/file.test.ts +96 -0
- package/src/v4/classic/tests/firstparty.test.ts +179 -0
- package/src/v4/classic/tests/fix-json-issue.test.ts +26 -0
- package/src/v4/classic/tests/from-json-schema.test.ts +1467 -0
- package/src/v4/classic/tests/function.test.ts +391 -0
- package/src/v4/classic/tests/generics.test.ts +72 -0
- package/src/v4/classic/tests/global-config.test.ts +32 -0
- package/src/v4/classic/tests/hash.test.ts +67 -0
- package/src/v4/classic/tests/iban.test.ts +81 -0
- package/src/v4/classic/tests/in-out.test.ts +159 -0
- package/src/v4/classic/tests/index.test.ts +958 -0
- package/src/v4/classic/tests/instance-footprint.test.ts +319 -0
- package/src/v4/classic/tests/instanceof.test.ts +127 -0
- package/src/v4/classic/tests/intersection.test.ts +334 -0
- package/src/v4/classic/tests/issue-schema.test.ts +215 -0
- package/src/v4/classic/tests/jitless-allows-eval.test.ts +39 -0
- package/src/v4/classic/tests/json.test.ts +109 -0
- package/src/v4/classic/tests/lazy.test.ts +262 -0
- package/src/v4/classic/tests/literal.test.ts +128 -0
- package/src/v4/classic/tests/locales_ka.test.ts +29 -0
- package/src/v4/classic/tests/locales_ro.test.ts +24 -0
- package/src/v4/classic/tests/map.test.ts +342 -0
- package/src/v4/classic/tests/nan.test.ts +21 -0
- package/src/v4/classic/tests/nested-refine.test.ts +168 -0
- package/src/v4/classic/tests/nonoptional.test.ts +101 -0
- package/src/v4/classic/tests/nullable.test.ts +22 -0
- package/src/v4/classic/tests/number.test.ts +401 -0
- package/src/v4/classic/tests/object.test.ts +1006 -0
- package/src/v4/classic/tests/optin-ladder.test.ts +235 -0
- package/src/v4/classic/tests/optional.test.ts +366 -0
- package/src/v4/classic/tests/partial.test.ts +497 -0
- package/src/v4/classic/tests/pickomit.test.ts +211 -0
- package/src/v4/classic/tests/pipe.test.ts +101 -0
- package/src/v4/classic/tests/prefault.test.ts +144 -0
- package/src/v4/classic/tests/preprocess-types.test.ts +44 -0
- package/src/v4/classic/tests/preprocess.test.ts +351 -0
- package/src/v4/classic/tests/primitive.test.ts +175 -0
- package/src/v4/classic/tests/promise.test.ts +81 -0
- package/src/v4/classic/tests/properties.test.ts +141 -0
- package/src/v4/classic/tests/prototypes.test.ts +23 -0
- package/src/v4/classic/tests/readonly.test.ts +184 -0
- package/src/v4/classic/tests/record.test.ts +885 -0
- package/src/v4/classic/tests/recursive-types.test.ts +707 -0
- package/src/v4/classic/tests/redos.test.ts +68 -0
- package/src/v4/classic/tests/refine.test.ts +693 -0
- package/src/v4/classic/tests/registries.test.ts +243 -0
- package/src/v4/classic/tests/set.test.ts +190 -0
- package/src/v4/classic/tests/standard-schema.test.ts +153 -0
- package/src/v4/classic/tests/string-formats.test.ts +125 -0
- package/src/v4/classic/tests/string.test.ts +1440 -0
- package/src/v4/classic/tests/stringbool.test.ts +124 -0
- package/src/v4/classic/tests/template-literal.test.ts +814 -0
- package/src/v4/classic/tests/to-json-schema-methods.test.ts +438 -0
- package/src/v4/classic/tests/to-json-schema.test.ts +4733 -0
- package/src/v4/classic/tests/transform.test.ts +378 -0
- package/src/v4/classic/tests/tuple.test.ts +511 -0
- package/src/v4/classic/tests/union.test.ts +310 -0
- package/src/v4/classic/tests/url.test.ts +13 -0
- package/src/v4/classic/tests/validate.test.ts +645 -0
- package/src/v4/classic/tests/validations.test.ts +283 -0
- package/src/v4/classic/tests/void.test.ts +12 -0
- package/src/v4/core/api.ts +1913 -0
- package/src/v4/core/checks.ts +1274 -0
- package/src/v4/core/compile.ts +2315 -0
- package/src/v4/core/core.ts +230 -0
- package/src/v4/core/doc.ts +52 -0
- package/src/v4/core/errors.ts +546 -0
- package/src/v4/core/index.ts +19 -0
- package/src/v4/core/json-schema-generator.ts +131 -0
- package/src/v4/core/json-schema-processors.ts +934 -0
- package/src/v4/core/json-schema.ts +148 -0
- package/src/v4/core/memoizer.ts +331 -0
- package/src/v4/core/parse.ts +309 -0
- package/src/v4/core/regexes.ts +217 -0
- package/src/v4/core/registries.ts +109 -0
- package/src/v4/core/schemas.ts +5295 -0
- package/src/v4/core/standard-schema.ts +159 -0
- package/src/v4/core/tests/cached.test.ts +54 -0
- package/src/v4/core/tests/compile-differential.test.ts +1004 -0
- package/src/v4/core/tests/compile-generative.test.ts +445 -0
- package/src/v4/core/tests/compile-global.test.ts +89 -0
- package/src/v4/core/tests/compile-off-by-default.test.ts +26 -0
- package/src/v4/core/tests/compile-stats.test.ts +34 -0
- package/src/v4/core/tests/compile.test.ts +2040 -0
- package/src/v4/core/tests/email-regex.test.ts +140 -0
- package/src/v4/core/tests/extend.test.ts +59 -0
- package/src/v4/core/tests/index.test.ts +46 -0
- package/src/v4/core/tests/locales/be.test.ts +124 -0
- package/src/v4/core/tests/locales/el.test.ts +214 -0
- package/src/v4/core/tests/locales/en.test.ts +22 -0
- package/src/v4/core/tests/locales/es.test.ts +180 -0
- package/src/v4/core/tests/locales/fr.test.ts +72 -0
- package/src/v4/core/tests/locales/he.test.ts +379 -0
- package/src/v4/core/tests/locales/hr.test.ts +163 -0
- package/src/v4/core/tests/locales/nl.test.ts +46 -0
- package/src/v4/core/tests/locales/parity.test.ts +42 -0
- package/src/v4/core/tests/locales/ru.test.ts +128 -0
- package/src/v4/core/tests/locales/tg.test.ts +85 -0
- package/src/v4/core/tests/locales/tk.test.ts +69 -0
- package/src/v4/core/tests/locales/tr.test.ts +69 -0
- package/src/v4/core/tests/locales/uz.test.ts +105 -0
- package/src/v4/core/tests/polyfill-collision.test.ts +46 -0
- package/src/v4/core/tests/record-constructor.test.ts +125 -0
- package/src/v4/core/tests/recursive-tuples.test.ts +45 -0
- package/src/v4/core/tests/treeshake.test.ts +51 -0
- package/src/v4/core/tests/url-no-canparse.test.ts +133 -0
- package/src/v4/core/to-json-schema.ts +857 -0
- package/src/v4/core/util.ts +1284 -0
- package/src/v4/core/versions.ts +5 -0
- package/src/v4/core/visit.ts +193 -0
- package/src/v4/core/zsf.ts +323 -0
- package/src/v4/index.ts +4 -0
- package/src/v4/locales/ar.ts +120 -0
- package/src/v4/locales/az.ts +116 -0
- package/src/v4/locales/be.ts +188 -0
- package/src/v4/locales/bg.ts +133 -0
- package/src/v4/locales/bn.ts +123 -0
- package/src/v4/locales/ca.ts +121 -0
- package/src/v4/locales/ckb.ts +140 -0
- package/src/v4/locales/cs.ts +123 -0
- package/src/v4/locales/da.ts +128 -0
- package/src/v4/locales/de.ts +121 -0
- package/src/v4/locales/el.ts +124 -0
- package/src/v4/locales/en.ts +136 -0
- package/src/v4/locales/eo.ts +123 -0
- package/src/v4/locales/es.ts +145 -0
- package/src/v4/locales/fa.ts +131 -0
- package/src/v4/locales/fi.ts +126 -0
- package/src/v4/locales/fr-CA.ts +121 -0
- package/src/v4/locales/fr.ts +139 -0
- package/src/v4/locales/gu.ts +123 -0
- package/src/v4/locales/he.ts +253 -0
- package/src/v4/locales/hi.ts +126 -0
- package/src/v4/locales/hr.ts +135 -0
- package/src/v4/locales/hu.ts +122 -0
- package/src/v4/locales/hy.ts +175 -0
- package/src/v4/locales/id.ts +120 -0
- package/src/v4/locales/index.ts +63 -0
- package/src/v4/locales/is.ts +124 -0
- package/src/v4/locales/it.ts +121 -0
- package/src/v4/locales/ja.ts +119 -0
- package/src/v4/locales/ka.ts +128 -0
- package/src/v4/locales/kh.ts +7 -0
- package/src/v4/locales/km.ts +124 -0
- package/src/v4/locales/kn.ts +126 -0
- package/src/v4/locales/ko.ts +126 -0
- package/src/v4/locales/lt.ts +243 -0
- package/src/v4/locales/mk.ts +123 -0
- package/src/v4/locales/ms.ts +120 -0
- package/src/v4/locales/ne.ts +128 -0
- package/src/v4/locales/nl.ts +126 -0
- package/src/v4/locales/nn.ts +121 -0
- package/src/v4/locales/no.ts +121 -0
- package/src/v4/locales/ota.ts +122 -0
- package/src/v4/locales/pl.ts +123 -0
- package/src/v4/locales/ps.ts +131 -0
- package/src/v4/locales/pt-BR.ts +161 -0
- package/src/v4/locales/pt.ts +159 -0
- package/src/v4/locales/ro.ts +132 -0
- package/src/v4/locales/ru.ts +188 -0
- package/src/v4/locales/sk.ts +123 -0
- package/src/v4/locales/sl.ts +123 -0
- package/src/v4/locales/sv.ts +124 -0
- package/src/v4/locales/ta.ts +123 -0
- package/src/v4/locales/tg.ts +135 -0
- package/src/v4/locales/th.ts +124 -0
- package/src/v4/locales/tk.ts +113 -0
- package/src/v4/locales/tr.ts +116 -0
- package/src/v4/locales/ua.ts +7 -0
- package/src/v4/locales/uk.ts +122 -0
- package/src/v4/locales/ur.ts +124 -0
- package/src/v4/locales/uz.ts +120 -0
- package/src/v4/locales/vi.ts +122 -0
- package/src/v4/locales/yo.ts +129 -0
- package/src/v4/locales/zh-CN.ts +121 -0
- package/src/v4/locales/zh-TW.ts +120 -0
- package/src/v4/mini/checks.ts +33 -0
- package/src/v4/mini/coerce.ts +27 -0
- package/src/v4/mini/deep-partial.ts +73 -0
- package/src/v4/mini/external.ts +52 -0
- package/src/v4/mini/in-out.ts +45 -0
- package/src/v4/mini/index.ts +3 -0
- package/src/v4/mini/iso.ts +66 -0
- package/src/v4/mini/parse.ts +16 -0
- package/src/v4/mini/schemas.ts +2093 -0
- package/src/v4/mini/tests/apply.test.ts +57 -0
- package/src/v4/mini/tests/assignability.test.ts +190 -0
- package/src/v4/mini/tests/brand.test.ts +94 -0
- package/src/v4/mini/tests/checks.test.ts +158 -0
- package/src/v4/mini/tests/codec.test.ts +582 -0
- package/src/v4/mini/tests/computed.test.ts +30 -0
- package/src/v4/mini/tests/cyclic-data.test.ts +84 -0
- package/src/v4/mini/tests/deep-partial.test.ts +54 -0
- package/src/v4/mini/tests/error.test.ts +41 -0
- package/src/v4/mini/tests/functions.test.ts +14 -0
- package/src/v4/mini/tests/index.test.ts +1148 -0
- package/src/v4/mini/tests/number.test.ts +109 -0
- package/src/v4/mini/tests/object.test.ts +292 -0
- package/src/v4/mini/tests/prototypes.test.ts +43 -0
- package/src/v4/mini/tests/recursive-types.test.ts +341 -0
- package/src/v4/mini/tests/standard-schema.test.ts +50 -0
- package/src/v4/mini/tests/string.test.ts +396 -0
- package/src/v4-mini/index.ts +3 -0
- package/v3/YatspError.cjs +167 -0
- package/v3/YatspError.d.cts +164 -0
- package/v3/YatspError.d.ts +164 -0
- package/v3/YatspError.js +143 -0
- package/v3/errors.cjs +36 -0
- package/v3/errors.d.cts +5 -0
- package/v3/errors.d.ts +5 -0
- package/v3/errors.js +9 -0
- package/v3/external.cjs +41 -0
- package/v3/external.d.cts +6 -0
- package/v3/external.d.ts +6 -0
- package/v3/external.js +6 -0
- package/v3/helpers/enumUtil.cjs +21 -0
- package/v3/helpers/enumUtil.d.cts +8 -0
- package/v3/helpers/enumUtil.d.ts +8 -0
- package/v3/helpers/enumUtil.js +1 -0
- package/v3/helpers/errorUtil.cjs +28 -0
- package/v3/helpers/errorUtil.d.cts +9 -0
- package/v3/helpers/errorUtil.d.ts +9 -0
- package/v3/helpers/errorUtil.js +6 -0
- package/v3/helpers/parseUtil.cjs +143 -0
- package/v3/helpers/parseUtil.d.cts +78 -0
- package/v3/helpers/parseUtil.d.ts +78 -0
- package/v3/helpers/parseUtil.js +109 -0
- package/v3/helpers/partialUtil.cjs +21 -0
- package/v3/helpers/partialUtil.d.cts +8 -0
- package/v3/helpers/partialUtil.d.ts +8 -0
- package/v3/helpers/partialUtil.js +1 -0
- package/v3/helpers/typeAliases.cjs +21 -0
- package/v3/helpers/typeAliases.d.cts +2 -0
- package/v3/helpers/typeAliases.d.ts +2 -0
- package/v3/helpers/typeAliases.js +1 -0
- package/v3/helpers/util.cjs +156 -0
- package/v3/helpers/util.d.cts +85 -0
- package/v3/helpers/util.d.ts +85 -0
- package/v3/helpers/util.js +133 -0
- package/v3/index.cjs +52 -0
- package/v3/index.d.cts +4 -0
- package/v3/index.d.ts +4 -0
- package/v3/index.js +4 -0
- package/v3/locales/en.cjs +112 -0
- package/v3/locales/en.d.cts +3 -0
- package/v3/locales/en.d.ts +3 -0
- package/v3/locales/en.js +109 -0
- package/v3/standard-schema.cjs +21 -0
- package/v3/standard-schema.d.cts +102 -0
- package/v3/standard-schema.d.ts +102 -0
- package/v3/standard-schema.js +1 -0
- package/v3/types.cjs +3798 -0
- package/v3/types.d.cts +1034 -0
- package/v3/types.d.ts +1034 -0
- package/v3/types.js +3697 -0
- package/v4/classic/checks.cjs +53 -0
- package/v4/classic/checks.d.cts +1 -0
- package/v4/classic/checks.d.ts +1 -0
- package/v4/classic/checks.js +1 -0
- package/v4/classic/coerce.cjs +66 -0
- package/v4/classic/coerce.d.cts +17 -0
- package/v4/classic/coerce.d.ts +17 -0
- package/v4/classic/coerce.js +17 -0
- package/v4/classic/compat.cjs +80 -0
- package/v4/classic/compat.d.cts +48 -0
- package/v4/classic/compat.d.ts +48 -0
- package/v4/classic/compat.js +31 -0
- package/v4/classic/deep-partial.cjs +58 -0
- package/v4/classic/deep-partial.d.cts +14 -0
- package/v4/classic/deep-partial.d.ts +14 -0
- package/v4/classic/deep-partial.js +13 -0
- package/v4/classic/errors.cjs +102 -0
- package/v4/classic/errors.d.cts +29 -0
- package/v4/classic/errors.d.ts +29 -0
- package/v4/classic/errors.js +57 -0
- package/v4/classic/external.cjs +97 -0
- package/v4/classic/external.d.cts +19 -0
- package/v4/classic/external.d.ts +19 -0
- package/v4/classic/external.js +17 -0
- package/v4/classic/from-json-schema.cjs +926 -0
- package/v4/classic/from-json-schema.d.cts +12 -0
- package/v4/classic/from-json-schema.d.ts +12 -0
- package/v4/classic/from-json-schema.js +881 -0
- package/v4/classic/in-out.cjs +82 -0
- package/v4/classic/in-out.d.cts +8 -0
- package/v4/classic/in-out.d.ts +8 -0
- package/v4/classic/in-out.js +36 -0
- package/v4/classic/index.cjs +52 -0
- package/v4/classic/index.d.cts +3 -0
- package/v4/classic/index.d.ts +3 -0
- package/v4/classic/index.js +4 -0
- package/v4/classic/iso.cjs +68 -0
- package/v4/classic/iso.d.cts +7 -0
- package/v4/classic/iso.d.ts +7 -0
- package/v4/classic/iso.js +15 -0
- package/v4/classic/parse.cjs +63 -0
- package/v4/classic/parse.d.cts +44 -0
- package/v4/classic/parse.d.ts +44 -0
- package/v4/classic/parse.js +16 -0
- package/v4/classic/schemas.cjs +1676 -0
- package/v4/classic/schemas.d.cts +816 -0
- package/v4/classic/schemas.d.ts +816 -0
- package/v4/classic/schemas.js +1535 -0
- package/v4/core/api.cjs +1269 -0
- package/v4/core/api.d.cts +335 -0
- package/v4/core/api.d.ts +335 -0
- package/v4/core/api.js +1107 -0
- package/v4/core/checks.cjs +561 -0
- package/v4/core/checks.d.cts +294 -0
- package/v4/core/checks.d.ts +294 -0
- package/v4/core/checks.js +516 -0
- package/v4/core/compile.cjs +1908 -0
- package/v4/core/compile.d.cts +65 -0
- package/v4/core/compile.d.ts +65 -0
- package/v4/core/compile.js +1858 -0
- package/v4/core/core.cjs +167 -0
- package/v4/core/core.d.cts +82 -0
- package/v4/core/core.d.ts +82 -0
- package/v4/core/core.js +141 -0
- package/v4/core/doc.cjs +61 -0
- package/v4/core/doc.d.cts +16 -0
- package/v4/core/doc.d.ts +16 -0
- package/v4/core/doc.js +38 -0
- package/v4/core/errors.cjs +317 -0
- package/v4/core/errors.d.cts +225 -0
- package/v4/core/errors.d.ts +225 -0
- package/v4/core/errors.js +267 -0
- package/v4/core/index.cjs +70 -0
- package/v4/core/index.d.cts +19 -0
- package/v4/core/index.d.ts +19 -0
- package/v4/core/index.js +19 -0
- package/v4/core/json-schema-generator.cjs +122 -0
- package/v4/core/json-schema-generator.d.cts +65 -0
- package/v4/core/json-schema-generator.d.ts +65 -0
- package/v4/core/json-schema-generator.js +99 -0
- package/v4/core/json-schema-processors.cjs +929 -0
- package/v4/core/json-schema-processors.d.cts +65 -0
- package/v4/core/json-schema-processors.d.ts +65 -0
- package/v4/core/json-schema-processors.js +843 -0
- package/v4/core/json-schema.cjs +21 -0
- package/v4/core/json-schema.d.cts +89 -0
- package/v4/core/json-schema.d.ts +89 -0
- package/v4/core/json-schema.js +1 -0
- package/v4/core/memoizer.cjs +360 -0
- package/v4/core/memoizer.d.cts +15 -0
- package/v4/core/memoizer.d.ts +15 -0
- package/v4/core/memoizer.js +311 -0
- package/v4/core/parse.cjs +233 -0
- package/v4/core/parse.d.cts +52 -0
- package/v4/core/parse.d.ts +52 -0
- package/v4/core/parse.js +175 -0
- package/v4/core/regexes.cjs +209 -0
- package/v4/core/regexes.d.cts +90 -0
- package/v4/core/regexes.d.ts +90 -0
- package/v4/core/regexes.js +156 -0
- package/v4/core/registries.cjs +76 -0
- package/v4/core/registries.d.cts +35 -0
- package/v4/core/registries.d.ts +35 -0
- package/v4/core/registries.js +52 -0
- package/v4/core/schemas.cjs +2669 -0
- package/v4/core/schemas.d.cts +1273 -0
- package/v4/core/schemas.d.ts +1273 -0
- package/v4/core/schemas.js +2606 -0
- package/v4/core/standard-schema.cjs +21 -0
- package/v4/core/standard-schema.d.cts +126 -0
- package/v4/core/standard-schema.d.ts +126 -0
- package/v4/core/standard-schema.js +1 -0
- package/v4/core/to-json-schema.cjs +681 -0
- package/v4/core/to-json-schema.d.cts +154 -0
- package/v4/core/to-json-schema.d.ts +154 -0
- package/v4/core/to-json-schema.js +651 -0
- package/v4/core/util.cjs +949 -0
- package/v4/core/util.d.cts +278 -0
- package/v4/core/util.d.ts +278 -0
- package/v4/core/util.js +859 -0
- package/v4/core/versions.cjs +27 -0
- package/v4/core/versions.d.cts +5 -0
- package/v4/core/versions.d.ts +5 -0
- package/v4/core/versions.js +5 -0
- package/v4/core/visit.cjs +214 -0
- package/v4/core/visit.d.cts +30 -0
- package/v4/core/visit.d.ts +30 -0
- package/v4/core/visit.js +169 -0
- package/v4/index.cjs +51 -0
- package/v4/index.d.cts +3 -0
- package/v4/index.d.ts +3 -0
- package/v4/index.js +4 -0
- package/v4/locales/ar.cjs +138 -0
- package/v4/locales/ar.d.cts +5 -0
- package/v4/locales/ar.d.ts +4 -0
- package/v4/locales/ar.js +111 -0
- package/v4/locales/az.cjs +137 -0
- package/v4/locales/az.d.cts +5 -0
- package/v4/locales/az.d.ts +4 -0
- package/v4/locales/az.js +110 -0
- package/v4/locales/be.cjs +195 -0
- package/v4/locales/be.d.cts +5 -0
- package/v4/locales/be.d.ts +4 -0
- package/v4/locales/be.js +168 -0
- package/v4/locales/bg.cjs +152 -0
- package/v4/locales/bg.d.cts +5 -0
- package/v4/locales/bg.d.ts +4 -0
- package/v4/locales/bg.js +125 -0
- package/v4/locales/bn.cjs +140 -0
- package/v4/locales/bn.d.cts +5 -0
- package/v4/locales/bn.d.ts +4 -0
- package/v4/locales/bn.js +113 -0
- package/v4/locales/ca.cjs +139 -0
- package/v4/locales/ca.d.cts +5 -0
- package/v4/locales/ca.d.ts +4 -0
- package/v4/locales/ca.js +112 -0
- package/v4/locales/ckb.cjs +160 -0
- package/v4/locales/ckb.d.cts +5 -0
- package/v4/locales/ckb.d.ts +4 -0
- package/v4/locales/ckb.js +133 -0
- package/v4/locales/cs.cjs +143 -0
- package/v4/locales/cs.d.cts +5 -0
- package/v4/locales/cs.d.ts +4 -0
- package/v4/locales/cs.js +116 -0
- package/v4/locales/da.cjs +147 -0
- package/v4/locales/da.d.cts +5 -0
- package/v4/locales/da.d.ts +4 -0
- package/v4/locales/da.js +120 -0
- package/v4/locales/de.cjs +140 -0
- package/v4/locales/de.d.cts +5 -0
- package/v4/locales/de.d.ts +4 -0
- package/v4/locales/de.js +113 -0
- package/v4/locales/el.cjs +139 -0
- package/v4/locales/el.d.cts +5 -0
- package/v4/locales/el.d.ts +4 -0
- package/v4/locales/el.js +112 -0
- package/v4/locales/en.cjs +152 -0
- package/v4/locales/en.d.cts +5 -0
- package/v4/locales/en.d.ts +4 -0
- package/v4/locales/en.js +125 -0
- package/v4/locales/eo.cjs +141 -0
- package/v4/locales/eo.d.cts +5 -0
- package/v4/locales/eo.d.ts +4 -0
- package/v4/locales/eo.js +114 -0
- package/v4/locales/es.cjs +163 -0
- package/v4/locales/es.d.cts +5 -0
- package/v4/locales/es.d.ts +4 -0
- package/v4/locales/es.js +136 -0
- package/v4/locales/fa.cjs +146 -0
- package/v4/locales/fa.d.cts +5 -0
- package/v4/locales/fa.d.ts +4 -0
- package/v4/locales/fa.js +119 -0
- package/v4/locales/fi.cjs +144 -0
- package/v4/locales/fi.d.cts +5 -0
- package/v4/locales/fi.d.ts +4 -0
- package/v4/locales/fi.js +117 -0
- package/v4/locales/fr-CA.cjs +139 -0
- package/v4/locales/fr-CA.d.cts +5 -0
- package/v4/locales/fr-CA.d.ts +4 -0
- package/v4/locales/fr-CA.js +112 -0
- package/v4/locales/fr.cjs +156 -0
- package/v4/locales/fr.d.cts +5 -0
- package/v4/locales/fr.d.ts +4 -0
- package/v4/locales/fr.js +129 -0
- package/v4/locales/gu.cjs +140 -0
- package/v4/locales/gu.d.cts +5 -0
- package/v4/locales/gu.d.ts +4 -0
- package/v4/locales/gu.js +113 -0
- package/v4/locales/he.cjs +248 -0
- package/v4/locales/he.d.cts +5 -0
- package/v4/locales/he.d.ts +4 -0
- package/v4/locales/he.js +221 -0
- package/v4/locales/hi.cjs +138 -0
- package/v4/locales/hi.d.cts +5 -0
- package/v4/locales/hi.d.ts +4 -0
- package/v4/locales/hi.js +111 -0
- package/v4/locales/hr.cjs +153 -0
- package/v4/locales/hr.d.cts +5 -0
- package/v4/locales/hr.d.ts +4 -0
- package/v4/locales/hr.js +126 -0
- package/v4/locales/hu.cjs +140 -0
- package/v4/locales/hu.d.cts +5 -0
- package/v4/locales/hu.d.ts +4 -0
- package/v4/locales/hu.js +113 -0
- package/v4/locales/hy.cjs +185 -0
- package/v4/locales/hy.d.cts +5 -0
- package/v4/locales/hy.d.ts +4 -0
- package/v4/locales/hy.js +158 -0
- package/v4/locales/id.cjs +138 -0
- package/v4/locales/id.d.cts +5 -0
- package/v4/locales/id.d.ts +4 -0
- package/v4/locales/id.js +111 -0
- package/v4/locales/index.cjs +152 -0
- package/v4/locales/index.d.cts +63 -0
- package/v4/locales/index.d.ts +63 -0
- package/v4/locales/index.js +63 -0
- package/v4/locales/is.cjs +141 -0
- package/v4/locales/is.d.cts +5 -0
- package/v4/locales/is.d.ts +4 -0
- package/v4/locales/is.js +114 -0
- package/v4/locales/it.cjs +140 -0
- package/v4/locales/it.d.cts +5 -0
- package/v4/locales/it.d.ts +4 -0
- package/v4/locales/it.js +113 -0
- package/v4/locales/ja.cjs +139 -0
- package/v4/locales/ja.d.cts +5 -0
- package/v4/locales/ja.d.ts +4 -0
- package/v4/locales/ja.js +112 -0
- package/v4/locales/ka.cjs +144 -0
- package/v4/locales/ka.d.cts +5 -0
- package/v4/locales/ka.d.ts +4 -0
- package/v4/locales/ka.js +117 -0
- package/v4/locales/kh.cjs +12 -0
- package/v4/locales/kh.d.cts +5 -0
- package/v4/locales/kh.d.ts +5 -0
- package/v4/locales/kh.js +5 -0
- package/v4/locales/km.cjs +142 -0
- package/v4/locales/km.d.cts +5 -0
- package/v4/locales/km.d.ts +4 -0
- package/v4/locales/km.js +115 -0
- package/v4/locales/kn.cjs +143 -0
- package/v4/locales/kn.d.cts +5 -0
- package/v4/locales/kn.d.ts +4 -0
- package/v4/locales/kn.js +116 -0
- package/v4/locales/ko.cjs +143 -0
- package/v4/locales/ko.d.cts +5 -0
- package/v4/locales/ko.d.ts +4 -0
- package/v4/locales/ko.js +116 -0
- package/v4/locales/lt.cjs +234 -0
- package/v4/locales/lt.d.cts +5 -0
- package/v4/locales/lt.d.ts +4 -0
- package/v4/locales/lt.js +207 -0
- package/v4/locales/mk.cjs +141 -0
- package/v4/locales/mk.d.cts +5 -0
- package/v4/locales/mk.d.ts +4 -0
- package/v4/locales/mk.js +114 -0
- package/v4/locales/ms.cjs +139 -0
- package/v4/locales/ms.d.cts +5 -0
- package/v4/locales/ms.d.ts +4 -0
- package/v4/locales/ms.js +112 -0
- package/v4/locales/ne.cjs +138 -0
- package/v4/locales/ne.d.cts +5 -0
- package/v4/locales/ne.d.ts +4 -0
- package/v4/locales/ne.js +111 -0
- package/v4/locales/nl.cjs +142 -0
- package/v4/locales/nl.d.cts +5 -0
- package/v4/locales/nl.d.ts +4 -0
- package/v4/locales/nl.js +115 -0
- package/v4/locales/nn.cjs +140 -0
- package/v4/locales/nn.d.cts +5 -0
- package/v4/locales/nn.d.ts +4 -0
- package/v4/locales/nn.js +113 -0
- package/v4/locales/no.cjs +140 -0
- package/v4/locales/no.d.cts +5 -0
- package/v4/locales/no.d.ts +4 -0
- package/v4/locales/no.js +113 -0
- package/v4/locales/ota.cjs +141 -0
- package/v4/locales/ota.d.cts +5 -0
- package/v4/locales/ota.d.ts +4 -0
- package/v4/locales/ota.js +114 -0
- package/v4/locales/pl.cjs +141 -0
- package/v4/locales/pl.d.cts +5 -0
- package/v4/locales/pl.d.ts +4 -0
- package/v4/locales/pl.js +114 -0
- package/v4/locales/ps.cjs +146 -0
- package/v4/locales/ps.d.cts +5 -0
- package/v4/locales/ps.d.ts +4 -0
- package/v4/locales/ps.js +119 -0
- package/v4/locales/pt-BR.cjs +170 -0
- package/v4/locales/pt-BR.d.cts +5 -0
- package/v4/locales/pt-BR.d.ts +4 -0
- package/v4/locales/pt-BR.js +143 -0
- package/v4/locales/pt.cjs +169 -0
- package/v4/locales/pt.d.cts +5 -0
- package/v4/locales/pt.d.ts +4 -0
- package/v4/locales/pt.js +142 -0
- package/v4/locales/ro.cjs +149 -0
- package/v4/locales/ro.d.cts +5 -0
- package/v4/locales/ro.d.ts +4 -0
- package/v4/locales/ro.js +122 -0
- package/v4/locales/ru.cjs +195 -0
- package/v4/locales/ru.d.cts +5 -0
- package/v4/locales/ru.d.ts +4 -0
- package/v4/locales/ru.js +168 -0
- package/v4/locales/sk.cjs +143 -0
- package/v4/locales/sk.d.cts +5 -0
- package/v4/locales/sk.d.ts +4 -0
- package/v4/locales/sk.js +116 -0
- package/v4/locales/sl.cjs +141 -0
- package/v4/locales/sl.d.cts +5 -0
- package/v4/locales/sl.d.ts +4 -0
- package/v4/locales/sl.js +114 -0
- package/v4/locales/sv.cjs +142 -0
- package/v4/locales/sv.d.cts +5 -0
- package/v4/locales/sv.d.ts +4 -0
- package/v4/locales/sv.js +115 -0
- package/v4/locales/ta.cjs +142 -0
- package/v4/locales/ta.d.cts +5 -0
- package/v4/locales/ta.d.ts +4 -0
- package/v4/locales/ta.js +115 -0
- package/v4/locales/tg.cjs +144 -0
- package/v4/locales/tg.d.cts +5 -0
- package/v4/locales/tg.d.ts +4 -0
- package/v4/locales/tg.js +117 -0
- package/v4/locales/th.cjs +142 -0
- package/v4/locales/th.d.cts +5 -0
- package/v4/locales/th.d.ts +4 -0
- package/v4/locales/th.js +115 -0
- package/v4/locales/tk.cjs +134 -0
- package/v4/locales/tk.d.cts +5 -0
- package/v4/locales/tk.d.ts +4 -0
- package/v4/locales/tk.js +107 -0
- package/v4/locales/tr.cjs +137 -0
- package/v4/locales/tr.d.cts +5 -0
- package/v4/locales/tr.d.ts +4 -0
- package/v4/locales/tr.js +110 -0
- package/v4/locales/ua.cjs +12 -0
- package/v4/locales/ua.d.cts +5 -0
- package/v4/locales/ua.d.ts +5 -0
- package/v4/locales/ua.js +5 -0
- package/v4/locales/uk.cjs +140 -0
- package/v4/locales/uk.d.cts +5 -0
- package/v4/locales/uk.d.ts +4 -0
- package/v4/locales/uk.js +113 -0
- package/v4/locales/ur.cjs +142 -0
- package/v4/locales/ur.d.cts +5 -0
- package/v4/locales/ur.d.ts +4 -0
- package/v4/locales/ur.js +115 -0
- package/v4/locales/uz.cjs +140 -0
- package/v4/locales/uz.d.cts +5 -0
- package/v4/locales/uz.d.ts +4 -0
- package/v4/locales/uz.js +113 -0
- package/v4/locales/vi.cjs +140 -0
- package/v4/locales/vi.d.cts +5 -0
- package/v4/locales/vi.d.ts +4 -0
- package/v4/locales/vi.js +113 -0
- package/v4/locales/yo.cjs +139 -0
- package/v4/locales/yo.d.cts +5 -0
- package/v4/locales/yo.d.ts +4 -0
- package/v4/locales/yo.js +112 -0
- package/v4/locales/zh-CN.cjs +141 -0
- package/v4/locales/zh-CN.d.cts +5 -0
- package/v4/locales/zh-CN.d.ts +4 -0
- package/v4/locales/zh-CN.js +114 -0
- package/v4/locales/zh-TW.cjs +139 -0
- package/v4/locales/zh-TW.d.cts +5 -0
- package/v4/locales/zh-TW.d.ts +4 -0
- package/v4/locales/zh-TW.js +112 -0
- package/v4/mini/checks.cjs +54 -0
- package/v4/mini/checks.d.cts +1 -0
- package/v4/mini/checks.d.ts +1 -0
- package/v4/mini/checks.js +1 -0
- package/v4/mini/coerce.cjs +71 -0
- package/v4/mini/coerce.d.cts +7 -0
- package/v4/mini/coerce.d.ts +7 -0
- package/v4/mini/coerce.js +22 -0
- package/v4/mini/deep-partial.cjs +58 -0
- package/v4/mini/deep-partial.d.cts +14 -0
- package/v4/mini/deep-partial.d.ts +14 -0
- package/v4/mini/deep-partial.js +13 -0
- package/v4/mini/external.cjs +95 -0
- package/v4/mini/external.d.cts +16 -0
- package/v4/mini/external.d.ts +16 -0
- package/v4/mini/external.js +16 -0
- package/v4/mini/in-out.cjs +82 -0
- package/v4/mini/in-out.d.cts +8 -0
- package/v4/mini/in-out.d.ts +8 -0
- package/v4/mini/in-out.js +36 -0
- package/v4/mini/index.cjs +51 -0
- package/v4/mini/index.d.cts +3 -0
- package/v4/mini/index.d.ts +3 -0
- package/v4/mini/index.js +3 -0
- package/v4/mini/iso.cjs +83 -0
- package/v4/mini/iso.d.cts +22 -0
- package/v4/mini/iso.d.ts +22 -0
- package/v4/mini/iso.js +34 -0
- package/v4/mini/parse.cjs +37 -0
- package/v4/mini/parse.d.cts +1 -0
- package/v4/mini/parse.d.ts +1 -0
- package/v4/mini/parse.js +1 -0
- package/v4/mini/schemas.cjs +1149 -0
- package/v4/mini/schemas.d.cts +480 -0
- package/v4/mini/schemas.d.ts +480 -0
- package/v4/mini/schemas.js +1004 -0
- package/v4-mini/index.cjs +51 -0
- package/v4-mini/index.d.cts +3 -0
- package/v4-mini/index.d.ts +3 -0
- package/v4-mini/index.js +3 -0
package/v4/core/util.cjs
ADDED
|
@@ -0,0 +1,949 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CONSTANT_CATCH = exports.Class = exports.BIGINT_FORMAT_RANGES = exports.NUMBER_FORMAT_RANGES = exports.primitiveTypes = exports.propertyKeyTypes = exports.getParsedType = exports.allowsEval = exports.captureStackTrace = void 0;
|
|
4
|
+
exports.assertEqual = assertEqual;
|
|
5
|
+
exports.assertNotEqual = assertNotEqual;
|
|
6
|
+
exports.toYatsp = toYatsp;
|
|
7
|
+
exports.assertIs = assertIs;
|
|
8
|
+
exports.assertNever = assertNever;
|
|
9
|
+
exports.assert = assert;
|
|
10
|
+
exports.getEnumValues = getEnumValues;
|
|
11
|
+
exports.joinValues = joinValues;
|
|
12
|
+
exports.jsonStringifyReplacer = jsonStringifyReplacer;
|
|
13
|
+
exports.cached = cached;
|
|
14
|
+
exports.nullish = nullish;
|
|
15
|
+
exports.cleanRegex = cleanRegex;
|
|
16
|
+
exports.floatSafeRemainder = floatSafeRemainder;
|
|
17
|
+
exports.defineLazy = defineLazy;
|
|
18
|
+
exports.objectClone = objectClone;
|
|
19
|
+
exports.assignProp = assignProp;
|
|
20
|
+
exports.rawShape = rawShape;
|
|
21
|
+
exports.mergeDefs = mergeDefs;
|
|
22
|
+
exports.cloneDef = cloneDef;
|
|
23
|
+
exports.getElementAtPath = getElementAtPath;
|
|
24
|
+
exports.promiseAllObject = promiseAllObject;
|
|
25
|
+
exports.randomString = randomString;
|
|
26
|
+
exports.esc = esc;
|
|
27
|
+
exports.slugify = slugify;
|
|
28
|
+
exports.isObject = isObject;
|
|
29
|
+
exports.isPlainObject = isPlainObject;
|
|
30
|
+
exports.shallowClone = shallowClone;
|
|
31
|
+
exports.numKeys = numKeys;
|
|
32
|
+
exports.escapeRegex = escapeRegex;
|
|
33
|
+
exports.clone = clone;
|
|
34
|
+
exports.normalizeParams = normalizeParams;
|
|
35
|
+
exports.createTransparentProxy = createTransparentProxy;
|
|
36
|
+
exports.stringifyPrimitive = stringifyPrimitive;
|
|
37
|
+
exports.optionalKeys = optionalKeys;
|
|
38
|
+
exports.pick = pick;
|
|
39
|
+
exports.omit = omit;
|
|
40
|
+
exports.extend = extend;
|
|
41
|
+
exports.safeExtend = safeExtend;
|
|
42
|
+
exports.merge = merge;
|
|
43
|
+
exports.partial = partial;
|
|
44
|
+
exports.required = required;
|
|
45
|
+
exports.aborted = aborted;
|
|
46
|
+
exports.explicitlyAborted = explicitlyAborted;
|
|
47
|
+
exports.prefixIssues = prefixIssues;
|
|
48
|
+
exports.unwrapMessage = unwrapMessage;
|
|
49
|
+
exports.attachSchema = attachSchema;
|
|
50
|
+
exports.finalizeIssue = finalizeIssue;
|
|
51
|
+
exports.getSizableOrigin = getSizableOrigin;
|
|
52
|
+
exports.codePointLength = codePointLength;
|
|
53
|
+
exports.getLengthableOrigin = getLengthableOrigin;
|
|
54
|
+
exports.parsedType = parsedType;
|
|
55
|
+
exports.issue = issue;
|
|
56
|
+
exports.cleanEnum = cleanEnum;
|
|
57
|
+
exports.base64ToUint8Array = base64ToUint8Array;
|
|
58
|
+
exports.uint8ArrayToBase64 = uint8ArrayToBase64;
|
|
59
|
+
exports.base64urlToUint8Array = base64urlToUint8Array;
|
|
60
|
+
exports.uint8ArrayToBase64url = uint8ArrayToBase64url;
|
|
61
|
+
exports.hexToUint8Array = hexToUint8Array;
|
|
62
|
+
exports.uint8ArrayToHex = uint8ArrayToHex;
|
|
63
|
+
exports.members = members;
|
|
64
|
+
exports.own = own;
|
|
65
|
+
exports.hide = hide;
|
|
66
|
+
exports.derived = derived;
|
|
67
|
+
exports.defineLazyInternal = defineLazyInternal;
|
|
68
|
+
exports.installLazyProp = installLazyProp;
|
|
69
|
+
exports.constantCatch = constantCatch;
|
|
70
|
+
const core_js_1 = require("./core.cjs");
|
|
71
|
+
// functions
|
|
72
|
+
function assertEqual(val) {
|
|
73
|
+
return val;
|
|
74
|
+
}
|
|
75
|
+
function assertNotEqual(val) {
|
|
76
|
+
return val;
|
|
77
|
+
}
|
|
78
|
+
function toYatsp() {
|
|
79
|
+
return (schema) => schema;
|
|
80
|
+
}
|
|
81
|
+
function assertIs(_arg) { }
|
|
82
|
+
function assertNever(_x) {
|
|
83
|
+
throw new Error("Unexpected value in exhaustive check");
|
|
84
|
+
}
|
|
85
|
+
function assert(_) { }
|
|
86
|
+
function getEnumValues(entries) {
|
|
87
|
+
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
88
|
+
const values = Object.entries(entries)
|
|
89
|
+
.filter(([k, _]) => numericValues.indexOf(+k) === -1)
|
|
90
|
+
.map(([_, v]) => v);
|
|
91
|
+
return values;
|
|
92
|
+
}
|
|
93
|
+
function joinValues(array, separator = "|") {
|
|
94
|
+
return array.map((val) => stringifyPrimitive(val)).join(separator);
|
|
95
|
+
}
|
|
96
|
+
function jsonStringifyReplacer(_, value) {
|
|
97
|
+
if (typeof value === "bigint")
|
|
98
|
+
return value.toString();
|
|
99
|
+
return value;
|
|
100
|
+
}
|
|
101
|
+
// the accessor lives on a shared prototype: an own accessor makes every box a dictionary-mode object (~360 B and a slow load per read against ~100 B and an inlined getter here)
|
|
102
|
+
class Cached {
|
|
103
|
+
constructor(getter) {
|
|
104
|
+
this._getter = getter;
|
|
105
|
+
this._value = undefined;
|
|
106
|
+
}
|
|
107
|
+
get value() {
|
|
108
|
+
const getter = this._getter;
|
|
109
|
+
if (getter !== undefined) {
|
|
110
|
+
this._value = getter();
|
|
111
|
+
this._getter = undefined;
|
|
112
|
+
}
|
|
113
|
+
return this._value;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function cached(getter) {
|
|
117
|
+
return new Cached(getter);
|
|
118
|
+
}
|
|
119
|
+
function nullish(input) {
|
|
120
|
+
return input === null || input === undefined;
|
|
121
|
+
}
|
|
122
|
+
function cleanRegex(source) {
|
|
123
|
+
const start = source.startsWith("^") ? 1 : 0;
|
|
124
|
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
125
|
+
return source.slice(start, end);
|
|
126
|
+
}
|
|
127
|
+
function floatSafeRemainder(val, step) {
|
|
128
|
+
const ratio = val / step;
|
|
129
|
+
const roundedRatio = Math.round(ratio);
|
|
130
|
+
// `val` and `step` each round to a double before the division rounds again, so a true decimal multiple's quotient can sit up to 1.5 of these scaled epsilons from the integer. A 1x tolerance therefore rejected 2.03 as a multiple of 0.07; 4x covers the worst case with margin.
|
|
131
|
+
const tolerance = 4 * Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
|
132
|
+
if (Math.abs(ratio - roundedRatio) < tolerance)
|
|
133
|
+
return 0;
|
|
134
|
+
return ratio - roundedRatio;
|
|
135
|
+
}
|
|
136
|
+
const EVALUATING = /* @__PURE__*/ Symbol("evaluating");
|
|
137
|
+
function defineLazy(object, key, getter) {
|
|
138
|
+
let value = undefined;
|
|
139
|
+
Object.defineProperty(object, key, {
|
|
140
|
+
get() {
|
|
141
|
+
if (value === EVALUATING) {
|
|
142
|
+
// Circular reference detected, return undefined to break the cycle
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
if (value === undefined) {
|
|
146
|
+
value = EVALUATING;
|
|
147
|
+
value = getter();
|
|
148
|
+
}
|
|
149
|
+
return value;
|
|
150
|
+
},
|
|
151
|
+
set(v) {
|
|
152
|
+
Object.defineProperty(object, key, {
|
|
153
|
+
value: v,
|
|
154
|
+
// configurable: true,
|
|
155
|
+
});
|
|
156
|
+
// object[key] = v;
|
|
157
|
+
},
|
|
158
|
+
configurable: true,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
function objectClone(obj) {
|
|
162
|
+
return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
|
|
163
|
+
}
|
|
164
|
+
function assignProp(target, prop, value) {
|
|
165
|
+
Object.defineProperty(target, prop, {
|
|
166
|
+
value,
|
|
167
|
+
writable: true,
|
|
168
|
+
enumerable: true,
|
|
169
|
+
configurable: true,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it.
|
|
174
|
+
*
|
|
175
|
+
* Its keys and descriptors read without invoking anything, which is what lets a discriminated union check its discriminator, and the cycle walk read a shape, without resolving a getter that references the schema being constructed. A def that answers `shape` from an accessor of its own has none.
|
|
176
|
+
*/
|
|
177
|
+
function rawShape(def) {
|
|
178
|
+
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
179
|
+
return desc?.get ? desc.get.raw : desc?.value;
|
|
180
|
+
}
|
|
181
|
+
// where a builder reads its source's keys and descriptors, resolving only a shape a def answers for itself. A shape resolves by object spread, so only its enumerable keys are ever part of it.
|
|
182
|
+
function sourceShape(schema) {
|
|
183
|
+
return rawShape(schema._yatsp.def) ?? schema._yatsp.def.shape;
|
|
184
|
+
}
|
|
185
|
+
// a key whose value is not settled yet, self-caching so every read after the first gets the same one
|
|
186
|
+
function deferProp(target, key, getter) {
|
|
187
|
+
Object.defineProperty(target, key, {
|
|
188
|
+
get() {
|
|
189
|
+
const value = getter();
|
|
190
|
+
assignProp(this, key, value);
|
|
191
|
+
return value;
|
|
192
|
+
},
|
|
193
|
+
enumerable: true,
|
|
194
|
+
configurable: true,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
// Writes a settled key. A plain assignment is much cheaper than `defineProperty` and produces the same descriptor, but it runs whatever setter already answers to the key — an accessor this shape deferred, or an inherited one, which `__proto__` has on every object and prototype pollution can add for any name.
|
|
198
|
+
function putProp(target, key, value) {
|
|
199
|
+
if (key in target)
|
|
200
|
+
assignProp(target, key, value);
|
|
201
|
+
else
|
|
202
|
+
target[key] = value;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Copies `keys` of `source`'s shape onto `target`, each value passed through `wrap`.
|
|
206
|
+
*
|
|
207
|
+
* A key the source has resolved is copied through now, so the derived shape states it outright and nothing has to resolve it to learn what it holds. A key the source still defers stays deferred, and reads back through the source's own `shape`, so it resolves once and both shapes get that one schema.
|
|
208
|
+
*/
|
|
209
|
+
function mirrorShape(target, source, keys, wrap) {
|
|
210
|
+
const raw = sourceShape(source);
|
|
211
|
+
for (const key of keys) {
|
|
212
|
+
const desc = Object.getOwnPropertyDescriptor(raw, key);
|
|
213
|
+
if (!desc.enumerable)
|
|
214
|
+
continue;
|
|
215
|
+
if (desc.get) {
|
|
216
|
+
deferProp(target, key, () => {
|
|
217
|
+
const value = source._yatsp.def.shape[key];
|
|
218
|
+
return wrap ? wrap(value, key) : value;
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
else
|
|
222
|
+
putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
// same, for a plain shape a caller passed rather than a schema's
|
|
226
|
+
function mirrorProps(target, source) {
|
|
227
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
228
|
+
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
229
|
+
if (!desc.enumerable)
|
|
230
|
+
continue;
|
|
231
|
+
if (desc.get)
|
|
232
|
+
deferProp(target, key, () => source[key]);
|
|
233
|
+
else
|
|
234
|
+
putProp(target, key, desc.value);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
function mergeDefs(...defs) {
|
|
238
|
+
const mergedDescriptors = {};
|
|
239
|
+
for (const def of defs) {
|
|
240
|
+
const descriptors = Object.getOwnPropertyDescriptors(def);
|
|
241
|
+
Object.assign(mergedDescriptors, descriptors);
|
|
242
|
+
}
|
|
243
|
+
return Object.defineProperties({}, mergedDescriptors);
|
|
244
|
+
}
|
|
245
|
+
function cloneDef(schema) {
|
|
246
|
+
return mergeDefs(schema._yatsp.def);
|
|
247
|
+
}
|
|
248
|
+
function getElementAtPath(obj, path) {
|
|
249
|
+
if (!path)
|
|
250
|
+
return obj;
|
|
251
|
+
return path.reduce((acc, key) => acc?.[key], obj);
|
|
252
|
+
}
|
|
253
|
+
function promiseAllObject(promisesObj) {
|
|
254
|
+
const keys = Object.keys(promisesObj);
|
|
255
|
+
const promises = keys.map((key) => promisesObj[key]);
|
|
256
|
+
return Promise.all(promises).then((results) => {
|
|
257
|
+
const resolvedObj = {};
|
|
258
|
+
for (let i = 0; i < keys.length; i++) {
|
|
259
|
+
resolvedObj[keys[i]] = results[i];
|
|
260
|
+
}
|
|
261
|
+
return resolvedObj;
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
function randomString(length = 10) {
|
|
265
|
+
const chars = "abcdefghijklmnopqrstuvwxyz";
|
|
266
|
+
let str = "";
|
|
267
|
+
for (let i = 0; i < length; i++) {
|
|
268
|
+
str += chars[Math.floor(Math.random() * chars.length)];
|
|
269
|
+
}
|
|
270
|
+
return str;
|
|
271
|
+
}
|
|
272
|
+
function esc(str) {
|
|
273
|
+
return JSON.stringify(str);
|
|
274
|
+
}
|
|
275
|
+
function slugify(input) {
|
|
276
|
+
return input
|
|
277
|
+
.toLowerCase()
|
|
278
|
+
.trim()
|
|
279
|
+
.replace(/[^\w\s-]/g, "")
|
|
280
|
+
.replace(/[\s_-]+/g, "-")
|
|
281
|
+
.replace(/^-+|-+$/g, "");
|
|
282
|
+
}
|
|
283
|
+
exports.captureStackTrace = ("captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => { });
|
|
284
|
+
function isObject(data) {
|
|
285
|
+
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
286
|
+
}
|
|
287
|
+
exports.allowsEval = cached(() => {
|
|
288
|
+
// Skip the probe under `jitless`: strict CSPs report the caught `new Function` as a `securitypolicyviolation` even though the throw is swallowed.
|
|
289
|
+
if (core_js_1.globalConfig.jitless) {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
// @ts-ignore
|
|
293
|
+
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
try {
|
|
297
|
+
const F = Function;
|
|
298
|
+
new F("");
|
|
299
|
+
return true;
|
|
300
|
+
}
|
|
301
|
+
catch (_) {
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
function isPlainObject(o) {
|
|
306
|
+
if (isObject(o) === false)
|
|
307
|
+
return false;
|
|
308
|
+
// modified constructor
|
|
309
|
+
const ctor = o.constructor;
|
|
310
|
+
if (ctor === undefined)
|
|
311
|
+
return true;
|
|
312
|
+
if (typeof ctor !== "function")
|
|
313
|
+
return true;
|
|
314
|
+
// modified prototype
|
|
315
|
+
const prot = ctor.prototype;
|
|
316
|
+
if (isObject(prot) === false)
|
|
317
|
+
return false;
|
|
318
|
+
// ctor doesn't have static `isPrototypeOf`
|
|
319
|
+
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
return true;
|
|
323
|
+
}
|
|
324
|
+
function shallowClone(o) {
|
|
325
|
+
if (isPlainObject(o))
|
|
326
|
+
return { ...o };
|
|
327
|
+
if (Array.isArray(o))
|
|
328
|
+
return [...o];
|
|
329
|
+
if (o instanceof Map)
|
|
330
|
+
return new Map(o);
|
|
331
|
+
if (o instanceof Set)
|
|
332
|
+
return new Set(o);
|
|
333
|
+
return o;
|
|
334
|
+
}
|
|
335
|
+
function numKeys(data) {
|
|
336
|
+
let keyCount = 0;
|
|
337
|
+
for (const key in data) {
|
|
338
|
+
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
339
|
+
keyCount++;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return keyCount;
|
|
343
|
+
}
|
|
344
|
+
const getParsedType = (data) => {
|
|
345
|
+
const t = typeof data;
|
|
346
|
+
switch (t) {
|
|
347
|
+
case "undefined":
|
|
348
|
+
return "undefined";
|
|
349
|
+
case "string":
|
|
350
|
+
return "string";
|
|
351
|
+
case "number":
|
|
352
|
+
return Number.isNaN(data) ? "nan" : "number";
|
|
353
|
+
case "boolean":
|
|
354
|
+
return "boolean";
|
|
355
|
+
case "function":
|
|
356
|
+
return "function";
|
|
357
|
+
case "bigint":
|
|
358
|
+
return "bigint";
|
|
359
|
+
case "symbol":
|
|
360
|
+
return "symbol";
|
|
361
|
+
case "object":
|
|
362
|
+
if (Array.isArray(data)) {
|
|
363
|
+
return "array";
|
|
364
|
+
}
|
|
365
|
+
if (data === null) {
|
|
366
|
+
return "null";
|
|
367
|
+
}
|
|
368
|
+
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
|
|
369
|
+
return "promise";
|
|
370
|
+
}
|
|
371
|
+
if (typeof Map !== "undefined" && data instanceof Map) {
|
|
372
|
+
return "map";
|
|
373
|
+
}
|
|
374
|
+
if (typeof Set !== "undefined" && data instanceof Set) {
|
|
375
|
+
return "set";
|
|
376
|
+
}
|
|
377
|
+
if (typeof Date !== "undefined" && data instanceof Date) {
|
|
378
|
+
return "date";
|
|
379
|
+
}
|
|
380
|
+
// @ts-ignore
|
|
381
|
+
if (typeof File !== "undefined" && data instanceof File) {
|
|
382
|
+
return "file";
|
|
383
|
+
}
|
|
384
|
+
return "object";
|
|
385
|
+
default:
|
|
386
|
+
throw new Error(`Unknown data type: ${t}`);
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
exports.getParsedType = getParsedType;
|
|
390
|
+
exports.propertyKeyTypes = new Set(["string", "number", "symbol"]);
|
|
391
|
+
exports.primitiveTypes = new Set([
|
|
392
|
+
"string",
|
|
393
|
+
"number",
|
|
394
|
+
"bigint",
|
|
395
|
+
"boolean",
|
|
396
|
+
"symbol",
|
|
397
|
+
"undefined",
|
|
398
|
+
]);
|
|
399
|
+
function escapeRegex(str) {
|
|
400
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
401
|
+
}
|
|
402
|
+
// yatsp-specific utils
|
|
403
|
+
function clone(inst, def, params) {
|
|
404
|
+
const cl = new inst._yatsp.constr(def ?? inst._yatsp.def);
|
|
405
|
+
if (!def || params?.parent)
|
|
406
|
+
cl._yatsp.parent = inst;
|
|
407
|
+
return cl;
|
|
408
|
+
}
|
|
409
|
+
function normalizeParams(_params) {
|
|
410
|
+
const params = _params;
|
|
411
|
+
if (!params)
|
|
412
|
+
return {};
|
|
413
|
+
if (typeof params === "string")
|
|
414
|
+
return { error: () => params };
|
|
415
|
+
if (params?.message !== undefined) {
|
|
416
|
+
if (params?.error !== undefined)
|
|
417
|
+
throw new Error("Cannot specify both `message` and `error` params");
|
|
418
|
+
params.error = params.message;
|
|
419
|
+
}
|
|
420
|
+
delete params.message;
|
|
421
|
+
if (typeof params.error === "string")
|
|
422
|
+
return { ...params, error: () => params.error };
|
|
423
|
+
return params;
|
|
424
|
+
}
|
|
425
|
+
function createTransparentProxy(getter) {
|
|
426
|
+
let target;
|
|
427
|
+
return new Proxy({}, {
|
|
428
|
+
get(_, prop, receiver) {
|
|
429
|
+
target ?? (target = getter());
|
|
430
|
+
return Reflect.get(target, prop, receiver);
|
|
431
|
+
},
|
|
432
|
+
set(_, prop, value, receiver) {
|
|
433
|
+
target ?? (target = getter());
|
|
434
|
+
return Reflect.set(target, prop, value, receiver);
|
|
435
|
+
},
|
|
436
|
+
has(_, prop) {
|
|
437
|
+
target ?? (target = getter());
|
|
438
|
+
return Reflect.has(target, prop);
|
|
439
|
+
},
|
|
440
|
+
deleteProperty(_, prop) {
|
|
441
|
+
target ?? (target = getter());
|
|
442
|
+
return Reflect.deleteProperty(target, prop);
|
|
443
|
+
},
|
|
444
|
+
ownKeys(_) {
|
|
445
|
+
target ?? (target = getter());
|
|
446
|
+
return Reflect.ownKeys(target);
|
|
447
|
+
},
|
|
448
|
+
getOwnPropertyDescriptor(_, prop) {
|
|
449
|
+
target ?? (target = getter());
|
|
450
|
+
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
451
|
+
},
|
|
452
|
+
defineProperty(_, prop, descriptor) {
|
|
453
|
+
target ?? (target = getter());
|
|
454
|
+
return Reflect.defineProperty(target, prop, descriptor);
|
|
455
|
+
},
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
function stringifyPrimitive(value) {
|
|
459
|
+
if (typeof value === "bigint")
|
|
460
|
+
return value.toString() + "n";
|
|
461
|
+
if (typeof value === "string")
|
|
462
|
+
return `"${value}"`;
|
|
463
|
+
return `${value}`;
|
|
464
|
+
}
|
|
465
|
+
function optionalKeys(shape) {
|
|
466
|
+
return Object.keys(shape).filter((k) => {
|
|
467
|
+
return shape[k]._yatsp.optin !== undefined && shape[k]._yatsp.optout === "optional";
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
// Wrapped in a `@__PURE__` IIFE: esbuild never tree-shakes a top-level initializer that contains a member access on `Number`, so the bare object literal survived into every bundle.
|
|
471
|
+
exports.NUMBER_FORMAT_RANGES = (() => ({
|
|
472
|
+
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
473
|
+
int32: [-2147483648, 2147483647],
|
|
474
|
+
uint32: [0, 4294967295],
|
|
475
|
+
float32: [-3.4028234663852886e38, 3.4028234663852886e38],
|
|
476
|
+
float64: [-Number.MAX_VALUE, Number.MAX_VALUE],
|
|
477
|
+
}))();
|
|
478
|
+
exports.BIGINT_FORMAT_RANGES = {
|
|
479
|
+
int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
|
|
480
|
+
uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")],
|
|
481
|
+
};
|
|
482
|
+
function pick(schema, mask) {
|
|
483
|
+
const currDef = schema._yatsp.def;
|
|
484
|
+
const checks = currDef.checks;
|
|
485
|
+
const hasChecks = checks && checks.length > 0;
|
|
486
|
+
if (hasChecks) {
|
|
487
|
+
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
488
|
+
}
|
|
489
|
+
const newShape = {};
|
|
490
|
+
mirrorShape(newShape, schema, maskedKeys(schema, mask));
|
|
491
|
+
return clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
|
|
492
|
+
}
|
|
493
|
+
// the mask keys that select something, checked against the source's shape without resolving it
|
|
494
|
+
function maskedKeys(schema, mask) {
|
|
495
|
+
const raw = sourceShape(schema);
|
|
496
|
+
const keys = [];
|
|
497
|
+
// `for...in` skips symbols, so a symbol in the mask would select nothing
|
|
498
|
+
for (const key of Reflect.ownKeys(mask)) {
|
|
499
|
+
if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) {
|
|
500
|
+
throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
501
|
+
}
|
|
502
|
+
if (mask[key])
|
|
503
|
+
keys.push(key);
|
|
504
|
+
}
|
|
505
|
+
return keys;
|
|
506
|
+
}
|
|
507
|
+
function omit(schema, mask) {
|
|
508
|
+
const currDef = schema._yatsp.def;
|
|
509
|
+
const checks = currDef.checks;
|
|
510
|
+
const hasChecks = checks && checks.length > 0;
|
|
511
|
+
if (hasChecks) {
|
|
512
|
+
throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
513
|
+
}
|
|
514
|
+
const omitted = new Set(maskedKeys(schema, mask));
|
|
515
|
+
const newShape = {};
|
|
516
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key) => !omitted.has(key)));
|
|
517
|
+
return clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
|
|
518
|
+
}
|
|
519
|
+
function extend(schema, shape) {
|
|
520
|
+
if (!isPlainObject(shape)) {
|
|
521
|
+
throw new Error("Invalid input to extend: expected a plain object");
|
|
522
|
+
}
|
|
523
|
+
const checks = schema._yatsp.def.checks;
|
|
524
|
+
const hasChecks = checks && checks.length > 0;
|
|
525
|
+
if (hasChecks) {
|
|
526
|
+
// Only throw if new shape overlaps with existing shape. Use getOwnPropertyDescriptor to check key existence without accessing values
|
|
527
|
+
const existingShape = sourceShape(schema);
|
|
528
|
+
for (const key of Reflect.ownKeys(shape)) {
|
|
529
|
+
if (Object.getOwnPropertyDescriptor(existingShape, key) !== undefined) {
|
|
530
|
+
throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
return clone(schema, mergeDefs(schema._yatsp.def, { shape: extended(schema, shape) }));
|
|
535
|
+
}
|
|
536
|
+
// the source's keys, then the caller's overlaid on top
|
|
537
|
+
function extended(schema, shape) {
|
|
538
|
+
const newShape = {};
|
|
539
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)));
|
|
540
|
+
mirrorProps(newShape, shape);
|
|
541
|
+
return newShape;
|
|
542
|
+
}
|
|
543
|
+
function safeExtend(schema, shape) {
|
|
544
|
+
if (!isPlainObject(shape)) {
|
|
545
|
+
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
546
|
+
}
|
|
547
|
+
return clone(schema, mergeDefs(schema._yatsp.def, { shape: extended(schema, shape) }));
|
|
548
|
+
}
|
|
549
|
+
function merge(a, b) {
|
|
550
|
+
if (!b?._yatsp?.def) {
|
|
551
|
+
throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
|
|
552
|
+
}
|
|
553
|
+
if (a._yatsp.def.checks?.length) {
|
|
554
|
+
throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
|
555
|
+
}
|
|
556
|
+
const newShape = {};
|
|
557
|
+
mirrorShape(newShape, a, Reflect.ownKeys(sourceShape(a)));
|
|
558
|
+
mirrorShape(newShape, b, Reflect.ownKeys(sourceShape(b)));
|
|
559
|
+
const def = mergeDefs(a._yatsp.def, {
|
|
560
|
+
shape: newShape,
|
|
561
|
+
get catchall() {
|
|
562
|
+
return b._yatsp.def.catchall;
|
|
563
|
+
},
|
|
564
|
+
checks: b._yatsp.def.checks ?? [],
|
|
565
|
+
});
|
|
566
|
+
return clone(a, def);
|
|
567
|
+
}
|
|
568
|
+
function partial(Class, schema, mask, name = "partial") {
|
|
569
|
+
const currDef = schema._yatsp.def;
|
|
570
|
+
const checks = currDef.checks;
|
|
571
|
+
const hasChecks = checks && checks.length > 0;
|
|
572
|
+
if (hasChecks) {
|
|
573
|
+
throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
|
|
574
|
+
}
|
|
575
|
+
const selected = mask ? new Set(maskedKeys(schema, mask)) : undefined;
|
|
576
|
+
const newShape = {};
|
|
577
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class &&
|
|
578
|
+
((value, key) => (selected && !selected.has(key) ? value : new Class({ type: "optional", innerType: value }))));
|
|
579
|
+
return clone(schema, mergeDefs(schema._yatsp.def, { shape: newShape, checks: [] }));
|
|
580
|
+
}
|
|
581
|
+
function required(Class, schema, mask) {
|
|
582
|
+
const selected = mask ? new Set(maskedKeys(schema, mask)) : undefined;
|
|
583
|
+
const newShape = {};
|
|
584
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key) =>
|
|
585
|
+
// overwrite with non-optional
|
|
586
|
+
selected && !selected.has(key) ? value : new Class({ type: "nonoptional", innerType: value }));
|
|
587
|
+
return clone(schema, mergeDefs(schema._yatsp.def, { shape: newShape }));
|
|
588
|
+
}
|
|
589
|
+
// invalid_type | too_big | too_small | invalid_format | not_multiple_of | unrecognized_keys | invalid_union | invalid_key | invalid_element | invalid_value | custom
|
|
590
|
+
function aborted(x, startIndex = 0) {
|
|
591
|
+
if (x.aborted === true)
|
|
592
|
+
return true;
|
|
593
|
+
for (let i = startIndex; i < x.issues.length; i++) {
|
|
594
|
+
if (x.issues[i]?.continue !== true) {
|
|
595
|
+
return true;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
return false;
|
|
599
|
+
}
|
|
600
|
+
// Checks for explicit abort (continue === false), as opposed to implicit abort (continue === undefined). Used to respect `abort: true` in .refine() even for checks that have a `when` function.
|
|
601
|
+
function explicitlyAborted(x, startIndex = 0) {
|
|
602
|
+
if (x.aborted === true)
|
|
603
|
+
return true;
|
|
604
|
+
for (let i = startIndex; i < x.issues.length; i++) {
|
|
605
|
+
if (x.issues[i]?.continue === false) {
|
|
606
|
+
return true;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
return false;
|
|
610
|
+
}
|
|
611
|
+
function prefixIssues(path, issues) {
|
|
612
|
+
return issues.map((iss) => {
|
|
613
|
+
var _a;
|
|
614
|
+
(_a = iss).path ?? (_a.path = []);
|
|
615
|
+
iss.path.unshift(path);
|
|
616
|
+
return iss;
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
function unwrapMessage(message) {
|
|
620
|
+
return typeof message === "string" ? message : message?.message;
|
|
621
|
+
}
|
|
622
|
+
/* A check holds no link back to the schema it is attached to — the same check instance is shared by every clone of that schema — so the owner is stamped onto the issues a check just raised, at the only point where both are in scope. Runs on the failure path only; `start` is the issue count from before the check ran. */
|
|
623
|
+
function attachSchema(issues, start, inst) {
|
|
624
|
+
var _a;
|
|
625
|
+
for (let i = start; i < issues.length; i++) {
|
|
626
|
+
(_a = issues[i]).schema ?? (_a.schema = inst);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
function finalizeIssue(iss, ctx, config) {
|
|
630
|
+
var _a;
|
|
631
|
+
// A schema that raised an issue itself owns it outright, and outranks any stamp an enclosing check left in `attachSchema`. String formats and z.custom() are schema and check at once, so when they act as a check they defer to that stamp instead.
|
|
632
|
+
const traits = iss.inst?._yatsp?.traits;
|
|
633
|
+
if (traits?.has("$YatspType")) {
|
|
634
|
+
if (traits.has("$YatspCheck"))
|
|
635
|
+
(_a = iss).schema ?? (_a.schema = iss.inst);
|
|
636
|
+
else
|
|
637
|
+
iss.schema = iss.inst;
|
|
638
|
+
}
|
|
639
|
+
// Decreasing specificity, first map to return a message wins. `inst` is whatever raised the issue, so a check's own map outranks the owning schema's.
|
|
640
|
+
const schemaError = iss.schema !== iss.inst ? iss.schema?._yatsp.def?.error : undefined;
|
|
641
|
+
const message = iss.message
|
|
642
|
+
? iss.message
|
|
643
|
+
: (unwrapMessage(iss.inst?._yatsp.def?.error?.(iss)) ??
|
|
644
|
+
unwrapMessage(schemaError?.(iss)) ??
|
|
645
|
+
unwrapMessage(ctx?.error?.(iss)) ??
|
|
646
|
+
unwrapMessage(config.customError?.(iss)) ??
|
|
647
|
+
unwrapMessage(config.localeError?.(iss)) ??
|
|
648
|
+
"Invalid input");
|
|
649
|
+
// an explicit own-key copy beats object rest with excluded keys, which v8 routes through a generic runtime call; Object.keys rather than for-in so an issue pushed with a prototype does not leak inherited keys, and an own __proto__ key is dropped rather than assigned through the setter
|
|
650
|
+
const full = {};
|
|
651
|
+
for (const k of Object.keys(iss)) {
|
|
652
|
+
if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__")
|
|
653
|
+
continue;
|
|
654
|
+
full[k] = iss[k];
|
|
655
|
+
}
|
|
656
|
+
full.path ?? (full.path = []);
|
|
657
|
+
full.message = message;
|
|
658
|
+
if (ctx?.reportInput) {
|
|
659
|
+
full.input = iss.input;
|
|
660
|
+
}
|
|
661
|
+
return full;
|
|
662
|
+
}
|
|
663
|
+
function getSizableOrigin(input) {
|
|
664
|
+
if (input instanceof Set)
|
|
665
|
+
return "set";
|
|
666
|
+
if (input instanceof Map)
|
|
667
|
+
return "map";
|
|
668
|
+
// @ts-ignore
|
|
669
|
+
if (input instanceof File)
|
|
670
|
+
return "file";
|
|
671
|
+
return "unknown";
|
|
672
|
+
}
|
|
673
|
+
const highSurrogate = /[\uD800-\uDBFF]/;
|
|
674
|
+
// Code points in `str`: a surrogate pair counts once, a lone surrogate as itself. Hand-rolled because the string iterator allocates and runs ~250x slower on this path; the regex probe exits ~50x quicker for a string with no astral characters.
|
|
675
|
+
function codePointLength(str) {
|
|
676
|
+
const units = str.length;
|
|
677
|
+
if (!highSurrogate.test(str))
|
|
678
|
+
return units;
|
|
679
|
+
let count = units;
|
|
680
|
+
for (let i = 0; i < units - 1; i++) {
|
|
681
|
+
if ((str.charCodeAt(i) & 0xfc00) === 0xd800 && (str.charCodeAt(i + 1) & 0xfc00) === 0xdc00) {
|
|
682
|
+
count--;
|
|
683
|
+
i++;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
return count;
|
|
687
|
+
}
|
|
688
|
+
function getLengthableOrigin(input) {
|
|
689
|
+
if (Array.isArray(input))
|
|
690
|
+
return "array";
|
|
691
|
+
if (typeof input === "string")
|
|
692
|
+
return "string";
|
|
693
|
+
return "unknown";
|
|
694
|
+
}
|
|
695
|
+
function parsedType(data) {
|
|
696
|
+
const t = typeof data;
|
|
697
|
+
switch (t) {
|
|
698
|
+
case "number": {
|
|
699
|
+
return Number.isNaN(data) ? "nan" : "number";
|
|
700
|
+
}
|
|
701
|
+
case "object": {
|
|
702
|
+
if (data === null) {
|
|
703
|
+
return "null";
|
|
704
|
+
}
|
|
705
|
+
if (Array.isArray(data)) {
|
|
706
|
+
return "array";
|
|
707
|
+
}
|
|
708
|
+
const obj = data;
|
|
709
|
+
if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) {
|
|
710
|
+
return obj.constructor.name;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
return t;
|
|
715
|
+
}
|
|
716
|
+
function issue(...args) {
|
|
717
|
+
const [iss, input, inst] = args;
|
|
718
|
+
if (typeof iss === "string") {
|
|
719
|
+
return {
|
|
720
|
+
message: iss,
|
|
721
|
+
code: "custom",
|
|
722
|
+
input,
|
|
723
|
+
inst,
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
return { ...iss };
|
|
727
|
+
}
|
|
728
|
+
function cleanEnum(obj) {
|
|
729
|
+
return Object.entries(obj)
|
|
730
|
+
.filter(([k, _]) => {
|
|
731
|
+
// return true if NaN, meaning it's not a number, thus a string key
|
|
732
|
+
return Number.isNaN(Number.parseInt(k, 10));
|
|
733
|
+
})
|
|
734
|
+
.map((el) => el[1]);
|
|
735
|
+
}
|
|
736
|
+
// Codec utility functions
|
|
737
|
+
function base64ToUint8Array(base64) {
|
|
738
|
+
const binaryString = atob(base64);
|
|
739
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
740
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
741
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
742
|
+
}
|
|
743
|
+
return bytes;
|
|
744
|
+
}
|
|
745
|
+
function uint8ArrayToBase64(bytes) {
|
|
746
|
+
let binaryString = "";
|
|
747
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
748
|
+
binaryString += String.fromCharCode(bytes[i]);
|
|
749
|
+
}
|
|
750
|
+
return btoa(binaryString);
|
|
751
|
+
}
|
|
752
|
+
function base64urlToUint8Array(base64url) {
|
|
753
|
+
const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/");
|
|
754
|
+
const padding = "=".repeat((4 - (base64.length % 4)) % 4);
|
|
755
|
+
return base64ToUint8Array(base64 + padding);
|
|
756
|
+
}
|
|
757
|
+
function uint8ArrayToBase64url(bytes) {
|
|
758
|
+
return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
759
|
+
}
|
|
760
|
+
function hexToUint8Array(hex) {
|
|
761
|
+
const cleanHex = hex.replace(/^0x/, "");
|
|
762
|
+
if (cleanHex.length % 2 !== 0) {
|
|
763
|
+
throw new Error("Invalid hex string length");
|
|
764
|
+
}
|
|
765
|
+
const bytes = new Uint8Array(cleanHex.length / 2);
|
|
766
|
+
for (let i = 0; i < cleanHex.length; i += 2) {
|
|
767
|
+
bytes[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16);
|
|
768
|
+
}
|
|
769
|
+
return bytes;
|
|
770
|
+
}
|
|
771
|
+
function uint8ArrayToHex(bytes) {
|
|
772
|
+
return Array.from(bytes)
|
|
773
|
+
.map((b) => b.toString(16).padStart(2, "0"))
|
|
774
|
+
.join("");
|
|
775
|
+
}
|
|
776
|
+
// instanceof
|
|
777
|
+
class Class {
|
|
778
|
+
constructor(..._args) { }
|
|
779
|
+
}
|
|
780
|
+
exports.Class = Class;
|
|
781
|
+
////////// PROTOTYPE INSTALLERS //////////
|
|
782
|
+
//
|
|
783
|
+
// Members live on the prototype and materialize per instance on first read, which keeps own-property count under the step where V8 stops using inline slots. Changing anything here means re-measuring runtime, memory and bundle size together — see "The three axes" in AGENTS.md.
|
|
784
|
+
/**
|
|
785
|
+
* Installs a trait's members on its prototype. Each value builds that member for the instance on first read; the built value shadows the accessor as an own property, so a detached `const { parse } = schema` keeps working.
|
|
786
|
+
*
|
|
787
|
+
* Call this from a `proto` initializer, which runs once per prototype — never per instance.
|
|
788
|
+
*/
|
|
789
|
+
function members(proto, table) {
|
|
790
|
+
for (const key in table) {
|
|
791
|
+
const desc = Object.getOwnPropertyDescriptor(table, key);
|
|
792
|
+
// a getter installs as written, so it stays live: `description` reads through to the registry on every access. not enumerable: an object literal's is, and a prototype member never was
|
|
793
|
+
if (desc.get)
|
|
794
|
+
Object.defineProperty(proto, key, { ...desc, enumerable: false });
|
|
795
|
+
// a method materializes bound on first read, which is what keeps a detached member working: `const opt = schema.optional; opt()`
|
|
796
|
+
else
|
|
797
|
+
defineBound(proto, key, desc.value);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
/** Shadows a prototype member with an own value, so a getter that builds from the instance runs once. */
|
|
801
|
+
function own(inst, key, value, enumerable = true) {
|
|
802
|
+
Object.defineProperty(inst, key, { configurable: true, writable: true, enumerable, value });
|
|
803
|
+
return value;
|
|
804
|
+
}
|
|
805
|
+
/** Like {@link own}, for a member that was never an own data property and has to stay out of `Object.keys`. */
|
|
806
|
+
function hide(inst, key, value) {
|
|
807
|
+
return own(inst, key, value, false);
|
|
808
|
+
}
|
|
809
|
+
/** Adds members a table derives from the instance: each builds on first read and shadows as own data, and assignment shadows the same way, as when these were own properties. */
|
|
810
|
+
function derived(computes, table) {
|
|
811
|
+
for (const key in computes) {
|
|
812
|
+
const compute = computes[key];
|
|
813
|
+
// an object literal's accessor is configurable and enumerable, and `members` copies the descriptor as written
|
|
814
|
+
Object.defineProperty(table, key, {
|
|
815
|
+
configurable: true,
|
|
816
|
+
enumerable: true,
|
|
817
|
+
get() {
|
|
818
|
+
return own(this, key, compute(this));
|
|
819
|
+
},
|
|
820
|
+
set(value) {
|
|
821
|
+
own(this, key, value);
|
|
822
|
+
},
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
return table;
|
|
826
|
+
}
|
|
827
|
+
function defineBound(proto, key, fn) {
|
|
828
|
+
Object.defineProperty(proto, key, {
|
|
829
|
+
configurable: true,
|
|
830
|
+
get() {
|
|
831
|
+
// vitest's spyOn calls a prototype getter bare to find the function it wraps, so a nullish receiver answers the raw method
|
|
832
|
+
return this == null ? fn : own(this, key, fn.bind(this));
|
|
833
|
+
},
|
|
834
|
+
set(value) {
|
|
835
|
+
own(this, key, value);
|
|
836
|
+
},
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
/** Returns the prototype to install on, or `undefined` if this group is already installed on it. */
|
|
840
|
+
function claim(inst, sentinel) {
|
|
841
|
+
const proto = Object.getPrototypeOf(inst);
|
|
842
|
+
// Runs on every construction, so `in` rather than the costlier `hasOwnProperty.call`. Sentinels are keys the group itself defines.
|
|
843
|
+
return sentinel in proto ? undefined : proto;
|
|
844
|
+
}
|
|
845
|
+
// The internals whose init chain is installing. A second call for the same one is a derived constructor overriding its base, so it must not construct another schema in between or the override is dropped.
|
|
846
|
+
let installing;
|
|
847
|
+
// Set while a getter is running, so a value that resolved through a recursion break is not memoized. One shared descriptor shadows the key for the duration, which costs no per-key allocation.
|
|
848
|
+
let broke = false;
|
|
849
|
+
const breaker = {
|
|
850
|
+
configurable: true,
|
|
851
|
+
get() {
|
|
852
|
+
broke = true;
|
|
853
|
+
return undefined;
|
|
854
|
+
},
|
|
855
|
+
};
|
|
856
|
+
/**
|
|
857
|
+
* Installs a lazily-derived internal on the `_yatsp` prototype of `inst`'s
|
|
858
|
+
* constructor, computed from the internals object itself and cached there on
|
|
859
|
+
* first read. One accessor per constructor rather than one per instance.
|
|
860
|
+
*/
|
|
861
|
+
function defineLazyInternal(inst, key, compute) {
|
|
862
|
+
const proto = Object.getPrototypeOf(inst._yatsp);
|
|
863
|
+
if (key in proto && installing !== inst._yatsp) {
|
|
864
|
+
// A repeat construction: everything is installed already. Cleared here so the reference is not held past the first construction of every type.
|
|
865
|
+
installing = undefined;
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
installing = inst._yatsp;
|
|
869
|
+
Object.defineProperty(proto, key, {
|
|
870
|
+
configurable: true,
|
|
871
|
+
get() {
|
|
872
|
+
// Shadowed before computing so a re-entrant read from a recursive schema resolves to undefined instead of running the getter again.
|
|
873
|
+
Object.defineProperty(this, key, breaker);
|
|
874
|
+
const outer = broke;
|
|
875
|
+
broke = false;
|
|
876
|
+
try {
|
|
877
|
+
const value = compute(this);
|
|
878
|
+
// A result that resolved through a recursion break is recomputed once the graph is complete; everything else memoizes, undefined included.
|
|
879
|
+
if (broke)
|
|
880
|
+
delete this[key];
|
|
881
|
+
else
|
|
882
|
+
Object.defineProperty(this, key, { configurable: true, writable: true, value });
|
|
883
|
+
broke = broke || outer;
|
|
884
|
+
return value;
|
|
885
|
+
}
|
|
886
|
+
catch (err) {
|
|
887
|
+
// A compute that threw memoizes nothing, so a later read runs it again and fails the same way. The shadow goes with it, since leaving it installed would answer undefined for every later read.
|
|
888
|
+
delete this[key];
|
|
889
|
+
broke = broke || outer;
|
|
890
|
+
throw err;
|
|
891
|
+
}
|
|
892
|
+
},
|
|
893
|
+
set(value) {
|
|
894
|
+
Object.defineProperty(this, key, { configurable: true, writable: true, value });
|
|
895
|
+
},
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
/**
|
|
899
|
+
* Installs `key` on `inst`'s prototype, computed by `make` on first read and cached there as an own
|
|
900
|
+
* data property. One accessor per constructor rather than one per instance, because an own accessor
|
|
901
|
+
* puts every instance after the first into v8 dictionary mode. The key doubles as the sentinel.
|
|
902
|
+
*/
|
|
903
|
+
function installLazyProp(inst, key, make, enumerable) {
|
|
904
|
+
const proto = claim(inst, key);
|
|
905
|
+
if (!proto)
|
|
906
|
+
return;
|
|
907
|
+
Object.defineProperty(proto, key, {
|
|
908
|
+
configurable: true,
|
|
909
|
+
get() {
|
|
910
|
+
// Shadowed before computing, so a re-entrant read from a self-referential shape resolves to undefined instead of running the getter again. A data property rather than an accessor: an own accessor is the dictionary-mode transition this exists to avoid.
|
|
911
|
+
const desc = { configurable: true, writable: true, enumerable, value: undefined };
|
|
912
|
+
Object.defineProperty(this, key, desc);
|
|
913
|
+
// a compute that throws leaves the shadow behind, so later reads answer undefined instead of re-throwing; `defineLazy` did the same, and `defineLazyInternal`'s delete-on-catch would cost bytes in every bundle for a case only a throwing user getter reaches
|
|
914
|
+
desc.value = make(this);
|
|
915
|
+
Object.defineProperty(this, key, desc);
|
|
916
|
+
return desc.value;
|
|
917
|
+
},
|
|
918
|
+
set(value) {
|
|
919
|
+
Object.defineProperty(this, key, { configurable: true, writable: true, enumerable, value });
|
|
920
|
+
},
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
/** Marks the thunk `_catch` synthesises for a constant catch value. `Function.length` cannot tell that thunk from a user callback — rest and defaulted parameters both report arity 0 — and a user callback reads `ctx.error`, whose issues only finalize correctly against the caller's per-parse error map. Provenance can say what arity cannot. A plain string key rather than `Symbol.for`, whose call at module scope no bundler can prove pure — the same shape that anchored `urlCanParse` into every build. */
|
|
924
|
+
exports.CONSTANT_CATCH = "~constantCatch";
|
|
925
|
+
/** Wraps a constant catch value in a thunk tagged with {@link CONSTANT_CATCH}. */
|
|
926
|
+
function constantCatch(value) {
|
|
927
|
+
const fn = () => value;
|
|
928
|
+
fn[exports.CONSTANT_CATCH] = true;
|
|
929
|
+
return fn;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
// seal-cjs-exports
|
|
933
|
+
(function () {
|
|
934
|
+
var keys = Object.getOwnPropertyNames(exports);
|
|
935
|
+
for (var i = 0; i < keys.length; i++) {
|
|
936
|
+
var desc = Object.getOwnPropertyDescriptor(exports, keys[i]);
|
|
937
|
+
if (!desc || !desc.get || !desc.configurable) continue;
|
|
938
|
+
var value;
|
|
939
|
+
try {
|
|
940
|
+
value = desc.get();
|
|
941
|
+
} catch (e) {
|
|
942
|
+
continue;
|
|
943
|
+
}
|
|
944
|
+
// a circular require may not have settled this one yet, so leave it live
|
|
945
|
+
if (value === undefined) continue;
|
|
946
|
+
Object.defineProperty(exports, keys[i], { value: value, writable: false, enumerable: desc.enumerable, configurable: false });
|
|
947
|
+
}
|
|
948
|
+
Object.freeze(exports);
|
|
949
|
+
})();
|