pull-request-split-advisor 3.1.2
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 +52 -0
- package/README.md +168 -0
- package/dist/ai/config-wizard.js +282 -0
- package/dist/ai/enricher.js +290 -0
- package/dist/ai/prompts.js +231 -0
- package/dist/ai/provider.js +265 -0
- package/dist/cli.js +442 -0
- package/dist/config/config.js +315 -0
- package/dist/config/default-config.js +223 -0
- package/dist/core/blocks.js +145 -0
- package/dist/core/commit-planner.js +273 -0
- package/dist/core/dependency.js +284 -0
- package/dist/core/file-stats.js +341 -0
- package/dist/core/history.js +72 -0
- package/dist/core/planner.js +25 -0
- package/dist/core/scoring.js +166 -0
- package/dist/core/strategy.js +486 -0
- package/dist/git/branch-naming.js +120 -0
- package/dist/git/executor.js +378 -0
- package/dist/git/git.js +239 -0
- package/dist/output/report-styles.generated.js +10 -0
- package/dist/output/report.js +726 -0
- package/dist/output/ui.js +417 -0
- package/dist/shared/constants.js +59 -0
- package/dist/shared/types.js +7 -0
- package/dist/shared/utils.js +73 -0
- package/node_modules/@colors/colors/LICENSE +26 -0
- package/node_modules/@colors/colors/README.md +219 -0
- package/node_modules/@colors/colors/examples/normal-usage.js +83 -0
- package/node_modules/@colors/colors/examples/safe-string.js +80 -0
- package/node_modules/@colors/colors/index.d.ts +136 -0
- package/node_modules/@colors/colors/lib/colors.js +211 -0
- package/node_modules/@colors/colors/lib/custom/trap.js +46 -0
- package/node_modules/@colors/colors/lib/custom/zalgo.js +110 -0
- package/node_modules/@colors/colors/lib/extendStringPrototype.js +110 -0
- package/node_modules/@colors/colors/lib/index.js +13 -0
- package/node_modules/@colors/colors/lib/maps/america.js +10 -0
- package/node_modules/@colors/colors/lib/maps/rainbow.js +12 -0
- package/node_modules/@colors/colors/lib/maps/random.js +11 -0
- package/node_modules/@colors/colors/lib/maps/zebra.js +5 -0
- package/node_modules/@colors/colors/lib/styles.js +95 -0
- package/node_modules/@colors/colors/lib/system/has-flag.js +35 -0
- package/node_modules/@colors/colors/lib/system/supports-colors.js +151 -0
- package/node_modules/@colors/colors/package.json +45 -0
- package/node_modules/@colors/colors/safe.d.ts +48 -0
- package/node_modules/@colors/colors/safe.js +10 -0
- package/node_modules/@colors/colors/themes/generic-logging.js +12 -0
- package/node_modules/ansi-align/LICENSE +13 -0
- package/node_modules/ansi-align/README.md +80 -0
- package/node_modules/ansi-align/index.js +61 -0
- package/node_modules/ansi-align/node_modules/ansi-regex/index.d.ts +37 -0
- package/node_modules/ansi-align/node_modules/ansi-regex/index.js +10 -0
- package/node_modules/ansi-align/node_modules/ansi-regex/license +9 -0
- package/node_modules/ansi-align/node_modules/ansi-regex/package.json +55 -0
- package/node_modules/ansi-align/node_modules/ansi-regex/readme.md +78 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/README.md +73 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/es2015/index.js +6 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/es2015/text.js +6 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/index.d.ts +23 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/index.js +6 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/package.json +50 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/text.js +6 -0
- package/node_modules/ansi-align/node_modules/string-width/index.d.ts +29 -0
- package/node_modules/ansi-align/node_modules/string-width/index.js +47 -0
- package/node_modules/ansi-align/node_modules/string-width/license +9 -0
- package/node_modules/ansi-align/node_modules/string-width/package.json +56 -0
- package/node_modules/ansi-align/node_modules/string-width/readme.md +50 -0
- package/node_modules/ansi-align/node_modules/strip-ansi/index.d.ts +17 -0
- package/node_modules/ansi-align/node_modules/strip-ansi/index.js +4 -0
- package/node_modules/ansi-align/node_modules/strip-ansi/license +9 -0
- package/node_modules/ansi-align/node_modules/strip-ansi/package.json +54 -0
- package/node_modules/ansi-align/node_modules/strip-ansi/readme.md +46 -0
- package/node_modules/ansi-align/package.json +43 -0
- package/node_modules/ansi-regex/index.d.ts +33 -0
- package/node_modules/ansi-regex/index.js +14 -0
- package/node_modules/ansi-regex/license +9 -0
- package/node_modules/ansi-regex/package.json +61 -0
- package/node_modules/ansi-regex/readme.md +66 -0
- package/node_modules/ansi-styles/index.d.ts +236 -0
- package/node_modules/ansi-styles/index.js +223 -0
- package/node_modules/ansi-styles/license +9 -0
- package/node_modules/ansi-styles/package.json +54 -0
- package/node_modules/ansi-styles/readme.md +173 -0
- package/node_modules/boxen/index.d.ts +267 -0
- package/node_modules/boxen/index.js +376 -0
- package/node_modules/boxen/license +9 -0
- package/node_modules/boxen/package.json +69 -0
- package/node_modules/boxen/readme.md +300 -0
- package/node_modules/camelcase/index.d.ts +102 -0
- package/node_modules/camelcase/index.js +110 -0
- package/node_modules/camelcase/license +9 -0
- package/node_modules/camelcase/package.json +47 -0
- package/node_modules/camelcase/readme.md +135 -0
- package/node_modules/chalk/license +9 -0
- package/node_modules/chalk/package.json +83 -0
- package/node_modules/chalk/readme.md +297 -0
- package/node_modules/chalk/source/index.d.ts +325 -0
- package/node_modules/chalk/source/index.js +225 -0
- package/node_modules/chalk/source/utilities.js +33 -0
- package/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +236 -0
- package/node_modules/chalk/source/vendor/ansi-styles/index.js +223 -0
- package/node_modules/chalk/source/vendor/supports-color/browser.d.ts +1 -0
- package/node_modules/chalk/source/vendor/supports-color/browser.js +34 -0
- package/node_modules/chalk/source/vendor/supports-color/index.d.ts +55 -0
- package/node_modules/chalk/source/vendor/supports-color/index.js +190 -0
- package/node_modules/cli-boxes/boxes.json +82 -0
- package/node_modules/cli-boxes/index.d.ts +127 -0
- package/node_modules/cli-boxes/index.js +6 -0
- package/node_modules/cli-boxes/license +9 -0
- package/node_modules/cli-boxes/package.json +42 -0
- package/node_modules/cli-boxes/readme.md +115 -0
- package/node_modules/cli-table3/LICENSE +21 -0
- package/node_modules/cli-table3/README.md +236 -0
- package/node_modules/cli-table3/index.d.ts +96 -0
- package/node_modules/cli-table3/index.js +1 -0
- package/node_modules/cli-table3/node_modules/ansi-regex/index.d.ts +37 -0
- package/node_modules/cli-table3/node_modules/ansi-regex/index.js +10 -0
- package/node_modules/cli-table3/node_modules/ansi-regex/license +9 -0
- package/node_modules/cli-table3/node_modules/ansi-regex/package.json +55 -0
- package/node_modules/cli-table3/node_modules/ansi-regex/readme.md +78 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/README.md +73 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/es2015/index.js +6 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/es2015/text.js +6 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/index.d.ts +23 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/index.js +6 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/package.json +50 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/text.js +6 -0
- package/node_modules/cli-table3/node_modules/string-width/index.d.ts +29 -0
- package/node_modules/cli-table3/node_modules/string-width/index.js +47 -0
- package/node_modules/cli-table3/node_modules/string-width/license +9 -0
- package/node_modules/cli-table3/node_modules/string-width/package.json +56 -0
- package/node_modules/cli-table3/node_modules/string-width/readme.md +50 -0
- package/node_modules/cli-table3/node_modules/strip-ansi/index.d.ts +17 -0
- package/node_modules/cli-table3/node_modules/strip-ansi/index.js +4 -0
- package/node_modules/cli-table3/node_modules/strip-ansi/license +9 -0
- package/node_modules/cli-table3/node_modules/strip-ansi/package.json +54 -0
- package/node_modules/cli-table3/node_modules/strip-ansi/readme.md +46 -0
- package/node_modules/cli-table3/package.json +100 -0
- package/node_modules/cli-table3/src/cell.js +409 -0
- package/node_modules/cli-table3/src/debug.js +28 -0
- package/node_modules/cli-table3/src/layout-manager.js +254 -0
- package/node_modules/cli-table3/src/table.js +106 -0
- package/node_modules/cli-table3/src/utils.js +344 -0
- package/node_modules/commander/LICENSE +22 -0
- package/node_modules/commander/Readme.md +1157 -0
- package/node_modules/commander/esm.mjs +16 -0
- package/node_modules/commander/index.js +24 -0
- package/node_modules/commander/lib/argument.js +149 -0
- package/node_modules/commander/lib/command.js +2509 -0
- package/node_modules/commander/lib/error.js +39 -0
- package/node_modules/commander/lib/help.js +520 -0
- package/node_modules/commander/lib/option.js +330 -0
- package/node_modules/commander/lib/suggestSimilar.js +101 -0
- package/node_modules/commander/package-support.json +16 -0
- package/node_modules/commander/package.json +84 -0
- package/node_modules/commander/typings/esm.d.mts +3 -0
- package/node_modules/commander/typings/index.d.ts +969 -0
- package/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
- package/node_modules/emoji-regex/README.md +107 -0
- package/node_modules/emoji-regex/index.d.ts +3 -0
- package/node_modules/emoji-regex/index.js +4 -0
- package/node_modules/emoji-regex/index.mjs +4 -0
- package/node_modules/emoji-regex/package.json +45 -0
- package/node_modules/get-east-asian-width/index.d.ts +60 -0
- package/node_modules/get-east-asian-width/index.js +30 -0
- package/node_modules/get-east-asian-width/license +9 -0
- package/node_modules/get-east-asian-width/lookup-data.js +18 -0
- package/node_modules/get-east-asian-width/lookup.js +135 -0
- package/node_modules/get-east-asian-width/package.json +71 -0
- package/node_modules/get-east-asian-width/readme.md +65 -0
- package/node_modules/get-east-asian-width/utilities.js +24 -0
- package/node_modules/is-fullwidth-code-point/index.d.ts +17 -0
- package/node_modules/is-fullwidth-code-point/index.js +50 -0
- package/node_modules/is-fullwidth-code-point/license +9 -0
- package/node_modules/is-fullwidth-code-point/package.json +42 -0
- package/node_modules/is-fullwidth-code-point/readme.md +39 -0
- package/node_modules/isbinaryfile/LICENSE.txt +22 -0
- package/node_modules/isbinaryfile/README.md +70 -0
- package/node_modules/isbinaryfile/lib/index.d.ts +3 -0
- package/node_modules/isbinaryfile/lib/index.js +256 -0
- package/node_modules/isbinaryfile/package.json +64 -0
- package/node_modules/string-width/index.d.ts +39 -0
- package/node_modules/string-width/index.js +82 -0
- package/node_modules/string-width/license +9 -0
- package/node_modules/string-width/package.json +64 -0
- package/node_modules/string-width/readme.md +66 -0
- package/node_modules/strip-ansi/index.d.ts +15 -0
- package/node_modules/strip-ansi/index.js +19 -0
- package/node_modules/strip-ansi/license +9 -0
- package/node_modules/strip-ansi/package.json +59 -0
- package/node_modules/strip-ansi/readme.md +37 -0
- package/node_modules/type-fest/index.d.ts +178 -0
- package/node_modules/type-fest/license-cc0 +121 -0
- package/node_modules/type-fest/license-mit +9 -0
- package/node_modules/type-fest/package.json +91 -0
- package/node_modules/type-fest/readme.md +1060 -0
- package/node_modules/type-fest/source/all-union-fields.d.ts +88 -0
- package/node_modules/type-fest/source/and.d.ts +25 -0
- package/node_modules/type-fest/source/array-indices.d.ts +23 -0
- package/node_modules/type-fest/source/array-slice.d.ts +109 -0
- package/node_modules/type-fest/source/array-splice.d.ts +99 -0
- package/node_modules/type-fest/source/array-tail.d.ts +76 -0
- package/node_modules/type-fest/source/array-values.d.ts +22 -0
- package/node_modules/type-fest/source/arrayable.d.ts +29 -0
- package/node_modules/type-fest/source/async-return-type.d.ts +23 -0
- package/node_modules/type-fest/source/asyncify.d.ts +32 -0
- package/node_modules/type-fest/source/basic.d.ts +68 -0
- package/node_modules/type-fest/source/camel-case.d.ts +89 -0
- package/node_modules/type-fest/source/camel-cased-properties-deep.d.ts +97 -0
- package/node_modules/type-fest/source/camel-cased-properties.d.ts +43 -0
- package/node_modules/type-fest/source/conditional-except.d.ts +45 -0
- package/node_modules/type-fest/source/conditional-keys.d.ts +47 -0
- package/node_modules/type-fest/source/conditional-pick-deep.d.ts +118 -0
- package/node_modules/type-fest/source/conditional-pick.d.ts +44 -0
- package/node_modules/type-fest/source/conditional-simplify.d.ts +32 -0
- package/node_modules/type-fest/source/delimiter-case.d.ts +78 -0
- package/node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts +106 -0
- package/node_modules/type-fest/source/delimiter-cased-properties.d.ts +46 -0
- package/node_modules/type-fest/source/distributed-omit.d.ts +89 -0
- package/node_modules/type-fest/source/distributed-pick.d.ts +85 -0
- package/node_modules/type-fest/source/empty-object.d.ts +46 -0
- package/node_modules/type-fest/source/enforce-optional.d.ts +47 -0
- package/node_modules/type-fest/source/entries.d.ts +62 -0
- package/node_modules/type-fest/source/entry.d.ts +65 -0
- package/node_modules/type-fest/source/exact.d.ts +68 -0
- package/node_modules/type-fest/source/except.d.ts +108 -0
- package/node_modules/type-fest/source/find-global-type.d.ts +64 -0
- package/node_modules/type-fest/source/fixed-length-array.d.ts +43 -0
- package/node_modules/type-fest/source/get.d.ts +219 -0
- package/node_modules/type-fest/source/global-this.d.ts +21 -0
- package/node_modules/type-fest/source/greater-than-or-equal.d.ts +22 -0
- package/node_modules/type-fest/source/greater-than.d.ts +56 -0
- package/node_modules/type-fest/source/has-optional-keys.d.ts +21 -0
- package/node_modules/type-fest/source/has-readonly-keys.d.ts +21 -0
- package/node_modules/type-fest/source/has-required-keys.d.ts +59 -0
- package/node_modules/type-fest/source/has-writable-keys.d.ts +21 -0
- package/node_modules/type-fest/source/if-any.d.ts +24 -0
- package/node_modules/type-fest/source/if-empty-object.d.ts +26 -0
- package/node_modules/type-fest/source/if-never.d.ts +24 -0
- package/node_modules/type-fest/source/if-null.d.ts +24 -0
- package/node_modules/type-fest/source/if-unknown.d.ts +24 -0
- package/node_modules/type-fest/source/includes.d.ts +22 -0
- package/node_modules/type-fest/source/int-closed-range.d.ts +35 -0
- package/node_modules/type-fest/source/int-range.d.ts +55 -0
- package/node_modules/type-fest/source/internal/array.d.ts +126 -0
- package/node_modules/type-fest/source/internal/characters.d.ts +67 -0
- package/node_modules/type-fest/source/internal/index.d.ts +8 -0
- package/node_modules/type-fest/source/internal/keys.d.ts +97 -0
- package/node_modules/type-fest/source/internal/numeric.d.ts +118 -0
- package/node_modules/type-fest/source/internal/object.d.ts +236 -0
- package/node_modules/type-fest/source/internal/string.d.ts +210 -0
- package/node_modules/type-fest/source/internal/tuple.d.ts +90 -0
- package/node_modules/type-fest/source/internal/type.d.ts +139 -0
- package/node_modules/type-fest/source/invariant-of.d.ts +76 -0
- package/node_modules/type-fest/source/is-any.d.ts +33 -0
- package/node_modules/type-fest/source/is-equal.d.ts +31 -0
- package/node_modules/type-fest/source/is-float.d.ts +41 -0
- package/node_modules/type-fest/source/is-integer.d.ts +58 -0
- package/node_modules/type-fest/source/is-literal.d.ts +296 -0
- package/node_modules/type-fest/source/is-never.d.ts +42 -0
- package/node_modules/type-fest/source/is-null.d.ts +20 -0
- package/node_modules/type-fest/source/is-tuple.d.ts +89 -0
- package/node_modules/type-fest/source/is-unknown.d.ts +52 -0
- package/node_modules/type-fest/source/iterable-element.d.ts +64 -0
- package/node_modules/type-fest/source/join.d.ts +68 -0
- package/node_modules/type-fest/source/jsonifiable.d.ts +37 -0
- package/node_modules/type-fest/source/jsonify.d.ts +122 -0
- package/node_modules/type-fest/source/kebab-case.d.ts +44 -0
- package/node_modules/type-fest/source/kebab-cased-properties-deep.d.ts +63 -0
- package/node_modules/type-fest/source/kebab-cased-properties.d.ts +40 -0
- package/node_modules/type-fest/source/keys-of-union.d.ts +42 -0
- package/node_modules/type-fest/source/last-array-element.d.ts +38 -0
- package/node_modules/type-fest/source/less-than-or-equal.d.ts +22 -0
- package/node_modules/type-fest/source/less-than.d.ts +26 -0
- package/node_modules/type-fest/source/literal-to-primitive-deep.d.ts +36 -0
- package/node_modules/type-fest/source/literal-to-primitive.d.ts +36 -0
- package/node_modules/type-fest/source/literal-union.d.ts +37 -0
- package/node_modules/type-fest/source/merge-deep.d.ts +486 -0
- package/node_modules/type-fest/source/merge-exclusive.d.ts +41 -0
- package/node_modules/type-fest/source/merge.d.ts +48 -0
- package/node_modules/type-fest/source/multidimensional-array.d.ts +44 -0
- package/node_modules/type-fest/source/multidimensional-readonly-array.d.ts +48 -0
- package/node_modules/type-fest/source/non-empty-object.d.ts +35 -0
- package/node_modules/type-fest/source/non-empty-string.d.ts +28 -0
- package/node_modules/type-fest/source/non-empty-tuple.d.ts +21 -0
- package/node_modules/type-fest/source/numeric.d.ts +222 -0
- package/node_modules/type-fest/source/observable-like.d.ts +63 -0
- package/node_modules/type-fest/source/omit-deep.d.ts +167 -0
- package/node_modules/type-fest/source/omit-index-signature.d.ts +95 -0
- package/node_modules/type-fest/source/opaque.d.ts +1 -0
- package/node_modules/type-fest/source/optional-keys-of.d.ts +39 -0
- package/node_modules/type-fest/source/or.d.ts +25 -0
- package/node_modules/type-fest/source/override-properties.d.ts +36 -0
- package/node_modules/type-fest/source/package-json.d.ts +676 -0
- package/node_modules/type-fest/source/partial-deep.d.ts +151 -0
- package/node_modules/type-fest/source/partial-on-undefined-deep.d.ts +78 -0
- package/node_modules/type-fest/source/pascal-case.d.ts +42 -0
- package/node_modules/type-fest/source/pascal-cased-properties-deep.d.ts +62 -0
- package/node_modules/type-fest/source/pascal-cased-properties.d.ts +36 -0
- package/node_modules/type-fest/source/paths.d.ts +262 -0
- package/node_modules/type-fest/source/pick-deep.d.ts +149 -0
- package/node_modules/type-fest/source/pick-index-signature.d.ts +50 -0
- package/node_modules/type-fest/source/primitive.d.ts +13 -0
- package/node_modules/type-fest/source/promisable.d.ts +25 -0
- package/node_modules/type-fest/source/readonly-deep.d.ts +81 -0
- package/node_modules/type-fest/source/readonly-keys-of.d.ts +30 -0
- package/node_modules/type-fest/source/readonly-tuple.d.ts +41 -0
- package/node_modules/type-fest/source/replace.d.ts +85 -0
- package/node_modules/type-fest/source/require-all-or-none.d.ts +51 -0
- package/node_modules/type-fest/source/require-at-least-one.d.ts +47 -0
- package/node_modules/type-fest/source/require-exactly-one.d.ts +45 -0
- package/node_modules/type-fest/source/require-one-or-none.d.ts +46 -0
- package/node_modules/type-fest/source/required-deep.d.ts +78 -0
- package/node_modules/type-fest/source/required-keys-of.d.ts +30 -0
- package/node_modules/type-fest/source/schema.d.ts +114 -0
- package/node_modules/type-fest/source/screaming-snake-case.d.ts +28 -0
- package/node_modules/type-fest/source/set-field-type.d.ts +65 -0
- package/node_modules/type-fest/source/set-non-nullable-deep.d.ts +83 -0
- package/node_modules/type-fest/source/set-non-nullable.d.ts +39 -0
- package/node_modules/type-fest/source/set-optional.d.ts +38 -0
- package/node_modules/type-fest/source/set-parameter-type.d.ts +117 -0
- package/node_modules/type-fest/source/set-readonly.d.ts +39 -0
- package/node_modules/type-fest/source/set-required-deep.d.ts +68 -0
- package/node_modules/type-fest/source/set-required.d.ts +70 -0
- package/node_modules/type-fest/source/set-return-type.d.ts +29 -0
- package/node_modules/type-fest/source/shared-union-fields-deep.d.ts +178 -0
- package/node_modules/type-fest/source/shared-union-fields.d.ts +76 -0
- package/node_modules/type-fest/source/simplify-deep.d.ts +115 -0
- package/node_modules/type-fest/source/simplify.d.ts +58 -0
- package/node_modules/type-fest/source/single-key-object.d.ts +29 -0
- package/node_modules/type-fest/source/snake-case.d.ts +45 -0
- package/node_modules/type-fest/source/snake-cased-properties-deep.d.ts +63 -0
- package/node_modules/type-fest/source/snake-cased-properties.d.ts +40 -0
- package/node_modules/type-fest/source/split.d.ts +88 -0
- package/node_modules/type-fest/source/spread.d.ts +84 -0
- package/node_modules/type-fest/source/string-key-of.d.ts +25 -0
- package/node_modules/type-fest/source/string-repeat.d.ts +47 -0
- package/node_modules/type-fest/source/string-slice.d.ts +37 -0
- package/node_modules/type-fest/source/stringified.d.ts +23 -0
- package/node_modules/type-fest/source/structured-cloneable.d.ts +92 -0
- package/node_modules/type-fest/source/subtract.d.ts +83 -0
- package/node_modules/type-fest/source/sum.d.ts +78 -0
- package/node_modules/type-fest/source/tagged-union.d.ts +51 -0
- package/node_modules/type-fest/source/tagged.d.ts +256 -0
- package/node_modules/type-fest/source/trim.d.ts +27 -0
- package/node_modules/type-fest/source/tsconfig-json.d.ts +1294 -0
- package/node_modules/type-fest/source/tuple-to-object.d.ts +42 -0
- package/node_modules/type-fest/source/tuple-to-union.d.ts +51 -0
- package/node_modules/type-fest/source/typed-array.d.ts +17 -0
- package/node_modules/type-fest/source/undefined-on-partial-deep.d.ts +80 -0
- package/node_modules/type-fest/source/union-to-intersection.d.ts +61 -0
- package/node_modules/type-fest/source/union-to-tuple.d.ts +56 -0
- package/node_modules/type-fest/source/unknown-array.d.ts +25 -0
- package/node_modules/type-fest/source/unknown-map.d.ts +24 -0
- package/node_modules/type-fest/source/unknown-record.d.ts +31 -0
- package/node_modules/type-fest/source/unknown-set.d.ts +24 -0
- package/node_modules/type-fest/source/value-of.d.ts +42 -0
- package/node_modules/type-fest/source/words.d.ts +118 -0
- package/node_modules/type-fest/source/writable-deep.d.ts +83 -0
- package/node_modules/type-fest/source/writable-keys-of.d.ts +33 -0
- package/node_modules/type-fest/source/writable.d.ts +68 -0
- package/node_modules/widest-line/index.d.ts +12 -0
- package/node_modules/widest-line/index.js +11 -0
- package/node_modules/widest-line/license +9 -0
- package/node_modules/widest-line/package.json +60 -0
- package/node_modules/widest-line/readme.md +26 -0
- package/node_modules/wrap-ansi/index.d.ts +41 -0
- package/node_modules/wrap-ansi/index.js +222 -0
- package/node_modules/wrap-ansi/license +9 -0
- package/node_modules/wrap-ansi/package.json +69 -0
- package/node_modules/wrap-ansi/readme.md +75 -0
- package/package.json +78 -0
- package/scripts/postinstall.cjs +122 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import type {Simplify} from '../simplify';
|
|
2
|
+
import type {UnknownArray} from '../unknown-array';
|
|
3
|
+
import type {IsEqual} from '../is-equal';
|
|
4
|
+
import type {KeysOfUnion} from '../keys-of-union';
|
|
5
|
+
import type {RequiredKeysOf} from '../required-keys-of';
|
|
6
|
+
import type {Merge} from '../merge';
|
|
7
|
+
import type {IfAny} from '../if-any';
|
|
8
|
+
import type {IfNever} from '../if-never';
|
|
9
|
+
import type {OptionalKeysOf} from '../optional-keys-of';
|
|
10
|
+
import type {FilterDefinedKeys, FilterOptionalKeys} from './keys';
|
|
11
|
+
import type {NonRecursiveType} from './type';
|
|
12
|
+
import type {ToString} from './string';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
Create an object type with the given key `<Key>` and value `<Value>`.
|
|
16
|
+
|
|
17
|
+
It will copy the prefix and optional status of the same key from the given object `CopiedFrom` into the result.
|
|
18
|
+
|
|
19
|
+
@example
|
|
20
|
+
```
|
|
21
|
+
type A = BuildObject<'a', string>;
|
|
22
|
+
//=> {a: string}
|
|
23
|
+
|
|
24
|
+
// Copy `readonly` and `?` from the key `a` of `{readonly a?: any}`
|
|
25
|
+
type B = BuildObject<'a', string, {readonly a?: any}>;
|
|
26
|
+
//=> {readonly a?: string}
|
|
27
|
+
```
|
|
28
|
+
*/
|
|
29
|
+
export type BuildObject<Key extends PropertyKey, Value, CopiedFrom extends object = {}> =
|
|
30
|
+
Key extends keyof CopiedFrom
|
|
31
|
+
? Pick<{[_ in keyof CopiedFrom]: Value}, Key>
|
|
32
|
+
: Key extends `${infer NumberKey extends number}`
|
|
33
|
+
? NumberKey extends keyof CopiedFrom
|
|
34
|
+
? Pick<{[_ in keyof CopiedFrom]: Value}, NumberKey>
|
|
35
|
+
: {[_ in Key]: Value}
|
|
36
|
+
: {[_ in Key]: Value};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
Returns a boolean for whether the given type is a plain key-value object.
|
|
40
|
+
*/
|
|
41
|
+
export type IsPlainObject<T> =
|
|
42
|
+
T extends NonRecursiveType | UnknownArray | ReadonlyMap<unknown, unknown> | ReadonlySet<unknown>
|
|
43
|
+
? false
|
|
44
|
+
: T extends object
|
|
45
|
+
? true
|
|
46
|
+
: false;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
Extract the object field type if T is an object and K is a key of T, return `never` otherwise.
|
|
50
|
+
|
|
51
|
+
It creates a type-safe way to access the member type of `unknown` type.
|
|
52
|
+
*/
|
|
53
|
+
export type ObjectValue<T, K> =
|
|
54
|
+
K extends keyof T
|
|
55
|
+
? T[K]
|
|
56
|
+
: ToString<K> extends keyof T
|
|
57
|
+
? T[ToString<K>]
|
|
58
|
+
: K extends `${infer NumberK extends number}`
|
|
59
|
+
? NumberK extends keyof T
|
|
60
|
+
? T[NumberK]
|
|
61
|
+
: never
|
|
62
|
+
: never;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
For an object T, if it has any properties that are a union with `undefined`, make those into optional properties instead.
|
|
66
|
+
|
|
67
|
+
@example
|
|
68
|
+
```
|
|
69
|
+
type User = {
|
|
70
|
+
firstName: string;
|
|
71
|
+
lastName: string | undefined;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
type OptionalizedUser = UndefinedToOptional<User>;
|
|
75
|
+
//=> {
|
|
76
|
+
// firstName: string;
|
|
77
|
+
// lastName?: string;
|
|
78
|
+
// }
|
|
79
|
+
```
|
|
80
|
+
*/
|
|
81
|
+
export type UndefinedToOptional<T extends object> = Simplify<
|
|
82
|
+
{
|
|
83
|
+
// Property is not a union with `undefined`, keep it as-is.
|
|
84
|
+
[Key in keyof Pick<T, FilterDefinedKeys<T>>]: T[Key];
|
|
85
|
+
} & {
|
|
86
|
+
// Property _is_ a union with defined value. Set as optional (via `?`) and remove `undefined` from the union.
|
|
87
|
+
[Key in keyof Pick<T, FilterOptionalKeys<T>>]?: Exclude<T[Key], undefined>;
|
|
88
|
+
}
|
|
89
|
+
>;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
Works similar to the built-in `Pick` utility type, except for the following differences:
|
|
93
|
+
- Distributes over union types and allows picking keys from any member of the union type.
|
|
94
|
+
- Primitives types are returned as-is.
|
|
95
|
+
- Picks all keys if `Keys` is `any`.
|
|
96
|
+
- Doesn't pick `number` from a `string` index signature.
|
|
97
|
+
|
|
98
|
+
@example
|
|
99
|
+
```
|
|
100
|
+
type ImageUpload = {
|
|
101
|
+
url: string;
|
|
102
|
+
size: number;
|
|
103
|
+
thumbnailUrl: string;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
type VideoUpload = {
|
|
107
|
+
url: string;
|
|
108
|
+
duration: number;
|
|
109
|
+
encodingFormat: string;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// Distributes over union types and allows picking keys from any member of the union type
|
|
113
|
+
type MediaDisplay = HomomorphicPick<ImageUpload | VideoUpload, "url" | "size" | "duration">;
|
|
114
|
+
//=> {url: string; size: number} | {url: string; duration: number}
|
|
115
|
+
|
|
116
|
+
// Primitive types are returned as-is
|
|
117
|
+
type Primitive = HomomorphicPick<string | number, 'toUpperCase' | 'toString'>;
|
|
118
|
+
//=> string | number
|
|
119
|
+
|
|
120
|
+
// Picks all keys if `Keys` is `any`
|
|
121
|
+
type Any = HomomorphicPick<{a: 1; b: 2} | {c: 3}, any>;
|
|
122
|
+
//=> {a: 1; b: 2} | {c: 3}
|
|
123
|
+
|
|
124
|
+
// Doesn't pick `number` from a `string` index signature
|
|
125
|
+
type IndexSignature = HomomorphicPick<{[k: string]: unknown}, number>;
|
|
126
|
+
//=> {}
|
|
127
|
+
*/
|
|
128
|
+
export type HomomorphicPick<T, Keys extends KeysOfUnion<T>> = {
|
|
129
|
+
[P in keyof T as Extract<P, Keys>]: T[P]
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
Extract all possible values for a given key from a union of object types.
|
|
134
|
+
|
|
135
|
+
@example
|
|
136
|
+
```
|
|
137
|
+
type Statuses = ValueOfUnion<{ id: 1, status: "open" } | { id: 2, status: "closed" }, "status">;
|
|
138
|
+
//=> "open" | "closed"
|
|
139
|
+
```
|
|
140
|
+
*/
|
|
141
|
+
export type ValueOfUnion<Union, Key extends KeysOfUnion<Union>> =
|
|
142
|
+
Union extends unknown ? Key extends keyof Union ? Union[Key] : never : never;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
Extract all readonly keys from a union of object types.
|
|
146
|
+
|
|
147
|
+
@example
|
|
148
|
+
```
|
|
149
|
+
type User = {
|
|
150
|
+
readonly id: string;
|
|
151
|
+
name: string;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
type Post = {
|
|
155
|
+
readonly id: string;
|
|
156
|
+
readonly author: string;
|
|
157
|
+
body: string;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
type ReadonlyKeys = ReadonlyKeysOfUnion<User | Post>;
|
|
161
|
+
//=> "id" | "author"
|
|
162
|
+
```
|
|
163
|
+
*/
|
|
164
|
+
export type ReadonlyKeysOfUnion<Union> = Union extends unknown ? keyof {
|
|
165
|
+
[Key in keyof Union as IsEqual<{[K in Key]: Union[Key]}, {readonly [K in Key]: Union[Key]}> extends true ? Key : never]: never
|
|
166
|
+
} : never;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
Merges user specified options with default options.
|
|
170
|
+
|
|
171
|
+
@example
|
|
172
|
+
```
|
|
173
|
+
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
174
|
+
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
175
|
+
type SpecifiedOptions = {leavesOnly: true};
|
|
176
|
+
|
|
177
|
+
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
178
|
+
//=> {maxRecursionDepth: 10; leavesOnly: true}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
@example
|
|
182
|
+
```
|
|
183
|
+
// Complains if default values are not provided for optional options
|
|
184
|
+
|
|
185
|
+
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
186
|
+
type DefaultPathsOptions = {maxRecursionDepth: 10};
|
|
187
|
+
type SpecifiedOptions = {};
|
|
188
|
+
|
|
189
|
+
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
190
|
+
// ~~~~~~~~~~~~~~~~~~~
|
|
191
|
+
// Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
@example
|
|
195
|
+
```
|
|
196
|
+
// Complains if an option's default type does not conform to the expected type
|
|
197
|
+
|
|
198
|
+
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
199
|
+
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
|
|
200
|
+
type SpecifiedOptions = {};
|
|
201
|
+
|
|
202
|
+
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
203
|
+
// ~~~~~~~~~~~~~~~~~~~
|
|
204
|
+
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
@example
|
|
208
|
+
```
|
|
209
|
+
// Complains if an option's specified type does not conform to the expected type
|
|
210
|
+
|
|
211
|
+
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
212
|
+
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
213
|
+
type SpecifiedOptions = {leavesOnly: 'yes'};
|
|
214
|
+
|
|
215
|
+
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
216
|
+
// ~~~~~~~~~~~~~~~~
|
|
217
|
+
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
218
|
+
```
|
|
219
|
+
*/
|
|
220
|
+
export type ApplyDefaultOptions<
|
|
221
|
+
Options extends object,
|
|
222
|
+
Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>,
|
|
223
|
+
SpecifiedOptions extends Options,
|
|
224
|
+
> =
|
|
225
|
+
IfAny<SpecifiedOptions, Defaults,
|
|
226
|
+
IfNever<SpecifiedOptions, Defaults,
|
|
227
|
+
Simplify<Merge<Defaults, {
|
|
228
|
+
[Key in keyof SpecifiedOptions
|
|
229
|
+
as Key extends OptionalKeysOf<Options>
|
|
230
|
+
? Extract<SpecifiedOptions[Key], undefined> extends never
|
|
231
|
+
? Key
|
|
232
|
+
: never
|
|
233
|
+
: Key
|
|
234
|
+
]: SpecifiedOptions[Key]
|
|
235
|
+
}> & Required<Options>> // `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
|
|
236
|
+
>>;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import type {NegativeInfinity, PositiveInfinity} from '../numeric';
|
|
2
|
+
import type {Trim} from '../trim';
|
|
3
|
+
import type {Whitespace} from './characters';
|
|
4
|
+
import type {BuildTuple} from './tuple';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
Return a string representation of the given string or number.
|
|
8
|
+
|
|
9
|
+
Note: This type is not the return type of the `.toString()` function.
|
|
10
|
+
*/
|
|
11
|
+
export type ToString<T> = T extends string | number ? `${T}` : never;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
Converts a numeric string to a number.
|
|
15
|
+
|
|
16
|
+
@example
|
|
17
|
+
```
|
|
18
|
+
type PositiveInt = StringToNumber<'1234'>;
|
|
19
|
+
//=> 1234
|
|
20
|
+
|
|
21
|
+
type NegativeInt = StringToNumber<'-1234'>;
|
|
22
|
+
//=> -1234
|
|
23
|
+
|
|
24
|
+
type PositiveFloat = StringToNumber<'1234.56'>;
|
|
25
|
+
//=> 1234.56
|
|
26
|
+
|
|
27
|
+
type NegativeFloat = StringToNumber<'-1234.56'>;
|
|
28
|
+
//=> -1234.56
|
|
29
|
+
|
|
30
|
+
type PositiveInfinity = StringToNumber<'Infinity'>;
|
|
31
|
+
//=> Infinity
|
|
32
|
+
|
|
33
|
+
type NegativeInfinity = StringToNumber<'-Infinity'>;
|
|
34
|
+
//=> -Infinity
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
@category String
|
|
38
|
+
@category Numeric
|
|
39
|
+
@category Template literal
|
|
40
|
+
*/
|
|
41
|
+
export type StringToNumber<S extends string> = S extends `${infer N extends number}`
|
|
42
|
+
? N
|
|
43
|
+
: S extends 'Infinity'
|
|
44
|
+
? PositiveInfinity
|
|
45
|
+
: S extends '-Infinity'
|
|
46
|
+
? NegativeInfinity
|
|
47
|
+
: never;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
Returns a boolean for whether the given string `S` starts with the given string `SearchString`.
|
|
51
|
+
|
|
52
|
+
@example
|
|
53
|
+
```
|
|
54
|
+
StartsWith<'abcde', 'abc'>;
|
|
55
|
+
//=> true
|
|
56
|
+
|
|
57
|
+
StartsWith<'abcde', 'bc'>;
|
|
58
|
+
//=> false
|
|
59
|
+
|
|
60
|
+
StartsWith<string, 'bc'>;
|
|
61
|
+
//=> never
|
|
62
|
+
|
|
63
|
+
StartsWith<'abcde', string>;
|
|
64
|
+
//=> never
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
@category String
|
|
68
|
+
@category Template literal
|
|
69
|
+
*/
|
|
70
|
+
export type StartsWith<S extends string, SearchString extends string> = string extends S | SearchString
|
|
71
|
+
? never
|
|
72
|
+
: S extends `${SearchString}${infer T}`
|
|
73
|
+
? true
|
|
74
|
+
: false;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
Returns an array of the characters of the string.
|
|
78
|
+
|
|
79
|
+
@example
|
|
80
|
+
```
|
|
81
|
+
StringToArray<'abcde'>;
|
|
82
|
+
//=> ['a', 'b', 'c', 'd', 'e']
|
|
83
|
+
|
|
84
|
+
StringToArray<string>;
|
|
85
|
+
//=> never
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
@category String
|
|
89
|
+
*/
|
|
90
|
+
export type StringToArray<S extends string, Result extends string[] = []> = string extends S
|
|
91
|
+
? never
|
|
92
|
+
: S extends `${infer F}${infer R}`
|
|
93
|
+
? StringToArray<R, [...Result, F]>
|
|
94
|
+
: Result;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
Returns the length of the given string.
|
|
98
|
+
|
|
99
|
+
@example
|
|
100
|
+
```
|
|
101
|
+
StringLength<'abcde'>;
|
|
102
|
+
//=> 5
|
|
103
|
+
|
|
104
|
+
StringLength<string>;
|
|
105
|
+
//=> never
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
@category String
|
|
109
|
+
@category Template literal
|
|
110
|
+
*/
|
|
111
|
+
export type StringLength<S extends string> = string extends S
|
|
112
|
+
? never
|
|
113
|
+
: StringToArray<S>['length'];
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
Returns a boolean for whether the string is lowercased.
|
|
117
|
+
*/
|
|
118
|
+
export type IsLowerCase<T extends string> = T extends Lowercase<T> ? true : false;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
Returns a boolean for whether the string is uppercased.
|
|
122
|
+
*/
|
|
123
|
+
export type IsUpperCase<T extends string> = T extends Uppercase<T> ? true : false;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
Returns a boolean for whether a string is whitespace.
|
|
127
|
+
*/
|
|
128
|
+
export type IsWhitespace<T extends string> = T extends Whitespace
|
|
129
|
+
? true
|
|
130
|
+
: T extends `${Whitespace}${infer Rest}`
|
|
131
|
+
? IsWhitespace<Rest>
|
|
132
|
+
: false;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
Returns a boolean for whether the string is numeric.
|
|
136
|
+
|
|
137
|
+
This type is a workaround for [Microsoft/TypeScript#46109](https://github.com/microsoft/TypeScript/issues/46109#issuecomment-930307987).
|
|
138
|
+
*/
|
|
139
|
+
export type IsNumeric<T extends string> = T extends `${number}`
|
|
140
|
+
? Trim<T> extends T
|
|
141
|
+
? true
|
|
142
|
+
: false
|
|
143
|
+
: false;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
Returns a boolean for whether `A` represents a number greater than `B`, where `A` and `B` are both numeric strings and have the same length.
|
|
147
|
+
|
|
148
|
+
@example
|
|
149
|
+
```
|
|
150
|
+
SameLengthPositiveNumericStringGt<'50', '10'>;
|
|
151
|
+
//=> true
|
|
152
|
+
|
|
153
|
+
SameLengthPositiveNumericStringGt<'10', '10'>;
|
|
154
|
+
//=> false
|
|
155
|
+
```
|
|
156
|
+
*/
|
|
157
|
+
type SameLengthPositiveNumericStringGt<A extends string, B extends string> = A extends `${infer FirstA}${infer RestA}`
|
|
158
|
+
? B extends `${infer FirstB}${infer RestB}`
|
|
159
|
+
? FirstA extends FirstB
|
|
160
|
+
? SameLengthPositiveNumericStringGt<RestA, RestB>
|
|
161
|
+
: PositiveNumericCharacterGt<FirstA, FirstB>
|
|
162
|
+
: never
|
|
163
|
+
: false;
|
|
164
|
+
|
|
165
|
+
type NumericString = '0123456789';
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
Returns a boolean for whether `A` is greater than `B`, where `A` and `B` are both positive numeric strings.
|
|
169
|
+
|
|
170
|
+
@example
|
|
171
|
+
```
|
|
172
|
+
PositiveNumericStringGt<'500', '1'>;
|
|
173
|
+
//=> true
|
|
174
|
+
|
|
175
|
+
PositiveNumericStringGt<'1', '1'>;
|
|
176
|
+
//=> false
|
|
177
|
+
|
|
178
|
+
PositiveNumericStringGt<'1', '500'>;
|
|
179
|
+
//=> false
|
|
180
|
+
```
|
|
181
|
+
*/
|
|
182
|
+
export type PositiveNumericStringGt<A extends string, B extends string> = A extends B
|
|
183
|
+
? false
|
|
184
|
+
: [BuildTuple<StringLength<A>, 0>, BuildTuple<StringLength<B>, 0>] extends infer R extends [readonly unknown[], readonly unknown[]]
|
|
185
|
+
? R[0] extends [...R[1], ...infer Remain extends readonly unknown[]]
|
|
186
|
+
? 0 extends Remain['length']
|
|
187
|
+
? SameLengthPositiveNumericStringGt<A, B>
|
|
188
|
+
: true
|
|
189
|
+
: false
|
|
190
|
+
: never;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
Returns a boolean for whether `A` represents a number greater than `B`, where `A` and `B` are both positive numeric characters.
|
|
194
|
+
|
|
195
|
+
@example
|
|
196
|
+
```
|
|
197
|
+
PositiveNumericCharacterGt<'5', '1'>;
|
|
198
|
+
//=> true
|
|
199
|
+
|
|
200
|
+
PositiveNumericCharacterGt<'1', '1'>;
|
|
201
|
+
//=> false
|
|
202
|
+
```
|
|
203
|
+
*/
|
|
204
|
+
type PositiveNumericCharacterGt<A extends string, B extends string> = NumericString extends `${infer HeadA}${A}${infer TailA}`
|
|
205
|
+
? NumericString extends `${infer HeadB}${B}${infer TailB}`
|
|
206
|
+
? HeadA extends `${HeadB}${infer _}${infer __}`
|
|
207
|
+
? true
|
|
208
|
+
: false
|
|
209
|
+
: never
|
|
210
|
+
: never;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type {GreaterThan} from '../greater-than';
|
|
2
|
+
import type {LessThan} from '../less-than';
|
|
3
|
+
import type {NegativeInfinity, PositiveInfinity} from '../numeric';
|
|
4
|
+
import type {UnknownArray} from '../unknown-array';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
Infer the length of the given tuple `<T>`.
|
|
8
|
+
|
|
9
|
+
Returns `never` if the given type is an non-fixed-length array like `Array<string>`.
|
|
10
|
+
|
|
11
|
+
@example
|
|
12
|
+
```
|
|
13
|
+
type Tuple = TupleLength<[string, number, boolean]>;
|
|
14
|
+
//=> 3
|
|
15
|
+
|
|
16
|
+
type Array = TupleLength<string[]>;
|
|
17
|
+
//=> never
|
|
18
|
+
|
|
19
|
+
// Supports union types.
|
|
20
|
+
type Union = TupleLength<[] | [1, 2, 3] | Array<number>>;
|
|
21
|
+
//=> 1 | 3
|
|
22
|
+
```
|
|
23
|
+
*/
|
|
24
|
+
export type TupleLength<T extends UnknownArray> =
|
|
25
|
+
// `extends unknown` is used to convert `T` (if `T` is a union type) to
|
|
26
|
+
// a [distributive conditionaltype](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types))
|
|
27
|
+
T extends unknown
|
|
28
|
+
? number extends T['length']
|
|
29
|
+
? never // Return never if the given type is an non-flexed-length array like `Array<string>`
|
|
30
|
+
: T['length']
|
|
31
|
+
: never; // Should never happen
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
Create a tuple type of the given length `<L>` and fill it with the given type `<Fill>`.
|
|
35
|
+
|
|
36
|
+
If `<Fill>` is not provided, it will default to `unknown`.
|
|
37
|
+
|
|
38
|
+
@link https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f
|
|
39
|
+
*/
|
|
40
|
+
export type BuildTuple<L extends number, Fill = unknown, T extends readonly unknown[] = []> = number extends L
|
|
41
|
+
? Fill[]
|
|
42
|
+
: L extends T['length']
|
|
43
|
+
? T
|
|
44
|
+
: BuildTuple<L, Fill, [...T, Fill]>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
Returns the maximum value from a tuple of integers.
|
|
48
|
+
|
|
49
|
+
Note:
|
|
50
|
+
- Float numbers are not supported.
|
|
51
|
+
|
|
52
|
+
@example
|
|
53
|
+
```
|
|
54
|
+
ArrayMax<[1, 2, 5, 3]>;
|
|
55
|
+
//=> 5
|
|
56
|
+
|
|
57
|
+
ArrayMax<[1, 2, 5, 3, 99, -1]>;
|
|
58
|
+
//=> 99
|
|
59
|
+
```
|
|
60
|
+
*/
|
|
61
|
+
export type TupleMax<A extends number[], Result extends number = NegativeInfinity> = number extends A[number]
|
|
62
|
+
? never :
|
|
63
|
+
A extends [infer F extends number, ...infer R extends number[]]
|
|
64
|
+
? GreaterThan<F, Result> extends true
|
|
65
|
+
? TupleMax<R, F>
|
|
66
|
+
: TupleMax<R, Result>
|
|
67
|
+
: Result;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
Returns the minimum value from a tuple of integers.
|
|
71
|
+
|
|
72
|
+
Note:
|
|
73
|
+
- Float numbers are not supported.
|
|
74
|
+
|
|
75
|
+
@example
|
|
76
|
+
```
|
|
77
|
+
ArrayMin<[1, 2, 5, 3]>;
|
|
78
|
+
//=> 1
|
|
79
|
+
|
|
80
|
+
ArrayMin<[1, 2, 5, 3, -5]>;
|
|
81
|
+
//=> -5
|
|
82
|
+
```
|
|
83
|
+
*/
|
|
84
|
+
export type TupleMin<A extends number[], Result extends number = PositiveInfinity> = number extends A[number]
|
|
85
|
+
? never
|
|
86
|
+
: A extends [infer F extends number, ...infer R extends number[]]
|
|
87
|
+
? LessThan<F, Result> extends true
|
|
88
|
+
? TupleMin<R, F>
|
|
89
|
+
: TupleMin<R, Result>
|
|
90
|
+
: Result;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type {IsAny} from '../is-any';
|
|
2
|
+
import type {IsNever} from '../is-never';
|
|
3
|
+
import type {Primitive} from '../primitive';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
7
|
+
*/
|
|
8
|
+
export type BuiltIns = Primitive | void | Date | RegExp;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
Matches non-recursive types.
|
|
12
|
+
*/
|
|
13
|
+
export type NonRecursiveType = BuiltIns | Function | (new (...arguments_: any[]) => unknown);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
Returns a boolean for whether the two given types extends the base type.
|
|
17
|
+
*/
|
|
18
|
+
export type IsBothExtends<BaseType, FirstType, SecondType> = FirstType extends BaseType
|
|
19
|
+
? SecondType extends BaseType
|
|
20
|
+
? true
|
|
21
|
+
: false
|
|
22
|
+
: false;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
Test if the given function has multiple call signatures.
|
|
26
|
+
|
|
27
|
+
Needed to handle the case of a single call signature with properties.
|
|
28
|
+
|
|
29
|
+
Multiple call signatures cannot currently be supported due to a TypeScript limitation.
|
|
30
|
+
@see https://github.com/microsoft/TypeScript/issues/29732
|
|
31
|
+
*/
|
|
32
|
+
export type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> =
|
|
33
|
+
T extends {(...arguments_: infer A): unknown; (...arguments_: infer B): unknown}
|
|
34
|
+
? B extends A
|
|
35
|
+
? A extends B
|
|
36
|
+
? false
|
|
37
|
+
: true
|
|
38
|
+
: true
|
|
39
|
+
: false;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
Returns a boolean for whether the given `boolean` is not `false`.
|
|
43
|
+
*/
|
|
44
|
+
export type IsNotFalse<T extends boolean> = [T] extends [false] ? false : true;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
Returns a boolean for whether the given type is primitive value or primitive type.
|
|
48
|
+
|
|
49
|
+
@example
|
|
50
|
+
```
|
|
51
|
+
IsPrimitive<'string'>
|
|
52
|
+
//=> true
|
|
53
|
+
|
|
54
|
+
IsPrimitive<string>
|
|
55
|
+
//=> true
|
|
56
|
+
|
|
57
|
+
IsPrimitive<Object>
|
|
58
|
+
//=> false
|
|
59
|
+
```
|
|
60
|
+
*/
|
|
61
|
+
export type IsPrimitive<T> = [T] extends [Primitive] ? true : false;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
Returns a boolean for whether A is false.
|
|
65
|
+
|
|
66
|
+
@example
|
|
67
|
+
```
|
|
68
|
+
Not<true>;
|
|
69
|
+
//=> false
|
|
70
|
+
|
|
71
|
+
Not<false>;
|
|
72
|
+
//=> true
|
|
73
|
+
```
|
|
74
|
+
*/
|
|
75
|
+
export type Not<A extends boolean> = A extends true
|
|
76
|
+
? false
|
|
77
|
+
: A extends false
|
|
78
|
+
? true
|
|
79
|
+
: never;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
Returns a boolean for whether the given type is a union type.
|
|
83
|
+
|
|
84
|
+
@example
|
|
85
|
+
```
|
|
86
|
+
type A = IsUnion<string | number>;
|
|
87
|
+
//=> true
|
|
88
|
+
|
|
89
|
+
type B = IsUnion<string>;
|
|
90
|
+
//=> false
|
|
91
|
+
```
|
|
92
|
+
*/
|
|
93
|
+
export type IsUnion<T> = InternalIsUnion<T>;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
The actual implementation of `IsUnion`.
|
|
97
|
+
*/
|
|
98
|
+
type InternalIsUnion<T, U = T> =
|
|
99
|
+
(
|
|
100
|
+
// @link https://ghaiklor.github.io/type-challenges-solutions/en/medium-isunion.html
|
|
101
|
+
IsNever<T> extends true
|
|
102
|
+
? false
|
|
103
|
+
: T extends any
|
|
104
|
+
? [U] extends [T]
|
|
105
|
+
? false
|
|
106
|
+
: true
|
|
107
|
+
: never
|
|
108
|
+
) extends infer Result
|
|
109
|
+
// In some cases `Result` will return `false | true` which is `boolean`,
|
|
110
|
+
// that means `T` has at least two types and it's a union type,
|
|
111
|
+
// so we will return `true` instead of `boolean`.
|
|
112
|
+
? boolean extends Result ? true
|
|
113
|
+
: Result
|
|
114
|
+
: never; // Should never happen
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
An if-else-like type that resolves depending on whether the given type is `any` or `never`.
|
|
118
|
+
|
|
119
|
+
@example
|
|
120
|
+
```
|
|
121
|
+
// When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
|
|
122
|
+
type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
123
|
+
//=> 'VALID'
|
|
124
|
+
|
|
125
|
+
// When `T` is `any` => Returns `IfAny` branch
|
|
126
|
+
type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
127
|
+
//=> 'IS_ANY'
|
|
128
|
+
|
|
129
|
+
// When `T` is `never` => Returns `IfNever` branch
|
|
130
|
+
type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
131
|
+
//=> 'IS_NEVER'
|
|
132
|
+
```
|
|
133
|
+
*/
|
|
134
|
+
export type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> =
|
|
135
|
+
IsAny<T> extends true
|
|
136
|
+
? IfAny
|
|
137
|
+
: IsNever<T> extends true
|
|
138
|
+
? IfNever
|
|
139
|
+
: IfNotAnyOrNever;
|