@versionzero/schema 1.0.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/LICENSE +177 -0
- package/README.md +246 -0
- package/package.json +84 -0
- package/src/compilation/handler-compilation.js +28 -0
- package/src/compilation/metadata-compilation.js +35 -0
- package/src/compilation/schema-compilation.js +142 -0
- package/src/compilation/selection-compilation.js +84 -0
- package/src/compilation/union-compilation.js +510 -0
- package/src/compilation/values-compilation.js +35 -0
- package/src/compiled-schema.js +1709 -0
- package/src/constants.js +1 -0
- package/src/core-library/index.js +32 -0
- package/src/core-library/processors/aggregation-operators.js +75 -0
- package/src/core-library/processors/alpha-constraint.js +20 -0
- package/src/core-library/processors/alphanum-constraint.js +20 -0
- package/src/core-library/processors/array-operator.js +51 -0
- package/src/core-library/processors/assert-constraint.js +75 -0
- package/src/core-library/processors/base64-constraint.js +26 -0
- package/src/core-library/processors/camel-case-operator.js +24 -0
- package/src/core-library/processors/capitalize-operator.js +16 -0
- package/src/core-library/processors/cardnum-constraint.js +193 -0
- package/src/core-library/processors/ceil-operator.js +44 -0
- package/src/core-library/processors/collapse-operator.js +29 -0
- package/src/core-library/processors/compact-operator.js +34 -0
- package/src/core-library/processors/compile-operator.js +65 -0
- package/src/core-library/processors/concat-operator.js +51 -0
- package/src/core-library/processors/conditional-operators.js +301 -0
- package/src/core-library/processors/constant-case-operator.js +16 -0
- package/src/core-library/processors/data-size-operator.js +86 -0
- package/src/core-library/processors/date-object-operator.js +54 -0
- package/src/core-library/processors/date-operator.js +67 -0
- package/src/core-library/processors/date-range-constraint.js +76 -0
- package/src/core-library/processors/defined-constraint.js +30 -0
- package/src/core-library/processors/each-operator.js +57 -0
- package/src/core-library/processors/email-constraint.js +112 -0
- package/src/core-library/processors/entries-operator.js +25 -0
- package/src/core-library/processors/eq-constraint.js +37 -0
- package/src/core-library/processors/filter-operator.js +74 -0
- package/src/core-library/processors/find-schema-operator.js +45 -0
- package/src/core-library/processors/flatten-operator.js +40 -0
- package/src/core-library/processors/floor-operator.js +47 -0
- package/src/core-library/processors/get-operator.js +44 -0
- package/src/core-library/processors/group-by-operator.js +84 -0
- package/src/core-library/processors/has-prefix-constraint.js +37 -0
- package/src/core-library/processors/has-suffix-constraint.js +35 -0
- package/src/core-library/processors/hex-constraint.js +20 -0
- package/src/core-library/processors/hostname-constraint.js +22 -0
- package/src/core-library/processors/http-url-constraint.js +27 -0
- package/src/core-library/processors/in-constraint.js +66 -0
- package/src/core-library/processors/index-by-operator.js +98 -0
- package/src/core-library/processors/index.js +131 -0
- package/src/core-library/processors/input-operator.js +23 -0
- package/src/core-library/processors/instanceof-constraint.js +38 -0
- package/src/core-library/processors/integer-constraint.js +22 -0
- package/src/core-library/processors/invoke-operator.js +33 -0
- package/src/core-library/processors/ipv4-constraint.js +188 -0
- package/src/core-library/processors/ipv6-constraint.js +205 -0
- package/src/core-library/processors/is-array-constraint.js +21 -0
- package/src/core-library/processors/is-date-constraint.js +22 -0
- package/src/core-library/processors/is-number-constraint.js +21 -0
- package/src/core-library/processors/is-object-constraint.js +21 -0
- package/src/core-library/processors/is-string-constraint.js +21 -0
- package/src/core-library/processors/join-operator.js +41 -0
- package/src/core-library/processors/json-constraint.js +22 -0
- package/src/core-library/processors/json-decode-operator.js +25 -0
- package/src/core-library/processors/json-encode-operator.js +35 -0
- package/src/core-library/processors/kebab-case-operator.js +23 -0
- package/src/core-library/processors/keys-operator.js +20 -0
- package/src/core-library/processors/length-constraint.js +85 -0
- package/src/core-library/processors/lookup-operator.js +84 -0
- package/src/core-library/processors/lowercase-operator.js +14 -0
- package/src/core-library/processors/map-operator.js +84 -0
- package/src/core-library/processors/match-operator.js +64 -0
- package/src/core-library/processors/matches-constraint.js +54 -0
- package/src/core-library/processors/math-operators.js +151 -0
- package/src/core-library/processors/merge-deep-operator.js +61 -0
- package/src/core-library/processors/merge-operator.js +54 -0
- package/src/core-library/processors/metadata-operator.js +100 -0
- package/src/core-library/processors/negative-constraint.js +23 -0
- package/src/core-library/processors/never-constraint.js +69 -0
- package/src/core-library/processors/non-empty-constraint.js +59 -0
- package/src/core-library/processors/not-constraint.js +71 -0
- package/src/core-library/processors/number-operator.js +24 -0
- package/src/core-library/processors/numeric-constraint.js +22 -0
- package/src/core-library/processors/object-operator.js +38 -0
- package/src/core-library/processors/omit-operator.js +57 -0
- package/src/core-library/processors/parallel-operator.js +64 -0
- package/src/core-library/processors/pascal-case-operator.js +16 -0
- package/src/core-library/processors/phone-constraint.js +235 -0
- package/src/core-library/processors/pick-operator.js +62 -0
- package/src/core-library/processors/pipeline-operator.js +63 -0
- package/src/core-library/processors/port-constraint.js +22 -0
- package/src/core-library/processors/positive-constraint.js +23 -0
- package/src/core-library/processors/process-operator.js +55 -0
- package/src/core-library/processors/property-operator.js +49 -0
- package/src/core-library/processors/range-constraint.js +72 -0
- package/src/core-library/processors/reference-operator.js +79 -0
- package/src/core-library/processors/require-constraint.js +74 -0
- package/src/core-library/processors/reverse-operator.js +20 -0
- package/src/core-library/processors/round-operator.js +53 -0
- package/src/core-library/processors/schema-handler-operators.js +54 -0
- package/src/core-library/processors/semver-constraint.js +282 -0
- package/src/core-library/processors/sequence-processors.js +406 -0
- package/src/core-library/processors/sort-operator.js +52 -0
- package/src/core-library/processors/split-operator.js +43 -0
- package/src/core-library/processors/string-extra-operators.js +141 -0
- package/src/core-library/processors/string-operator.js +34 -0
- package/src/core-library/processors/target-operator.js +30 -0
- package/src/core-library/processors/template-operator.js +60 -0
- package/src/core-library/processors/title-case-operator.js +17 -0
- package/src/core-library/processors/trim-operator.js +14 -0
- package/src/core-library/processors/truthy-constraint.js +35 -0
- package/src/core-library/processors/type-operator.js +24 -0
- package/src/core-library/processors/unique-operator.js +21 -0
- package/src/core-library/processors/uppercase-operator.js +14 -0
- package/src/core-library/processors/url-constraint.js +31 -0
- package/src/core-library/processors/url-decode-operator.js +50 -0
- package/src/core-library/processors/url-encode-operator.js +44 -0
- package/src/core-library/processors/uuid-constraint.js +31 -0
- package/src/core-library/processors/values-operator.js +20 -0
- package/src/core-library/schemas/any-schema.js +23 -0
- package/src/core-library/schemas/array-schema.js +8 -0
- package/src/core-library/schemas/boolean-schema.js +10 -0
- package/src/core-library/schemas/date-schema.js +12 -0
- package/src/core-library/schemas/function-schema.js +40 -0
- package/src/core-library/schemas/number-schema.js +9 -0
- package/src/core-library/schemas/object-schema.js +10 -0
- package/src/core-library/schemas/root-schema.js +21 -0
- package/src/core-library/schemas/string-schema.js +9 -0
- package/src/core-library-node/index.js +47 -0
- package/src/core-library-node/processors/base64-decode-operator.js +20 -0
- package/src/core-library-node/processors/base64-encode-operator.js +20 -0
- package/src/core-library-node/processors/buffer-operator.js +39 -0
- package/src/core-library-node/processors/directory-constraint.js +35 -0
- package/src/core-library-node/processors/executable-constraint.js +34 -0
- package/src/core-library-node/processors/file-constraint.js +34 -0
- package/src/core-library-node/processors/file-size-constraint.js +94 -0
- package/src/core-library-node/processors/is-buffer-constraint.js +21 -0
- package/src/core-library-node/processors/reachable-constraint.js +28 -0
- package/src/core-library-node/processors/readable-constraint.js +34 -0
- package/src/core-library-node/processors/writable-constraint.js +59 -0
- package/src/core-library-node/schemas/buffer-schema.js +10 -0
- package/src/errors.js +209 -0
- package/src/executor/array-executor.js +78 -0
- package/src/executor/conditional-executor.js +134 -0
- package/src/executor/each-executor.js +68 -0
- package/src/executor/executor.js +123 -0
- package/src/executor/object-executor.js +98 -0
- package/src/executor/parallel-executor.js +43 -0
- package/src/executor/pipeline-executor.js +65 -0
- package/src/executor/sequence-executor.js +206 -0
- package/src/executor/serial-executor.js +24 -0
- package/src/executor/step-executor.js +68 -0
- package/src/helpers/case.js +124 -0
- package/src/helpers/data-size.js +144 -0
- package/src/helpers/debug-sink.js +15 -0
- package/src/helpers/deep.js +280 -0
- package/src/helpers/format.js +121 -0
- package/src/helpers/has-string-properties.js +30 -0
- package/src/helpers/index.js +16 -0
- package/src/helpers/object.js +115 -0
- package/src/helpers/parse-date.js +75 -0
- package/src/helpers/path.js +28 -0
- package/src/helpers/regex.js +18 -0
- package/src/helpers/stringify.js +309 -0
- package/src/helpers/to-data.js +64 -0
- package/src/helpers/truthy.js +55 -0
- package/src/index.js +29 -0
- package/src/schema-compiler.js +531 -0
- package/src/schema-location.js +200 -0
- package/src/schema-resolver.js +546 -0
- package/src/schema.js +1182 -0
- package/src/traversal/executors/check-condition.js +42 -0
- package/src/traversal/executors/check-input.js +27 -0
- package/src/traversal/executors/check-required.js +19 -0
- package/src/traversal/executors/check-schema.js +45 -0
- package/src/traversal/executors/defaults.js +21 -0
- package/src/traversal/executors/enter-existing.js +25 -0
- package/src/traversal/executors/enter-input.js +25 -0
- package/src/traversal/executors/enter.js +37 -0
- package/src/traversal/executors/exit.js +74 -0
- package/src/traversal/executors/finalize.js +64 -0
- package/src/traversal/executors/index.js +42 -0
- package/src/traversal/executors/normalize.js +38 -0
- package/src/traversal/executors/prepare-existing.js +27 -0
- package/src/traversal/executors/prepare-pending.js +54 -0
- package/src/traversal/executors/resolve-union.js +50 -0
- package/src/traversal/executors/serialize.js +48 -0
- package/src/traversal/executors/transform-early.js +51 -0
- package/src/traversal/executors/transform.js +68 -0
- package/src/traversal/executors/traversal-state-executor.js +46 -0
- package/src/traversal/executors/validate.js +63 -0
- package/src/traversal/traversal-context.js +231 -0
- package/src/traversal/traversal-state.js +809 -0
- package/src/types.js +102 -0
- package/src/value-processor/composed-value-processor.js +43 -0
- package/src/value-processor/defined-value-processor.js +72 -0
- package/src/value-processor/function-value-processor.js +68 -0
- package/src/value-processor/parameterized-value-processor.js +45 -0
- package/src/value-processor/parameters-value-processor.js +178 -0
- package/src/value-processor/spec.js +89 -0
- package/src/value-processor/value-processor.js +105 -0
- package/types/compilation/handler-compilation.d.ts +13 -0
- package/types/compilation/metadata-compilation.d.ts +6 -0
- package/types/compilation/schema-compilation.d.ts +32 -0
- package/types/compilation/selection-compilation.d.ts +9 -0
- package/types/compilation/union-compilation.d.ts +42 -0
- package/types/compilation/values-compilation.d.ts +12 -0
- package/types/compiled-schema.d.ts +883 -0
- package/types/constants.d.ts +1 -0
- package/types/core-library/index.d.ts +7 -0
- package/types/core-library/processors/aggregation-operators.d.ts +24 -0
- package/types/core-library/processors/alpha-constraint.d.ts +9 -0
- package/types/core-library/processors/alphanum-constraint.d.ts +9 -0
- package/types/core-library/processors/array-operator.d.ts +12 -0
- package/types/core-library/processors/assert-constraint.d.ts +30 -0
- package/types/core-library/processors/base64-constraint.d.ts +11 -0
- package/types/core-library/processors/camel-case-operator.d.ts +17 -0
- package/types/core-library/processors/capitalize-operator.d.ts +11 -0
- package/types/core-library/processors/cardnum-constraint.d.ts +51 -0
- package/types/core-library/processors/ceil-operator.d.ts +30 -0
- package/types/core-library/processors/collapse-operator.d.ts +24 -0
- package/types/core-library/processors/compact-operator.d.ts +29 -0
- package/types/core-library/processors/compile-operator.d.ts +34 -0
- package/types/core-library/processors/concat-operator.d.ts +23 -0
- package/types/core-library/processors/conditional-operators.d.ts +219 -0
- package/types/core-library/processors/constant-case-operator.d.ts +9 -0
- package/types/core-library/processors/data-size-operator.d.ts +31 -0
- package/types/core-library/processors/date-object-operator.d.ts +16 -0
- package/types/core-library/processors/date-operator.d.ts +21 -0
- package/types/core-library/processors/date-range-constraint.d.ts +26 -0
- package/types/core-library/processors/defined-constraint.d.ts +20 -0
- package/types/core-library/processors/each-operator.d.ts +34 -0
- package/types/core-library/processors/email-constraint.d.ts +54 -0
- package/types/core-library/processors/entries-operator.d.ts +13 -0
- package/types/core-library/processors/eq-constraint.d.ts +20 -0
- package/types/core-library/processors/filter-operator.d.ts +35 -0
- package/types/core-library/processors/find-schema-operator.d.ts +28 -0
- package/types/core-library/processors/flatten-operator.d.ts +26 -0
- package/types/core-library/processors/floor-operator.d.ts +33 -0
- package/types/core-library/processors/get-operator.d.ts +31 -0
- package/types/core-library/processors/group-by-operator.d.ts +36 -0
- package/types/core-library/processors/has-prefix-constraint.d.ts +22 -0
- package/types/core-library/processors/has-suffix-constraint.d.ts +20 -0
- package/types/core-library/processors/hex-constraint.d.ts +9 -0
- package/types/core-library/processors/hostname-constraint.d.ts +11 -0
- package/types/core-library/processors/http-url-constraint.d.ts +9 -0
- package/types/core-library/processors/in-constraint.d.ts +27 -0
- package/types/core-library/processors/index-by-operator.d.ts +26 -0
- package/types/core-library/processors/index.d.ts +8 -0
- package/types/core-library/processors/input-operator.d.ts +20 -0
- package/types/core-library/processors/instanceof-constraint.d.ts +23 -0
- package/types/core-library/processors/integer-constraint.d.ts +9 -0
- package/types/core-library/processors/invoke-operator.d.ts +12 -0
- package/types/core-library/processors/ipv4-constraint.d.ts +37 -0
- package/types/core-library/processors/ipv6-constraint.d.ts +34 -0
- package/types/core-library/processors/is-array-constraint.d.ts +10 -0
- package/types/core-library/processors/is-date-constraint.d.ts +10 -0
- package/types/core-library/processors/is-number-constraint.d.ts +10 -0
- package/types/core-library/processors/is-object-constraint.d.ts +10 -0
- package/types/core-library/processors/is-string-constraint.d.ts +10 -0
- package/types/core-library/processors/join-operator.d.ts +29 -0
- package/types/core-library/processors/json-constraint.d.ts +10 -0
- package/types/core-library/processors/json-decode-operator.d.ts +9 -0
- package/types/core-library/processors/json-encode-operator.d.ts +27 -0
- package/types/core-library/processors/kebab-case-operator.d.ts +16 -0
- package/types/core-library/processors/keys-operator.d.ts +9 -0
- package/types/core-library/processors/length-constraint.d.ts +34 -0
- package/types/core-library/processors/lookup-operator.d.ts +36 -0
- package/types/core-library/processors/lowercase-operator.d.ts +9 -0
- package/types/core-library/processors/map-operator.d.ts +38 -0
- package/types/core-library/processors/match-operator.d.ts +34 -0
- package/types/core-library/processors/matches-constraint.d.ts +29 -0
- package/types/core-library/processors/math-operators.d.ts +91 -0
- package/types/core-library/processors/merge-deep-operator.d.ts +32 -0
- package/types/core-library/processors/merge-operator.d.ts +26 -0
- package/types/core-library/processors/metadata-operator.d.ts +56 -0
- package/types/core-library/processors/negative-constraint.d.ts +13 -0
- package/types/core-library/processors/never-constraint.d.ts +26 -0
- package/types/core-library/processors/non-empty-constraint.d.ts +28 -0
- package/types/core-library/processors/not-constraint.d.ts +28 -0
- package/types/core-library/processors/number-operator.d.ts +9 -0
- package/types/core-library/processors/numeric-constraint.d.ts +10 -0
- package/types/core-library/processors/object-operator.d.ts +10 -0
- package/types/core-library/processors/omit-operator.d.ts +24 -0
- package/types/core-library/processors/parallel-operator.d.ts +41 -0
- package/types/core-library/processors/pascal-case-operator.d.ts +9 -0
- package/types/core-library/processors/phone-constraint.d.ts +65 -0
- package/types/core-library/processors/pick-operator.d.ts +27 -0
- package/types/core-library/processors/pipeline-operator.d.ts +40 -0
- package/types/core-library/processors/port-constraint.d.ts +11 -0
- package/types/core-library/processors/positive-constraint.d.ts +13 -0
- package/types/core-library/processors/process-operator.d.ts +37 -0
- package/types/core-library/processors/property-operator.d.ts +34 -0
- package/types/core-library/processors/range-constraint.d.ts +30 -0
- package/types/core-library/processors/reference-operator.d.ts +38 -0
- package/types/core-library/processors/require-constraint.d.ts +29 -0
- package/types/core-library/processors/reverse-operator.d.ts +9 -0
- package/types/core-library/processors/round-operator.d.ts +34 -0
- package/types/core-library/processors/schema-handler-operators.d.ts +28 -0
- package/types/core-library/processors/semver-constraint.d.ts +43 -0
- package/types/core-library/processors/sequence-processors.d.ts +213 -0
- package/types/core-library/processors/sort-operator.d.ts +31 -0
- package/types/core-library/processors/split-operator.d.ts +33 -0
- package/types/core-library/processors/string-extra-operators.d.ts +83 -0
- package/types/core-library/processors/string-operator.d.ts +10 -0
- package/types/core-library/processors/target-operator.d.ts +27 -0
- package/types/core-library/processors/template-operator.d.ts +31 -0
- package/types/core-library/processors/title-case-operator.d.ts +12 -0
- package/types/core-library/processors/trim-operator.d.ts +9 -0
- package/types/core-library/processors/truthy-constraint.d.ts +23 -0
- package/types/core-library/processors/type-operator.d.ts +11 -0
- package/types/core-library/processors/unique-operator.d.ts +10 -0
- package/types/core-library/processors/uppercase-operator.d.ts +9 -0
- package/types/core-library/processors/url-constraint.d.ts +20 -0
- package/types/core-library/processors/url-decode-operator.d.ts +31 -0
- package/types/core-library/processors/url-encode-operator.d.ts +36 -0
- package/types/core-library/processors/uuid-constraint.d.ts +20 -0
- package/types/core-library/processors/values-operator.d.ts +9 -0
- package/types/core-library/schemas/any-schema.d.ts +2 -0
- package/types/core-library/schemas/array-schema.d.ts +2 -0
- package/types/core-library/schemas/boolean-schema.d.ts +2 -0
- package/types/core-library/schemas/date-schema.d.ts +2 -0
- package/types/core-library/schemas/function-schema.d.ts +2 -0
- package/types/core-library/schemas/number-schema.d.ts +2 -0
- package/types/core-library/schemas/object-schema.d.ts +2 -0
- package/types/core-library/schemas/root-schema.d.ts +2 -0
- package/types/core-library/schemas/string-schema.d.ts +2 -0
- package/types/core-library-node/index.d.ts +12 -0
- package/types/core-library-node/processors/base64-decode-operator.d.ts +9 -0
- package/types/core-library-node/processors/base64-encode-operator.d.ts +9 -0
- package/types/core-library-node/processors/buffer-operator.d.ts +15 -0
- package/types/core-library-node/processors/directory-constraint.d.ts +14 -0
- package/types/core-library-node/processors/executable-constraint.d.ts +17 -0
- package/types/core-library-node/processors/file-constraint.d.ts +13 -0
- package/types/core-library-node/processors/file-size-constraint.d.ts +43 -0
- package/types/core-library-node/processors/is-buffer-constraint.d.ts +10 -0
- package/types/core-library-node/processors/reachable-constraint.d.ts +13 -0
- package/types/core-library-node/processors/readable-constraint.d.ts +17 -0
- package/types/core-library-node/processors/writable-constraint.d.ts +18 -0
- package/types/core-library-node/schemas/buffer-schema.d.ts +2 -0
- package/types/errors.d.ts +58 -0
- package/types/executor/array-executor.d.ts +17 -0
- package/types/executor/conditional-executor.d.ts +45 -0
- package/types/executor/each-executor.d.ts +15 -0
- package/types/executor/executor.d.ts +84 -0
- package/types/executor/object-executor.d.ts +14 -0
- package/types/executor/parallel-executor.d.ts +27 -0
- package/types/executor/pipeline-executor.d.ts +11 -0
- package/types/executor/sequence-executor.d.ts +32 -0
- package/types/executor/serial-executor.d.ts +16 -0
- package/types/executor/step-executor.d.ts +14 -0
- package/types/helpers/case.d.ts +30 -0
- package/types/helpers/data-size.d.ts +25 -0
- package/types/helpers/debug-sink.d.ts +9 -0
- package/types/helpers/deep.d.ts +33 -0
- package/types/helpers/format.d.ts +14 -0
- package/types/helpers/has-string-properties.d.ts +5 -0
- package/types/helpers/index.d.ts +13 -0
- package/types/helpers/object.d.ts +46 -0
- package/types/helpers/parse-date.d.ts +6 -0
- package/types/helpers/path.d.ts +13 -0
- package/types/helpers/regex.d.ts +7 -0
- package/types/helpers/stringify.d.ts +33 -0
- package/types/helpers/to-data.d.ts +13 -0
- package/types/helpers/truthy.d.ts +26 -0
- package/types/index.d.ts +6 -0
- package/types/schema-compiler.d.ts +49 -0
- package/types/schema-location.d.ts +64 -0
- package/types/schema-resolver.d.ts +145 -0
- package/types/schema.d.ts +586 -0
- package/types/traversal/executors/check-condition.d.ts +8 -0
- package/types/traversal/executors/check-input.d.ts +6 -0
- package/types/traversal/executors/check-required.d.ts +6 -0
- package/types/traversal/executors/check-schema.d.ts +7 -0
- package/types/traversal/executors/defaults.d.ts +8 -0
- package/types/traversal/executors/enter-existing.d.ts +6 -0
- package/types/traversal/executors/enter-input.d.ts +8 -0
- package/types/traversal/executors/enter.d.ts +7 -0
- package/types/traversal/executors/exit.d.ts +6 -0
- package/types/traversal/executors/finalize.d.ts +6 -0
- package/types/traversal/executors/index.d.ts +15 -0
- package/types/traversal/executors/normalize.d.ts +7 -0
- package/types/traversal/executors/prepare-existing.d.ts +6 -0
- package/types/traversal/executors/prepare-pending.d.ts +6 -0
- package/types/traversal/executors/resolve-union.d.ts +6 -0
- package/types/traversal/executors/serialize.d.ts +11 -0
- package/types/traversal/executors/transform-early.d.ts +6 -0
- package/types/traversal/executors/transform.d.ts +6 -0
- package/types/traversal/executors/traversal-state-executor.d.ts +19 -0
- package/types/traversal/executors/validate.d.ts +6 -0
- package/types/traversal/traversal-context.d.ts +67 -0
- package/types/traversal/traversal-state.d.ts +97 -0
- package/types/types.d.ts +218 -0
- package/types/value-processor/composed-value-processor.d.ts +17 -0
- package/types/value-processor/defined-value-processor.d.ts +16 -0
- package/types/value-processor/function-value-processor.d.ts +15 -0
- package/types/value-processor/parameterized-value-processor.d.ts +14 -0
- package/types/value-processor/parameters-value-processor.d.ts +28 -0
- package/types/value-processor/spec.d.ts +22 -0
- package/types/value-processor/value-processor.d.ts +92 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Executor, toExecutor, UNDEFINED_EXECUTOR } from './executor.js';
|
|
2
|
+
import { isTruthy } from '../helpers/truthy.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @template T
|
|
6
|
+
* @typedef {object} ConditionalExecutorActions
|
|
7
|
+
* @property {any} [success]
|
|
8
|
+
* @property {any} [failure]
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Checks if the provided predicate succeeds. Usable as-is, or as a base class with behavior configured by flags.
|
|
13
|
+
*
|
|
14
|
+
* Default behavior simply tries running the predicate; if it throws or rejects, it is considered a failure.
|
|
15
|
+
*
|
|
16
|
+
* On success, the success action is called with the original input (default: returns the value)
|
|
17
|
+
* On failure, the failure action is called with the original input (default: return undefined)
|
|
18
|
+
*
|
|
19
|
+
* @template T
|
|
20
|
+
* @augments {Executor<T>}
|
|
21
|
+
*/
|
|
22
|
+
export class ConditionalExecutor extends Executor {
|
|
23
|
+
/** @type {Executor} */
|
|
24
|
+
#predicate;
|
|
25
|
+
/** @type {Executor} */
|
|
26
|
+
#success;
|
|
27
|
+
/** @type {Executor} */
|
|
28
|
+
#failure;
|
|
29
|
+
|
|
30
|
+
/** @type {boolean} */
|
|
31
|
+
#passResult = false;
|
|
32
|
+
|
|
33
|
+
/** @type {boolean} */
|
|
34
|
+
#passError = false;
|
|
35
|
+
|
|
36
|
+
/** @type {boolean} */
|
|
37
|
+
#checkTruthy = false;
|
|
38
|
+
|
|
39
|
+
/** @type {boolean} */
|
|
40
|
+
#checkDefined = false;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Construct a `ConditionalExecutor` from a predicate and optional success/failure executors.
|
|
44
|
+
* - If no success executor is provided, the resolved value from the predicate is returned.
|
|
45
|
+
* - If no failure executor is provided, `undefined` is returned.
|
|
46
|
+
*
|
|
47
|
+
* @param {any} predicate
|
|
48
|
+
* @param {ConditionalExecutorActions<T>} [actions]
|
|
49
|
+
* @param {symbol[]} [flags]
|
|
50
|
+
*/
|
|
51
|
+
constructor(predicate, actions = {}, flags = []) {
|
|
52
|
+
super();
|
|
53
|
+
this.#predicate = toExecutor(predicate ?? new Executor());
|
|
54
|
+
this.#success = toExecutor(actions.success ?? new Executor());
|
|
55
|
+
this.#failure = toExecutor(actions.failure ?? UNDEFINED_EXECUTOR);
|
|
56
|
+
|
|
57
|
+
for (const flag of flags) {
|
|
58
|
+
if (flag === ConditionalExecutor.CHECK_TRUTHY) {
|
|
59
|
+
this.#checkTruthy = true;
|
|
60
|
+
}
|
|
61
|
+
else if (flag === ConditionalExecutor.CHECK_DEFINED) {
|
|
62
|
+
this.#checkDefined = true;
|
|
63
|
+
}
|
|
64
|
+
else if (flag === ConditionalExecutor.PASS_RESULT) {
|
|
65
|
+
this.#passResult = true;
|
|
66
|
+
}
|
|
67
|
+
else if (flag === ConditionalExecutor.PASS_ERROR) {
|
|
68
|
+
this.#passError = true;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
throw new Error(`Unknown flag`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @param {T} input
|
|
78
|
+
* @param {...any} variadic
|
|
79
|
+
* @returns {T|null|undefined|Promise<T|null|undefined>}
|
|
80
|
+
*/
|
|
81
|
+
execute(input, ...variadic) {
|
|
82
|
+
|
|
83
|
+
const handle = (error, result) => {
|
|
84
|
+
|
|
85
|
+
let success;
|
|
86
|
+
const value = this.#passResult ? result : input;
|
|
87
|
+
const failureValue = this.#passError? error : value;
|
|
88
|
+
|
|
89
|
+
if (error) {
|
|
90
|
+
success = false;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
if (this.#checkTruthy) {
|
|
94
|
+
success = isTruthy(result);
|
|
95
|
+
}
|
|
96
|
+
else if (this.#checkDefined) {
|
|
97
|
+
success = (result !== undefined);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
success = true;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (success) {
|
|
104
|
+
return this.#success.execute(value, ...variadic);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
return this.#failure.execute(failureValue, ...variadic);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
let result;
|
|
112
|
+
try {
|
|
113
|
+
result = this.#predicate.execute(input, ...variadic);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
return handle(error);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (result instanceof Promise) {
|
|
120
|
+
return result.then(resolved => {
|
|
121
|
+
return handle(undefined, resolved);
|
|
122
|
+
}, rejected => {
|
|
123
|
+
return handle(rejected);
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
return handle(undefined, result);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
static CHECK_TRUTHY = Symbol('CHECK-TRUTHY');
|
|
130
|
+
static CHECK_DEFINED = Symbol('CHECK-DEFINED');
|
|
131
|
+
static PASS_RESULT = Symbol('PASS-RESULT');
|
|
132
|
+
static PASS_ERROR = Symbol('PASS-ERROR');
|
|
133
|
+
|
|
134
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Executor, toExecutor } from './executor.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @template T
|
|
5
|
+
* @template E
|
|
6
|
+
* @augments {Executor<T>}
|
|
7
|
+
*/
|
|
8
|
+
export class EachExecutor extends Executor {
|
|
9
|
+
/** @type {Executor<E>} */
|
|
10
|
+
#executor;
|
|
11
|
+
|
|
12
|
+
/** @type {((value:T|null|undefined)=>(E|null|undefined)[])|undefined} */
|
|
13
|
+
#toValues;
|
|
14
|
+
|
|
15
|
+
/** @type {((values:(E|null|undefined)[], input:T|null|undefined)=>T|null|undefined)|undefined} */
|
|
16
|
+
#fromValues;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {Executor<E>|any} each - executor to apply to each value during execute
|
|
20
|
+
* @param {(value:T|null|undefined)=>(E|null|undefined)[]} [toValues] - optional value factory
|
|
21
|
+
* @param {((values:(E|null|undefined)[],input:T|null|undefined)=>T|null|undefined)} [fromValues]
|
|
22
|
+
*/
|
|
23
|
+
constructor(each, toValues, fromValues) {
|
|
24
|
+
super();
|
|
25
|
+
this.#executor = toExecutor(each);
|
|
26
|
+
this.#toValues = toValues;
|
|
27
|
+
this.#fromValues = fromValues;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @param {T|null|undefined} input
|
|
32
|
+
* @param {...any} extra
|
|
33
|
+
* @returns {T|null|undefined|Promise<T|null|undefined>}
|
|
34
|
+
*/
|
|
35
|
+
execute(input, ...extra) {
|
|
36
|
+
|
|
37
|
+
let values = (this.#toValues? this.#toValues(input) : /** @type {E[]} */ (input));
|
|
38
|
+
|
|
39
|
+
if (!values) {
|
|
40
|
+
return input;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (!Array.isArray(values)) {
|
|
44
|
+
values = [values];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
let sync = true;
|
|
48
|
+
|
|
49
|
+
const results = values.map(value => {
|
|
50
|
+
const result = this.#executor.execute(value, ...extra);
|
|
51
|
+
if (sync && result instanceof Promise) {
|
|
52
|
+
sync = false;
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
if (sync) {
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
return this.#fromValues? this.#fromValues(results, input) : results;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
// @ts-ignore - just make sure T is E[]
|
|
63
|
+
return Promise.all(results).then(resolved => {
|
|
64
|
+
return this.#fromValues? this.#fromValues(resolved, input) : (resolved);
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
|
|
2
|
+
/** @import {Thenable} from './thenable.js' */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @template T
|
|
6
|
+
* @typedef {(input:T|null|undefined, ...variadic:any) => T|null|undefined|Promise<T|null|undefined>} ExecutorFunction
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @template T
|
|
11
|
+
* @template R
|
|
12
|
+
* @typedef {(input:T|null|undefined, ...variadic:any) => R|null|undefined|Promise<R|null|undefined>} MappingExecutorFunction
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* An `Executor` is a composable unit of computation that processes an input into an output.
|
|
17
|
+
*
|
|
18
|
+
* Executors are designed for fine-grained runtime composition (executors calling other executors) and
|
|
19
|
+
* are frequently used in hot code paths. Executors may be synchronous or asynchronous, but fully synchronous
|
|
20
|
+
* executor call chains are optimized to incur no async overhead. Only the outermost call thus needs to be awaited.
|
|
21
|
+
*
|
|
22
|
+
* Errors are surfaced as exceptions or rejections.
|
|
23
|
+
*
|
|
24
|
+
* Combinator executors may catch and transform errors, or intercept and reinterpret intermediate outputs.
|
|
25
|
+
*
|
|
26
|
+
* @template T
|
|
27
|
+
*/
|
|
28
|
+
export class Executor
|
|
29
|
+
{
|
|
30
|
+
/**
|
|
31
|
+
* Process on a given input.
|
|
32
|
+
*
|
|
33
|
+
* The execute() method may return an output synchronously, or return a `Promise`
|
|
34
|
+
* for deferred output. Callers must handle both cases.
|
|
35
|
+
*
|
|
36
|
+
* Output value conventions:
|
|
37
|
+
* - An output value of `null` signals that processing this input will *never* produce an output. Most executors
|
|
38
|
+
* receiving `null` as input should propagate it immediately without processing, although coordinator executors
|
|
39
|
+
* that check for success or failure may choose to branch to an appropriate handler executor based on the result.
|
|
40
|
+
* - An output value of `undefined` signals that this input could not be processed *at this time*.
|
|
41
|
+
* It is a soft signal (often used to halt a chain); individual executors define whether
|
|
42
|
+
* `undefined` is a legal input for their context.
|
|
43
|
+
*
|
|
44
|
+
* @param {T|null|undefined} input - required primary input
|
|
45
|
+
* @param {...any} variadic - optional extra arguments (defined as needed by subclasses)
|
|
46
|
+
* @returns {T|null|undefined|Promise<T|null|undefined>}
|
|
47
|
+
*/
|
|
48
|
+
execute(input, ...variadic) {
|
|
49
|
+
return input;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get isConstant() {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Wrap a provided executor function as an Executor
|
|
60
|
+
*
|
|
61
|
+
* @template T
|
|
62
|
+
* @augments Executor<T>
|
|
63
|
+
*/
|
|
64
|
+
export class FunctionExecutor extends Executor {
|
|
65
|
+
#execute;
|
|
66
|
+
/**
|
|
67
|
+
* @param {ExecutorFunction<T>} execute
|
|
68
|
+
*/
|
|
69
|
+
constructor(execute) {
|
|
70
|
+
super();
|
|
71
|
+
this.#execute = execute;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @param {T} input - required primary input
|
|
76
|
+
* @param {...any} variadic - optional extra arguments (defined as needed by subclasses)
|
|
77
|
+
* @returns {T|null|undefined|Promise<T|null|undefined>}
|
|
78
|
+
*/
|
|
79
|
+
execute(input, ...variadic) {
|
|
80
|
+
return this.#execute(input, ...variadic);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export class ConstantExecutor extends Executor {
|
|
85
|
+
#value;
|
|
86
|
+
/**
|
|
87
|
+
* @param {any} value
|
|
88
|
+
*/
|
|
89
|
+
constructor(value) {
|
|
90
|
+
super();
|
|
91
|
+
this.#value = value;
|
|
92
|
+
}
|
|
93
|
+
execute() {
|
|
94
|
+
return this.#value;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
get isConstant() {
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export const NULL_EXECUTOR = new ConstantExecutor(null);
|
|
103
|
+
export const UNDEFINED_EXECUTOR = new ConstantExecutor(undefined);
|
|
104
|
+
export const TRUE_EXECUTOR = new ConstantExecutor(true);
|
|
105
|
+
export const FALSE_EXECUTOR = new ConstantExecutor(false);
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @template T
|
|
109
|
+
* @param {T|Executor<T>|ExecutorFunction<T>} e
|
|
110
|
+
* @returns {Executor<T>}
|
|
111
|
+
*/
|
|
112
|
+
export function toExecutor(e) {
|
|
113
|
+
if (e instanceof Executor) {
|
|
114
|
+
return e;
|
|
115
|
+
}
|
|
116
|
+
else if (typeof e === 'function') {
|
|
117
|
+
// @ts-ignore
|
|
118
|
+
return new FunctionExecutor(e);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
return new ConstantExecutor(e);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Executor, toExecutor } from './executor.js';
|
|
2
|
+
|
|
3
|
+
import { SchemaError } from '../errors.js';
|
|
4
|
+
|
|
5
|
+
/** @typedef {[key:string, executor:Executor]} ObjectExecutorEntry */
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @augments {Executor<any>}
|
|
9
|
+
*/
|
|
10
|
+
export class ObjectExecutor extends Executor {
|
|
11
|
+
|
|
12
|
+
/** @type {ObjectExecutorEntry[]} */
|
|
13
|
+
#executorEntries = [];
|
|
14
|
+
/** @type {((input:any) => any) | undefined} */
|
|
15
|
+
#preprocess;
|
|
16
|
+
|
|
17
|
+
/** @type {any} */
|
|
18
|
+
#constantValue;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {object} [object]
|
|
22
|
+
* @param {(input:any) => any} [preprocess]
|
|
23
|
+
*/
|
|
24
|
+
constructor(object = {}, preprocess) {
|
|
25
|
+
|
|
26
|
+
super();
|
|
27
|
+
|
|
28
|
+
let isConstant = true;
|
|
29
|
+
for (const [key, item] of Object.entries(object)) {
|
|
30
|
+
if (item === undefined) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const itemExecutor = toExecutor(item);
|
|
34
|
+
this.#executorEntries.push([key, itemExecutor]);
|
|
35
|
+
isConstant &&= itemExecutor.isConstant;
|
|
36
|
+
}
|
|
37
|
+
this.#preprocess = preprocess;
|
|
38
|
+
|
|
39
|
+
if (isConstant) {
|
|
40
|
+
if (preprocess) {
|
|
41
|
+
throw new SchemaError('Cannot use a preprocessor with a constant object executor');
|
|
42
|
+
}
|
|
43
|
+
this.#constantValue = Object.fromEntries(this.#executorEntries.map(([key, executor]) => [key, executor.execute(true)]));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @param {any} input
|
|
49
|
+
* @param {...any} extra
|
|
50
|
+
* @returns {object|Promise<object>}
|
|
51
|
+
*/
|
|
52
|
+
execute(input, ...extra) {
|
|
53
|
+
if (this.#constantValue !== undefined) {
|
|
54
|
+
return this.#constantValue;
|
|
55
|
+
}
|
|
56
|
+
const output = {};
|
|
57
|
+
let current = 0;
|
|
58
|
+
|
|
59
|
+
const entries = this.#executorEntries;
|
|
60
|
+
|
|
61
|
+
while (current < entries.length) {
|
|
62
|
+
const key = entries[current][0];
|
|
63
|
+
const executeInput = this.#preprocess? this.#preprocess(input) : input
|
|
64
|
+
const result = entries[current++][1].execute(executeInput, ...extra);
|
|
65
|
+
|
|
66
|
+
if (result instanceof Promise) {
|
|
67
|
+
return result.then(resolved => {
|
|
68
|
+
output[key] = resolved;
|
|
69
|
+
return this.#resume(input, extra, current, output)
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
output[key] = result;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return output;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @param {any} input
|
|
81
|
+
* @param {any[]} extra
|
|
82
|
+
* @param {number} resumeIndex
|
|
83
|
+
* @param {object} output
|
|
84
|
+
* @returns {Promise<object>}
|
|
85
|
+
*/
|
|
86
|
+
async #resume(input, extra, resumeIndex, output) {
|
|
87
|
+
const entries = this.#executorEntries;
|
|
88
|
+
while (resumeIndex < entries.length) {
|
|
89
|
+
const key = entries[resumeIndex][0];
|
|
90
|
+
const executeInput = this.#preprocess? this.#preprocess(input) : input
|
|
91
|
+
output[key] = await entries[resumeIndex++][1].execute(executeInput, ...extra);
|
|
92
|
+
}
|
|
93
|
+
return output;
|
|
94
|
+
}
|
|
95
|
+
get isConstant() {
|
|
96
|
+
return this.#constantValue !== undefined;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
|
|
2
|
+
import { Executor, toExecutor } from './executor.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Executes a fixed set of executors concurrently, passing the same input value and variadic arguments to each,
|
|
6
|
+
* and returning an array of all results in the same order as the executors.
|
|
7
|
+
*
|
|
8
|
+
* When all executors are synchronous, execution is sequential and the result is a plain array.
|
|
9
|
+
* When any executor returns a Promise, all results are collected via `Promise.all`, giving true
|
|
10
|
+
* concurrent execution for I/O-bound processors.
|
|
11
|
+
*
|
|
12
|
+
* Errors propagate immediately — a synchronous throw or async rejection halts collection
|
|
13
|
+
* and surfaces the error to the caller without waiting for remaining executors.
|
|
14
|
+
*
|
|
15
|
+
* @augments {Executor<any>}
|
|
16
|
+
*/
|
|
17
|
+
export class ParallelExecutor extends Executor {
|
|
18
|
+
|
|
19
|
+
#executors;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {Array<any>} [parallel] - executors/functions/values to execute concurrently
|
|
23
|
+
*/
|
|
24
|
+
constructor(parallel = []) {
|
|
25
|
+
super();
|
|
26
|
+
this.#executors = parallel.map((/** @type {any} */ item) => toExecutor(item));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {any} input
|
|
31
|
+
* @param {...any} variadic
|
|
32
|
+
* @returns {any[]|Promise<any[]>}
|
|
33
|
+
*/
|
|
34
|
+
execute(input, ...variadic) {
|
|
35
|
+
let hasAsync = false;
|
|
36
|
+
const results = this.#executors.map(exec => {
|
|
37
|
+
const result = exec.execute(input, ...variadic);
|
|
38
|
+
if (result instanceof Promise) hasAsync = true;
|
|
39
|
+
return result;
|
|
40
|
+
});
|
|
41
|
+
return hasAsync ? Promise.all(results) : results;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Executor, toExecutor } from './executor.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @augments Executor<any>
|
|
5
|
+
*/
|
|
6
|
+
export class PipelineExecutor extends Executor
|
|
7
|
+
{
|
|
8
|
+
/** @type {Executor<any>[]} */
|
|
9
|
+
#executors;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {Array<any>|any} pipeline - executors/functions/values to execute as a pipeline
|
|
13
|
+
*/
|
|
14
|
+
constructor(pipeline = []) {
|
|
15
|
+
if (!Array.isArray(pipeline)) {
|
|
16
|
+
pipeline = [pipeline]
|
|
17
|
+
}
|
|
18
|
+
super();
|
|
19
|
+
this.#executors = pipeline.map((/** @type {any} */ item) => toExecutor(item));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param {any} value
|
|
24
|
+
* @param {...any} variadic
|
|
25
|
+
* @returns {any|Promise<any>}
|
|
26
|
+
*/
|
|
27
|
+
execute(value, ...variadic) {
|
|
28
|
+
// if (value === null) {
|
|
29
|
+
// return null;
|
|
30
|
+
// }
|
|
31
|
+
let current = 0;
|
|
32
|
+
|
|
33
|
+
const executors = this.#executors;
|
|
34
|
+
|
|
35
|
+
while (current < executors.length) {
|
|
36
|
+
value = executors[current++].execute(value, ...variadic);
|
|
37
|
+
|
|
38
|
+
// if (value === null) {
|
|
39
|
+
// return null;
|
|
40
|
+
// }
|
|
41
|
+
|
|
42
|
+
if (value instanceof Promise) {
|
|
43
|
+
return value.then(resolved => this.#resume(resolved, variadic, current));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @param {unknown} value
|
|
51
|
+
* @param {any[]} variadic
|
|
52
|
+
* @param {number} resumeIndex
|
|
53
|
+
* @returns {Promise<any>}
|
|
54
|
+
*/
|
|
55
|
+
async #resume(value, variadic, resumeIndex) {
|
|
56
|
+
while (resumeIndex < this.#executors.length) {
|
|
57
|
+
// if (value === null) {
|
|
58
|
+
// return null;
|
|
59
|
+
// }
|
|
60
|
+
const input = value;
|
|
61
|
+
value = await this.#executors[resumeIndex++].execute(value, ...variadic);
|
|
62
|
+
}
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
}
|