@flickfyi/flkr 0.0.141 → 0.0.146
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/node_modules/@flickfyi/attestation/.turbo/turbo-build.log +7 -7
- package/node_modules/@flickfyi/biscuit/.turbo/turbo-build.log +7 -7
- package/node_modules/@flickfyi/core/.oxlintrc.json +2 -1
- package/node_modules/@flickfyi/core/.turbo/turbo-build.log +502 -95
- package/node_modules/@flickfyi/core/README.md +58 -4
- package/node_modules/@flickfyi/core/dist/index.cjs +1 -1
- package/node_modules/@flickfyi/core/dist/index.js +35 -24
- package/node_modules/@flickfyi/core/dist/kowalski/calculations.d.ts +17 -0
- package/node_modules/@flickfyi/core/dist/kowalski/calculator.d.ts +13 -0
- package/node_modules/@flickfyi/core/dist/kowalski/catalog.cjs +1 -0
- package/node_modules/@flickfyi/core/dist/kowalski/catalog.d.cts +962 -0
- package/node_modules/@flickfyi/core/dist/kowalski/catalog.d.ts +962 -0
- package/node_modules/@flickfyi/core/dist/kowalski/catalog.js +639 -0
- package/node_modules/@flickfyi/core/dist/kowalski/clocks.d.ts +4 -0
- package/node_modules/@flickfyi/core/dist/kowalski/date-time.d.ts +22 -0
- package/node_modules/@flickfyi/core/dist/kowalski/details.d.ts +7 -0
- package/node_modules/@flickfyi/core/dist/kowalski/everyday.d.ts +8 -0
- package/node_modules/@flickfyi/core/dist/kowalski/format.d.ts +4 -0
- package/node_modules/@flickfyi/core/dist/kowalski/frame.d.ts +161 -0
- package/node_modules/@flickfyi/core/dist/kowalski/index.cjs +21 -0
- package/node_modules/@flickfyi/core/dist/kowalski/index.d.cts +8 -0
- package/node_modules/@flickfyi/core/dist/kowalski/index.d.ts +8 -0
- package/node_modules/@flickfyi/core/dist/kowalski/index.js +7496 -0
- package/node_modules/@flickfyi/core/dist/kowalski/productivity.d.ts +5 -0
- package/node_modules/@flickfyi/core/dist/kowalski/recipe.d.ts +8 -0
- package/node_modules/@flickfyi/core/dist/kowalski/tools.d.ts +7 -0
- package/node_modules/@flickfyi/core/dist/kowalski/use-clock.d.ts +6 -0
- package/node_modules/@flickfyi/core/dist/kowalski/use-configured-feature.d.ts +19 -0
- package/node_modules/@flickfyi/core/dist/kowalski/use-feature-store.d.ts +15 -0
- package/node_modules/@flickfyi/core/dist/kowalski.css +506 -0
- package/node_modules/@flickfyi/core/dist/molecules/field/field.d.ts +8 -0
- package/node_modules/@flickfyi/core/dist/molecules/index.cjs +1 -1
- package/node_modules/@flickfyi/core/dist/molecules/index.d.cts +3 -0
- package/node_modules/@flickfyi/core/dist/molecules/index.d.ts +3 -0
- package/node_modules/@flickfyi/core/dist/molecules/index.js +88 -27
- package/node_modules/@flickfyi/core/dist/molecules/segmented/segmented.d.ts +10 -0
- package/node_modules/@flickfyi/core/dist/molecules/stepper/stepper.d.ts +10 -0
- package/node_modules/@flickfyi/core/dist/quantum/use-store.d.ts +7 -1
- package/node_modules/@flickfyi/core/dist/themes.css +2 -0
- package/node_modules/@flickfyi/core/examples/kowalski/bill-split/bill-split.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/bill-split/bill-split.tsx +17 -0
- package/node_modules/@flickfyi/core/examples/kowalski/bookmark/bookmark.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/bookmark/bookmark.tsx +23 -0
- package/node_modules/@flickfyi/core/examples/kowalski/budget/budget.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/budget/budget.tsx +26 -0
- package/node_modules/@flickfyi/core/examples/kowalski/calculator/calculator.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/calculator/calculator.tsx +24 -0
- package/node_modules/@flickfyi/core/examples/kowalski/checklist/checklist.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/checklist/checklist.tsx +26 -0
- package/node_modules/@flickfyi/core/examples/kowalski/color-palette/color-palette.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/color-palette/color-palette.tsx +22 -0
- package/node_modules/@flickfyi/core/examples/kowalski/contact/contact.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/contact/contact.tsx +23 -0
- package/node_modules/@flickfyi/core/examples/kowalski/countdown/countdown.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/countdown/countdown.tsx +23 -0
- package/node_modules/@flickfyi/core/examples/kowalski/event/event.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/event/event.tsx +24 -0
- package/node_modules/@flickfyi/core/examples/kowalski/expense/expense.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/expense/expense.tsx +23 -0
- package/node_modules/@flickfyi/core/examples/kowalski/goal/goal.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/goal/goal.tsx +24 -0
- package/node_modules/@flickfyi/core/examples/kowalski/habit/habit.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/habit/habit.tsx +23 -0
- package/node_modules/@flickfyi/core/examples/kowalski/ledger/ledger.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/ledger/ledger.tsx +25 -0
- package/node_modules/@flickfyi/core/examples/kowalski/note/note.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/note/note.tsx +22 -0
- package/node_modules/@flickfyi/core/examples/kowalski/poll/poll.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/poll/poll.tsx +26 -0
- package/node_modules/@flickfyi/core/examples/kowalski/random-picker/random-picker.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/random-picker/random-picker.tsx +23 -0
- package/node_modules/@flickfyi/core/examples/kowalski/rating/rating.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/rating/rating.tsx +19 -0
- package/node_modules/@flickfyi/core/examples/kowalski/recipe/recipe.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/recipe/recipe.tsx +120 -0
- package/node_modules/@flickfyi/core/examples/kowalski/reminder/reminder.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/reminder/reminder.tsx +23 -0
- package/node_modules/@flickfyi/core/examples/kowalski/rotation/rotation.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/rotation/rotation.tsx +27 -0
- package/node_modules/@flickfyi/core/examples/kowalski/scoreboard/scoreboard.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/scoreboard/scoreboard.tsx +26 -0
- package/node_modules/@flickfyi/core/examples/kowalski/shopping-list/shopping-list.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/shopping-list/shopping-list.tsx +27 -0
- package/node_modules/@flickfyi/core/examples/kowalski/task-board/task-board.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/task-board/task-board.tsx +27 -0
- package/node_modules/@flickfyi/core/examples/kowalski/theme.ts +3 -0
- package/node_modules/@flickfyi/core/examples/kowalski/time-zone/time-zone.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/time-zone/time-zone.tsx +22 -0
- package/node_modules/@flickfyi/core/examples/kowalski/timer/timer.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/timer/timer.tsx +23 -0
- package/node_modules/@flickfyi/core/examples/kowalski/trip/trip.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/trip/trip.tsx +26 -0
- package/node_modules/@flickfyi/core/examples/kowalski/unit-converter/unit-converter.stories.tsx +15 -0
- package/node_modules/@flickfyi/core/examples/kowalski/unit-converter/unit-converter.tsx +24 -0
- package/node_modules/@flickfyi/core/examples/parrott/calculator/calculator.stories.tsx +3 -1
- package/node_modules/@flickfyi/core/examples/parrott/checklist/checklist.stories.tsx +3 -1
- package/node_modules/@flickfyi/core/examples/parrott/countdown/countdown.stories.tsx +3 -1
- package/node_modules/@flickfyi/core/examples/parrott/counter/counter.stories.tsx +1 -0
- package/node_modules/@flickfyi/core/examples/parrott/fortune/fortune.stories.tsx +3 -1
- package/node_modules/@flickfyi/core/examples/parrott/grid/grid.stories.tsx +3 -1
- package/node_modules/@flickfyi/core/examples/parrott/kale-smoothie/kale-smoothie.stories.tsx +1 -0
- package/node_modules/@flickfyi/core/examples/parrott/list/list.stories.tsx +3 -1
- package/node_modules/@flickfyi/core/examples/parrott/log/log.stories.tsx +3 -1
- package/node_modules/@flickfyi/core/examples/parrott/timed-task/timed-task.stories.tsx +3 -1
- package/node_modules/@flickfyi/core/examples/parrott/timer/timer.stories.tsx +3 -1
- package/node_modules/@flickfyi/core/fixtures/native/host/project.yml +3 -0
- package/node_modules/@flickfyi/core/fixtures/native/src/catalog-features.tsx +88 -0
- package/node_modules/@flickfyi/core/package.json +35 -5
- package/node_modules/@flickfyi/core/package.tsgo.json +19 -1
- package/node_modules/@flickfyi/core/scripts/vite-globals.d.ts +2 -0
- package/node_modules/@flickfyi/core/src/generated-types.d.ts +1 -0
- package/node_modules/@flickfyi/core/src/kowalski/README.md +9 -0
- package/node_modules/@flickfyi/core/src/kowalski/calculations.ts +106 -0
- package/node_modules/@flickfyi/core/src/kowalski/calculator.ts +243 -0
- package/node_modules/@flickfyi/core/src/kowalski/catalog.ts +787 -0
- package/node_modules/@flickfyi/core/src/kowalski/clocks.tsx +464 -0
- package/node_modules/@flickfyi/core/src/kowalski/date-time.tsx +469 -0
- package/node_modules/@flickfyi/core/src/kowalski/details.tsx +1387 -0
- package/node_modules/@flickfyi/core/src/kowalski/everyday.tsx +652 -0
- package/node_modules/@flickfyi/core/src/kowalski/format.ts +48 -0
- package/node_modules/@flickfyi/core/src/kowalski/frame.tsx +351 -0
- package/node_modules/@flickfyi/core/src/kowalski/index.ts +23 -0
- package/node_modules/@flickfyi/core/src/kowalski/productivity.tsx +575 -0
- package/node_modules/@flickfyi/core/src/kowalski/recipe.tsx +555 -0
- package/node_modules/@flickfyi/core/src/kowalski/stories/composition.stories.tsx +47 -0
- package/node_modules/@flickfyi/core/src/kowalski/stories/composition.tsx +100 -0
- package/node_modules/@flickfyi/core/src/kowalski/tools.tsx +1213 -0
- package/node_modules/@flickfyi/core/src/kowalski/use-clock.ts +19 -0
- package/node_modules/@flickfyi/core/src/kowalski/use-configured-feature.ts +85 -0
- package/node_modules/@flickfyi/core/src/kowalski/use-feature-store.ts +119 -0
- package/node_modules/@flickfyi/core/src/molecules/field/field.tsx +34 -0
- package/node_modules/@flickfyi/core/src/molecules/index.ts +3 -0
- package/node_modules/@flickfyi/core/src/molecules/segmented/segmented.tsx +48 -0
- package/node_modules/@flickfyi/core/src/molecules/stepper/stepper.tsx +54 -0
- package/node_modules/@flickfyi/core/src/quantum/use-store.ts +41 -16
- package/node_modules/@flickfyi/core/tests/fly.test.ts +34 -7
- package/node_modules/@flickfyi/core/tests/kowalski-calculations.test.ts +60 -0
- package/node_modules/@flickfyi/core/tests/kowalski-calculator.test.ts +142 -0
- package/node_modules/@flickfyi/core/tests/kowalski-contracts.test.ts +223 -0
- package/node_modules/@flickfyi/core/tests/kowalski-date-time.test.tsx +462 -0
- package/node_modules/@flickfyi/core/tests/kowalski-features.test.tsx +2158 -0
- package/node_modules/@flickfyi/core/tests/kowalski-store.test.tsx +514 -0
- package/node_modules/@flickfyi/core/tests/preview-build.test.ts +1 -1
- package/node_modules/@flickfyi/core/tests/quantum-use-store.test.ts +53 -1
- package/node_modules/@flickfyi/core/tests/verify-tsgo-assets.test.ts +1 -1
- package/node_modules/@flickfyi/core/tsconfig.vite-dts.json +2 -1
- package/node_modules/@flickfyi/core/tsgo.bun.lock +111 -9
- package/node_modules/@flickfyi/core/tsgo.package.json +21 -3
- package/node_modules/@flickfyi/core/vite.config.ts +9 -5
- package/node_modules/@flickfyi/core/vitest.config.ts +1 -1
- package/node_modules/@flickfyi/http-message-sig/.turbo/turbo-build.log +7 -7
- package/node_modules/@flickfyi/identity/.turbo/turbo-build.log +8 -9
- package/node_modules/@flickfyi/lens/.turbo/turbo-build.log +7 -7
- package/node_modules/@flickfyi/photon/.turbo/turbo-build.log +10 -4
- package/node_modules/@flickfyi/photon/Sources/Photon/Components/Button.swift +29 -2
- package/node_modules/@flickfyi/photon/Sources/PhotonVersion/Resources/photon-version.json +1 -1
- package/node_modules/@flickfyi/photon/Tests/PhotonTests/Components/ButtonHostTests.swift +26 -0
- package/node_modules/@flickfyi/photon/Tests/PhotonTests/Fixtures/StyleX/catalog-features.styles.json +1 -0
- package/node_modules/@flickfyi/photon/Tests/PhotonTests/Fixtures/StyleX/catalog-native.styles.json +1 -1
- package/node_modules/@flickfyi/photon/Tests/PhotonTests/Fixtures/StyleX/catalog-scale.styles.json +1 -1
- package/node_modules/@flickfyi/photon/Tests/PhotonTests/Fixtures/StyleX/catalog-theme.styles.json +1 -1
- package/node_modules/@flickfyi/photon/Tests/PhotonTests/Fixtures/StyleX/catalog-typography.styles.json +1 -1
- package/node_modules/@flickfyi/photon/Tests/PhotonTests/Fixtures/StyleX/stylex-calculator.styles.json +1 -1
- package/node_modules/@flickfyi/photon/dist/globals.d.ts +5 -0
- package/node_modules/@flickfyi/photon/dist/version.cjs +1 -1
- package/node_modules/@flickfyi/photon/dist/version.js +1 -1
- package/node_modules/@flickfyi/photon/generated/react-swiftui.d.ts +1 -0
- package/node_modules/@flickfyi/photon/package.json +1 -1
- package/node_modules/@flickfyi/photon/src/globals.d.ts +5 -0
- package/node_modules/@flickfyi/rwsdk-extensions/.turbo/turbo-build.log +7 -7
- package/node_modules/@formatjs/fast-memoize/LICENSE.md +9 -0
- package/node_modules/@formatjs/fast-memoize/README.md +3 -0
- package/node_modules/@formatjs/fast-memoize/index.d.ts +35 -0
- package/node_modules/@formatjs/fast-memoize/index.js +69 -0
- package/node_modules/@formatjs/fast-memoize/index.js.map +1 -0
- package/node_modules/@formatjs/fast-memoize/package.json +25 -0
- package/node_modules/@formatjs/icu-messageformat-parser/LICENSE.md +9 -0
- package/node_modules/@formatjs/icu-messageformat-parser/README.md +38 -0
- package/node_modules/@formatjs/icu-messageformat-parser/index.d.ts +393 -0
- package/node_modules/@formatjs/icu-messageformat-parser/index.js +2187 -0
- package/node_modules/@formatjs/icu-messageformat-parser/index.js.map +1 -0
- package/node_modules/@formatjs/icu-messageformat-parser/manipulator.d.ts +175 -0
- package/node_modules/@formatjs/icu-messageformat-parser/manipulator.js +209 -0
- package/node_modules/@formatjs/icu-messageformat-parser/manipulator.js.map +1 -0
- package/node_modules/@formatjs/icu-messageformat-parser/no-parser.d.ts +183 -0
- package/node_modules/@formatjs/icu-messageformat-parser/no-parser.js +162 -0
- package/node_modules/@formatjs/icu-messageformat-parser/no-parser.js.map +1 -0
- package/node_modules/@formatjs/icu-messageformat-parser/package.json +21 -0
- package/node_modules/@formatjs/icu-messageformat-parser/printer.d.ts +154 -0
- package/node_modules/@formatjs/icu-messageformat-parser/printer.js +224 -0
- package/node_modules/@formatjs/icu-messageformat-parser/printer.js.map +1 -0
- package/node_modules/@formatjs/icu-skeleton-parser/LICENSE.md +9 -0
- package/node_modules/@formatjs/icu-skeleton-parser/README.md +1 -0
- package/node_modules/@formatjs/icu-skeleton-parser/index.d.ts +67 -0
- package/node_modules/@formatjs/icu-skeleton-parser/index.js +380 -0
- package/node_modules/@formatjs/icu-skeleton-parser/index.js.map +1 -0
- package/node_modules/@formatjs/icu-skeleton-parser/package.json +15 -0
- package/node_modules/@formatjs/intl/LICENSE.md +9 -0
- package/node_modules/@formatjs/intl/README.md +3 -0
- package/node_modules/@formatjs/intl/index.d.ts +499 -0
- package/node_modules/@formatjs/intl/index.js +595 -0
- package/node_modules/@formatjs/intl/index.js.map +1 -0
- package/node_modules/@formatjs/intl/package.json +37 -0
- package/node_modules/decimal.js/LICENCE.md +23 -0
- package/node_modules/decimal.js/README.md +246 -0
- package/node_modules/decimal.js/decimal.d.ts +301 -0
- package/node_modules/decimal.js/decimal.js +4951 -0
- package/node_modules/decimal.js/decimal.mjs +4914 -0
- package/node_modules/decimal.js/package.json +55 -0
- package/node_modules/format-quantity/LICENSE +21 -0
- package/node_modules/format-quantity/README.md +181 -0
- package/node_modules/format-quantity/dist/cjs/format-quantity.cjs.development.d.ts +131 -0
- package/node_modules/format-quantity/dist/cjs/format-quantity.cjs.development.js +214 -0
- package/node_modules/format-quantity/dist/cjs/format-quantity.cjs.development.js.map +1 -0
- package/node_modules/format-quantity/dist/cjs/format-quantity.cjs.production.d.ts +131 -0
- package/node_modules/format-quantity/dist/cjs/format-quantity.cjs.production.js +2 -0
- package/node_modules/format-quantity/dist/cjs/format-quantity.cjs.production.js.map +1 -0
- package/node_modules/format-quantity/dist/cjs/index.d.ts +1 -0
- package/node_modules/format-quantity/dist/cjs/index.js +6 -0
- package/node_modules/format-quantity/dist/format-quantity.d.mts +131 -0
- package/node_modules/format-quantity/dist/format-quantity.legacy-esm.d.ts +131 -0
- package/node_modules/format-quantity/dist/format-quantity.legacy-esm.js +268 -0
- package/node_modules/format-quantity/dist/format-quantity.legacy-esm.js.map +1 -0
- package/node_modules/format-quantity/dist/format-quantity.mjs +208 -0
- package/node_modules/format-quantity/dist/format-quantity.mjs.map +1 -0
- package/node_modules/format-quantity/dist/format-quantity.production.d.mts +131 -0
- package/node_modules/format-quantity/dist/format-quantity.production.mjs +2 -0
- package/node_modules/format-quantity/dist/format-quantity.production.mjs.map +1 -0
- package/node_modules/format-quantity/dist/format-quantity.umd.min.js +3 -0
- package/node_modules/format-quantity/dist/format-quantity.umd.min.js.map +1 -0
- package/node_modules/format-quantity/package.json +81 -0
- package/node_modules/intl-messageformat/LICENSE.md +33 -0
- package/node_modules/intl-messageformat/README.md +3 -0
- package/node_modules/intl-messageformat/index.d.ts +177 -0
- package/node_modules/intl-messageformat/index.js +327 -0
- package/node_modules/intl-messageformat/index.js.map +1 -0
- package/node_modules/intl-messageformat/intl-messageformat.iife.js +2819 -0
- package/node_modules/intl-messageformat/package.json +40 -0
- package/node_modules/numeric-quantity/LICENSE +21 -0
- package/node_modules/numeric-quantity/README.md +306 -0
- package/node_modules/numeric-quantity/dist/cjs/index.d.ts +1 -0
- package/node_modules/numeric-quantity/dist/cjs/index.js +6 -0
- package/node_modules/numeric-quantity/dist/cjs/numeric-quantity.cjs.development.d.ts +293 -0
- package/node_modules/numeric-quantity/dist/cjs/numeric-quantity.cjs.development.js +579 -0
- package/node_modules/numeric-quantity/dist/cjs/numeric-quantity.cjs.development.js.map +1 -0
- package/node_modules/numeric-quantity/dist/cjs/numeric-quantity.cjs.production.d.ts +293 -0
- package/node_modules/numeric-quantity/dist/cjs/numeric-quantity.cjs.production.js +2 -0
- package/node_modules/numeric-quantity/dist/cjs/numeric-quantity.cjs.production.js.map +1 -0
- package/node_modules/numeric-quantity/dist/numeric-quantity.d.mts +293 -0
- package/node_modules/numeric-quantity/dist/numeric-quantity.iife.umd.min.js +2 -0
- package/node_modules/numeric-quantity/dist/numeric-quantity.iife.umd.min.js.map +1 -0
- package/node_modules/numeric-quantity/dist/numeric-quantity.legacy-esm.d.ts +293 -0
- package/node_modules/numeric-quantity/dist/numeric-quantity.legacy-esm.js +622 -0
- package/node_modules/numeric-quantity/dist/numeric-quantity.legacy-esm.js.map +1 -0
- package/node_modules/numeric-quantity/dist/numeric-quantity.mjs +564 -0
- package/node_modules/numeric-quantity/dist/numeric-quantity.mjs.map +1 -0
- package/node_modules/numeric-quantity/dist/numeric-quantity.production.d.mts +293 -0
- package/node_modules/numeric-quantity/dist/numeric-quantity.production.mjs +2 -0
- package/node_modules/numeric-quantity/dist/numeric-quantity.production.mjs.map +1 -0
- package/node_modules/numeric-quantity/package.json +72 -0
- package/node_modules/validator/LICENSE +20 -0
- package/node_modules/validator/README.md +269 -0
- package/node_modules/validator/es/index.js +218 -0
- package/node_modules/validator/es/lib/alpha.js +151 -0
- package/node_modules/validator/es/lib/blacklist.js +5 -0
- package/node_modules/validator/es/lib/contains.js +15 -0
- package/node_modules/validator/es/lib/equals.js +5 -0
- package/node_modules/validator/es/lib/escape.js +5 -0
- package/node_modules/validator/es/lib/isAbaRouting.js +15 -0
- package/node_modules/validator/es/lib/isAfter.js +10 -0
- package/node_modules/validator/es/lib/isAlpha.js +23 -0
- package/node_modules/validator/es/lib/isAlphanumeric.js +23 -0
- package/node_modules/validator/es/lib/isAscii.js +10 -0
- package/node_modules/validator/es/lib/isBIC.js +16 -0
- package/node_modules/validator/es/lib/isBase32.js +15 -0
- package/node_modules/validator/es/lib/isBase58.js +8 -0
- package/node_modules/validator/es/lib/isBase64.js +23 -0
- package/node_modules/validator/es/lib/isBefore.js +10 -0
- package/node_modules/validator/es/lib/isBoolean.js +15 -0
- package/node_modules/validator/es/lib/isBtcAddress.js +7 -0
- package/node_modules/validator/es/lib/isByteLength.js +19 -0
- package/node_modules/validator/es/lib/isCreditCard.js +43 -0
- package/node_modules/validator/es/lib/isCurrency.js +74 -0
- package/node_modules/validator/es/lib/isDataURI.js +31 -0
- package/node_modules/validator/es/lib/isDate.js +93 -0
- package/node_modules/validator/es/lib/isDecimal.js +22 -0
- package/node_modules/validator/es/lib/isDivisibleBy.js +6 -0
- package/node_modules/validator/es/lib/isEAN.js +70 -0
- package/node_modules/validator/es/lib/isEmail.js +165 -0
- package/node_modules/validator/es/lib/isEmpty.js +10 -0
- package/node_modules/validator/es/lib/isEthereumAddress.js +6 -0
- package/node_modules/validator/es/lib/isFQDN.js +67 -0
- package/node_modules/validator/es/lib/isFloat.js +14 -0
- package/node_modules/validator/es/lib/isFullWidth.js +6 -0
- package/node_modules/validator/es/lib/isHSL.js +13 -0
- package/node_modules/validator/es/lib/isHalfWidth.js +6 -0
- package/node_modules/validator/es/lib/isHash.js +21 -0
- package/node_modules/validator/es/lib/isHexColor.js +13 -0
- package/node_modules/validator/es/lib/isHexadecimal.js +6 -0
- package/node_modules/validator/es/lib/isIBAN.js +171 -0
- package/node_modules/validator/es/lib/isIMEI.js +40 -0
- package/node_modules/validator/es/lib/isIP.js +58 -0
- package/node_modules/validator/es/lib/isIPRange.js +41 -0
- package/node_modules/validator/es/lib/isISBN.js +47 -0
- package/node_modules/validator/es/lib/isISIN.js +55 -0
- package/node_modules/validator/es/lib/isISO15924.js +9 -0
- package/node_modules/validator/es/lib/isISO31661Alpha2.js +21 -0
- package/node_modules/validator/es/lib/isISO31661Alpha3.js +20 -0
- package/node_modules/validator/es/lib/isISO31661Numeric.js +8 -0
- package/node_modules/validator/es/lib/isISO4217.js +9 -0
- package/node_modules/validator/es/lib/isISO6346.js +28 -0
- package/node_modules/validator/es/lib/isISO6391.js +6 -0
- package/node_modules/validator/es/lib/isISO8601.js +42 -0
- package/node_modules/validator/es/lib/isISRC.js +8 -0
- package/node_modules/validator/es/lib/isISSN.js +19 -0
- package/node_modules/validator/es/lib/isIdentityCard.js +407 -0
- package/node_modules/validator/es/lib/isIn.js +23 -0
- package/node_modules/validator/es/lib/isInt.js +19 -0
- package/node_modules/validator/es/lib/isJSON.js +26 -0
- package/node_modules/validator/es/lib/isJWT.js +15 -0
- package/node_modules/validator/es/lib/isLatLong.js +21 -0
- package/node_modules/validator/es/lib/isLength.js +27 -0
- package/node_modules/validator/es/lib/isLicensePlate.js +58 -0
- package/node_modules/validator/es/lib/isLocale.js +107 -0
- package/node_modules/validator/es/lib/isLowercase.js +5 -0
- package/node_modules/validator/es/lib/isLuhnNumber.js +25 -0
- package/node_modules/validator/es/lib/isMACAddress.js +36 -0
- package/node_modules/validator/es/lib/isMD5.js +6 -0
- package/node_modules/validator/es/lib/isMagnetURI.js +9 -0
- package/node_modules/validator/es/lib/isMailtoURI.js +75 -0
- package/node_modules/validator/es/lib/isMimeType.js +40 -0
- package/node_modules/validator/es/lib/isMobilePhone.js +212 -0
- package/node_modules/validator/es/lib/isMongoId.js +6 -0
- package/node_modules/validator/es/lib/isMultibyte.js +10 -0
- package/node_modules/validator/es/lib/isNumeric.js +10 -0
- package/node_modules/validator/es/lib/isOctal.js +6 -0
- package/node_modules/validator/es/lib/isPassportNumber.js +145 -0
- package/node_modules/validator/es/lib/isPort.js +8 -0
- package/node_modules/validator/es/lib/isPostalCode.js +100 -0
- package/node_modules/validator/es/lib/isRFC3339.js +21 -0
- package/node_modules/validator/es/lib/isRgbColor.js +34 -0
- package/node_modules/validator/es/lib/isSemVer.js +14 -0
- package/node_modules/validator/es/lib/isSlug.js +6 -0
- package/node_modules/validator/es/lib/isStrongPassword.js +90 -0
- package/node_modules/validator/es/lib/isSurrogatePair.js +6 -0
- package/node_modules/validator/es/lib/isTaxID.js +1407 -0
- package/node_modules/validator/es/lib/isTime.js +22 -0
- package/node_modules/validator/es/lib/isULID.js +5 -0
- package/node_modules/validator/es/lib/isURL.js +241 -0
- package/node_modules/validator/es/lib/isUUID.js +23 -0
- package/node_modules/validator/es/lib/isUppercase.js +5 -0
- package/node_modules/validator/es/lib/isVAT.js +264 -0
- package/node_modules/validator/es/lib/isVariableWidth.js +7 -0
- package/node_modules/validator/es/lib/isWhitelisted.js +10 -0
- package/node_modules/validator/es/lib/ltrim.js +7 -0
- package/node_modules/validator/es/lib/matches.js +8 -0
- package/node_modules/validator/es/lib/normalizeEmail.js +131 -0
- package/node_modules/validator/es/lib/rtrim.js +15 -0
- package/node_modules/validator/es/lib/stripLow.js +7 -0
- package/node_modules/validator/es/lib/toBoolean.js +8 -0
- package/node_modules/validator/es/lib/toDate.js +6 -0
- package/node_modules/validator/es/lib/toFloat.js +5 -0
- package/node_modules/validator/es/lib/toInt.js +5 -0
- package/node_modules/validator/es/lib/trim.js +5 -0
- package/node_modules/validator/es/lib/unescape.js +8 -0
- package/node_modules/validator/es/lib/util/algorithms.js +79 -0
- package/node_modules/validator/es/lib/util/assertString.js +4 -0
- package/node_modules/validator/es/lib/util/checkHost.js +12 -0
- package/node_modules/validator/es/lib/util/includesArray.js +6 -0
- package/node_modules/validator/es/lib/util/includesString.js +4 -0
- package/node_modules/validator/es/lib/util/merge.js +14 -0
- package/node_modules/validator/es/lib/util/multilineRegex.js +12 -0
- package/node_modules/validator/es/lib/util/nullUndefinedCheck.js +3 -0
- package/node_modules/validator/es/lib/util/toString.js +13 -0
- package/node_modules/validator/es/lib/util/typeOf.js +10 -0
- package/node_modules/validator/es/lib/whitelist.js +5 -0
- package/node_modules/validator/index.js +229 -0
- package/node_modules/validator/lib/alpha.js +157 -0
- package/node_modules/validator/lib/blacklist.js +14 -0
- package/node_modules/validator/lib/contains.js +24 -0
- package/node_modules/validator/lib/equals.js +14 -0
- package/node_modules/validator/lib/escape.js +14 -0
- package/node_modules/validator/lib/isAbaRouting.js +23 -0
- package/node_modules/validator/lib/isAfter.js +19 -0
- package/node_modules/validator/lib/isAlpha.js +31 -0
- package/node_modules/validator/lib/isAlphanumeric.js +31 -0
- package/node_modules/validator/lib/isAscii.js +18 -0
- package/node_modules/validator/lib/isBIC.js +24 -0
- package/node_modules/validator/lib/isBase32.js +24 -0
- package/node_modules/validator/lib/isBase58.js +16 -0
- package/node_modules/validator/lib/isBase64.js +32 -0
- package/node_modules/validator/lib/isBefore.js +19 -0
- package/node_modules/validator/lib/isBoolean.js +24 -0
- package/node_modules/validator/lib/isBtcAddress.js +16 -0
- package/node_modules/validator/lib/isByteLength.js +27 -0
- package/node_modules/validator/lib/isCreditCard.js +52 -0
- package/node_modules/validator/lib/isCurrency.js +83 -0
- package/node_modules/validator/lib/isDataURI.js +40 -0
- package/node_modules/validator/lib/isDate.js +102 -0
- package/node_modules/validator/lib/isDecimal.js +31 -0
- package/node_modules/validator/lib/isDivisibleBy.js +15 -0
- package/node_modules/validator/lib/isEAN.js +78 -0
- package/node_modules/validator/lib/isEmail.js +174 -0
- package/node_modules/validator/lib/isEmpty.js +19 -0
- package/node_modules/validator/lib/isEthereumAddress.js +15 -0
- package/node_modules/validator/lib/isFQDN.js +76 -0
- package/node_modules/validator/lib/isFloat.js +22 -0
- package/node_modules/validator/lib/isFullWidth.js +14 -0
- package/node_modules/validator/lib/isHSL.js +22 -0
- package/node_modules/validator/lib/isHalfWidth.js +14 -0
- package/node_modules/validator/lib/isHash.js +30 -0
- package/node_modules/validator/lib/isHexColor.js +22 -0
- package/node_modules/validator/lib/isHexadecimal.js +15 -0
- package/node_modules/validator/lib/isIBAN.js +178 -0
- package/node_modules/validator/lib/isIMEI.js +49 -0
- package/node_modules/validator/lib/isIP.js +67 -0
- package/node_modules/validator/lib/isIPRange.js +50 -0
- package/node_modules/validator/lib/isISBN.js +56 -0
- package/node_modules/validator/lib/isISIN.js +64 -0
- package/node_modules/validator/lib/isISO15924.js +16 -0
- package/node_modules/validator/lib/isISO31661Alpha2.js +28 -0
- package/node_modules/validator/lib/isISO31661Alpha3.js +28 -0
- package/node_modules/validator/lib/isISO31661Numeric.js +16 -0
- package/node_modules/validator/lib/isISO4217.js +16 -0
- package/node_modules/validator/lib/isISO6346.js +35 -0
- package/node_modules/validator/lib/isISO6391.js +15 -0
- package/node_modules/validator/lib/isISO8601.js +50 -0
- package/node_modules/validator/lib/isISRC.js +16 -0
- package/node_modules/validator/lib/isISSN.js +28 -0
- package/node_modules/validator/lib/isIdentityCard.js +416 -0
- package/node_modules/validator/lib/isIn.js +32 -0
- package/node_modules/validator/lib/isInt.js +28 -0
- package/node_modules/validator/lib/isJSON.js +35 -0
- package/node_modules/validator/lib/isJWT.js +24 -0
- package/node_modules/validator/lib/isLatLong.js +30 -0
- package/node_modules/validator/lib/isLength.js +35 -0
- package/node_modules/validator/lib/isLicensePlate.js +67 -0
- package/node_modules/validator/lib/isLocale.js +115 -0
- package/node_modules/validator/lib/isLowercase.js +14 -0
- package/node_modules/validator/lib/isLuhnNumber.js +34 -0
- package/node_modules/validator/lib/isMACAddress.js +45 -0
- package/node_modules/validator/lib/isMD5.js +15 -0
- package/node_modules/validator/lib/isMagnetURI.js +18 -0
- package/node_modules/validator/lib/isMailtoURI.js +84 -0
- package/node_modules/validator/lib/isMimeType.js +48 -0
- package/node_modules/validator/lib/isMobilePhone.js +219 -0
- package/node_modules/validator/lib/isMongoId.js +15 -0
- package/node_modules/validator/lib/isMultibyte.js +18 -0
- package/node_modules/validator/lib/isNumeric.js +19 -0
- package/node_modules/validator/lib/isOctal.js +15 -0
- package/node_modules/validator/lib/isPassportNumber.js +152 -0
- package/node_modules/validator/lib/isPort.js +17 -0
- package/node_modules/validator/lib/isPostalCode.js +107 -0
- package/node_modules/validator/lib/isRFC3339.js +29 -0
- package/node_modules/validator/lib/isRgbColor.js +42 -0
- package/node_modules/validator/lib/isSemVer.js +22 -0
- package/node_modules/validator/lib/isSlug.js +15 -0
- package/node_modules/validator/lib/isStrongPassword.js +99 -0
- package/node_modules/validator/lib/isSurrogatePair.js +15 -0
- package/node_modules/validator/lib/isTaxID.js +1417 -0
- package/node_modules/validator/lib/isTime.js +31 -0
- package/node_modules/validator/lib/isULID.js +14 -0
- package/node_modules/validator/lib/isURL.js +249 -0
- package/node_modules/validator/lib/isUUID.js +32 -0
- package/node_modules/validator/lib/isUppercase.js +14 -0
- package/node_modules/validator/lib/isVAT.js +274 -0
- package/node_modules/validator/lib/isVariableWidth.js +16 -0
- package/node_modules/validator/lib/isWhitelisted.js +19 -0
- package/node_modules/validator/lib/ltrim.js +16 -0
- package/node_modules/validator/lib/matches.js +17 -0
- package/node_modules/validator/lib/normalizeEmail.js +140 -0
- package/node_modules/validator/lib/rtrim.js +24 -0
- package/node_modules/validator/lib/stripLow.js +16 -0
- package/node_modules/validator/lib/toBoolean.js +17 -0
- package/node_modules/validator/lib/toDate.js +15 -0
- package/node_modules/validator/lib/toFloat.js +14 -0
- package/node_modules/validator/lib/toInt.js +14 -0
- package/node_modules/validator/lib/trim.js +14 -0
- package/node_modules/validator/lib/unescape.js +17 -0
- package/node_modules/validator/lib/util/algorithms.js +88 -0
- package/node_modules/validator/lib/util/assertString.js +12 -0
- package/node_modules/validator/lib/util/checkHost.js +20 -0
- package/node_modules/validator/lib/util/includesArray.js +14 -0
- package/node_modules/validator/lib/util/includesString.js +12 -0
- package/node_modules/validator/lib/util/merge.js +22 -0
- package/node_modules/validator/lib/util/multilineRegex.js +20 -0
- package/node_modules/validator/lib/util/nullUndefinedCheck.js +11 -0
- package/node_modules/validator/lib/util/toString.js +21 -0
- package/node_modules/validator/lib/util/typeOf.js +18 -0
- package/node_modules/validator/lib/whitelist.js +14 -0
- package/node_modules/validator/package.json +76 -0
- package/node_modules/validator/validator.js +5808 -0
- package/node_modules/validator/validator.min.js +23 -0
- package/package.json +3 -3
|
@@ -0,0 +1,622 @@
|
|
|
1
|
+
//#region src/constants.ts
|
|
2
|
+
/**
|
|
3
|
+
* Unicode decimal digit block start code points.
|
|
4
|
+
* Each block contains 10 contiguous digits (0-9).
|
|
5
|
+
* This list covers all \p{Nd} (Decimal_Number) blocks through Unicode 17.0.
|
|
6
|
+
* The drift test in index.test.ts validates completeness against the JS engine.
|
|
7
|
+
*/
|
|
8
|
+
const decimalDigitBlockStarts = [
|
|
9
|
+
48,
|
|
10
|
+
1632,
|
|
11
|
+
1776,
|
|
12
|
+
1984,
|
|
13
|
+
2406,
|
|
14
|
+
2534,
|
|
15
|
+
2662,
|
|
16
|
+
2790,
|
|
17
|
+
2918,
|
|
18
|
+
3046,
|
|
19
|
+
3174,
|
|
20
|
+
3302,
|
|
21
|
+
3430,
|
|
22
|
+
3558,
|
|
23
|
+
3664,
|
|
24
|
+
3792,
|
|
25
|
+
3872,
|
|
26
|
+
4160,
|
|
27
|
+
4240,
|
|
28
|
+
6112,
|
|
29
|
+
6160,
|
|
30
|
+
6470,
|
|
31
|
+
6608,
|
|
32
|
+
6784,
|
|
33
|
+
6800,
|
|
34
|
+
6992,
|
|
35
|
+
7088,
|
|
36
|
+
7232,
|
|
37
|
+
7248,
|
|
38
|
+
42528,
|
|
39
|
+
43216,
|
|
40
|
+
43264,
|
|
41
|
+
43472,
|
|
42
|
+
43504,
|
|
43
|
+
43600,
|
|
44
|
+
44016,
|
|
45
|
+
65296,
|
|
46
|
+
66720,
|
|
47
|
+
68912,
|
|
48
|
+
68928,
|
|
49
|
+
69734,
|
|
50
|
+
69872,
|
|
51
|
+
69942,
|
|
52
|
+
70096,
|
|
53
|
+
70384,
|
|
54
|
+
70736,
|
|
55
|
+
70864,
|
|
56
|
+
71248,
|
|
57
|
+
71360,
|
|
58
|
+
71376,
|
|
59
|
+
71386,
|
|
60
|
+
71472,
|
|
61
|
+
71904,
|
|
62
|
+
72016,
|
|
63
|
+
72688,
|
|
64
|
+
72784,
|
|
65
|
+
73040,
|
|
66
|
+
73120,
|
|
67
|
+
73184,
|
|
68
|
+
73552,
|
|
69
|
+
90416,
|
|
70
|
+
92768,
|
|
71
|
+
92864,
|
|
72
|
+
93008,
|
|
73
|
+
93552,
|
|
74
|
+
118e3,
|
|
75
|
+
120782,
|
|
76
|
+
120792,
|
|
77
|
+
120802,
|
|
78
|
+
120812,
|
|
79
|
+
120822,
|
|
80
|
+
123200,
|
|
81
|
+
123632,
|
|
82
|
+
124144,
|
|
83
|
+
124401,
|
|
84
|
+
125264,
|
|
85
|
+
130032
|
|
86
|
+
];
|
|
87
|
+
const unicodeDecimalDigitRegex = new RegExp("\\p{Nd}", "gu");
|
|
88
|
+
/**
|
|
89
|
+
* Normalizes non-ASCII decimal digits to ASCII digits.
|
|
90
|
+
* Converts characters from Unicode decimal digit blocks (e.g., Arabic-Indic,
|
|
91
|
+
* Devanagari, Bengali) to their ASCII equivalents (0-9).
|
|
92
|
+
*
|
|
93
|
+
* All current Unicode \p{Nd} blocks are included in decimalDigitBlockStarts.
|
|
94
|
+
*/
|
|
95
|
+
const normalizeDigits = (str) => str.replace(unicodeDecimalDigitRegex, (ch) => {
|
|
96
|
+
const cp = ch.codePointAt(0);
|
|
97
|
+
if (cp <= 57) return ch;
|
|
98
|
+
let lo = 0;
|
|
99
|
+
let hi = decimalDigitBlockStarts.length - 1;
|
|
100
|
+
while (lo < hi) {
|
|
101
|
+
const mid = lo + hi + 1 >>> 1;
|
|
102
|
+
if (decimalDigitBlockStarts[mid] <= cp) lo = mid;
|
|
103
|
+
else hi = mid - 1;
|
|
104
|
+
}
|
|
105
|
+
return String(cp - decimalDigitBlockStarts[lo]);
|
|
106
|
+
});
|
|
107
|
+
/**
|
|
108
|
+
* Map of Unicode superscript and subscript digit code points to ASCII digits.
|
|
109
|
+
*/
|
|
110
|
+
const superSubDigitToAsciiMap = {
|
|
111
|
+
"⁰": "0",
|
|
112
|
+
"¹": "1",
|
|
113
|
+
"²": "2",
|
|
114
|
+
"³": "3",
|
|
115
|
+
"⁴": "4",
|
|
116
|
+
"⁵": "5",
|
|
117
|
+
"⁶": "6",
|
|
118
|
+
"⁷": "7",
|
|
119
|
+
"⁸": "8",
|
|
120
|
+
"⁹": "9",
|
|
121
|
+
"₀": "0",
|
|
122
|
+
"₁": "1",
|
|
123
|
+
"₂": "2",
|
|
124
|
+
"₃": "3",
|
|
125
|
+
"₄": "4",
|
|
126
|
+
"₅": "5",
|
|
127
|
+
"₆": "6",
|
|
128
|
+
"₇": "7",
|
|
129
|
+
"₈": "8",
|
|
130
|
+
"₉": "9"
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Captures Unicode superscript and subscript digits.
|
|
134
|
+
*/
|
|
135
|
+
const superSubDigitsRegex = /[⁰¹²³⁴⁵⁶⁷⁸⁹₀₁₂₃₄₅₆₇₈₉]/g;
|
|
136
|
+
/**
|
|
137
|
+
* Map of Unicode fraction code points to their ASCII equivalents.
|
|
138
|
+
*/
|
|
139
|
+
const vulgarFractionToAsciiMap = {
|
|
140
|
+
"¼": "1/4",
|
|
141
|
+
"½": "1/2",
|
|
142
|
+
"¾": "3/4",
|
|
143
|
+
"⅐": "1/7",
|
|
144
|
+
"⅑": "1/9",
|
|
145
|
+
"⅒": "1/10",
|
|
146
|
+
"⅓": "1/3",
|
|
147
|
+
"⅔": "2/3",
|
|
148
|
+
"⅕": "1/5",
|
|
149
|
+
"⅖": "2/5",
|
|
150
|
+
"⅗": "3/5",
|
|
151
|
+
"⅘": "4/5",
|
|
152
|
+
"⅙": "1/6",
|
|
153
|
+
"⅚": "5/6",
|
|
154
|
+
"⅛": "1/8",
|
|
155
|
+
"⅜": "3/8",
|
|
156
|
+
"⅝": "5/8",
|
|
157
|
+
"⅞": "7/8",
|
|
158
|
+
"⅟": "1/"
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Captures the individual elements of a numeric string. Commas and underscores are allowed
|
|
162
|
+
* as separators, as long as they appear between digits and are not consecutive.
|
|
163
|
+
*
|
|
164
|
+
* Capture groups:
|
|
165
|
+
*
|
|
166
|
+
* | # | Description | Example(s) |
|
|
167
|
+
* | --- | -------------------------------------------------- | ----------------------------------------------------------------------- |
|
|
168
|
+
* | `0` | entire match | `"2 1/3"` from `"2 1/3"` |
|
|
169
|
+
* | `1` | sign (`-` or `+`) | `"-"` from `"-2 1/3"` |
|
|
170
|
+
* | `2` | whole number or numerator | `"2"` from `"2 1/3"`; `"1"` from `"1/3"` |
|
|
171
|
+
* | `3` | entire tail: fraction, decimal, and/or exponent | `" 1/3"` from `"2 1/3"`; `".23"` from `"1.23"`; `".5e3"` from `"1.5e3"` |
|
|
172
|
+
* | `4` | exponent, when there is no decimal portion | `"e3"` from `"1e3"` |
|
|
173
|
+
* | `5` | exponent, when there is a decimal portion | `"e-3"` from `"1.5e-3"` |
|
|
174
|
+
* | `6` | numerator of a mixed number (incl. leading space) | `" 2"` from `"1 2/3"` |
|
|
175
|
+
*
|
|
176
|
+
* Groups 4–6 are subgroups of group 3 and are not used directly by
|
|
177
|
+
* {@link numericQuantity}; only groups 1–3 are consumed.
|
|
178
|
+
*
|
|
179
|
+
* _Capture groups 2 and 3 may include comma/underscore separators._
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
*
|
|
183
|
+
* ```ts
|
|
184
|
+
* numericRegex.exec("1") // [ "1", null, "1", null, null, null, null ]
|
|
185
|
+
* numericRegex.exec("1.23") // [ "1.23", null, "1", ".23", null, null, null ]
|
|
186
|
+
* numericRegex.exec("1 2/3") // [ "1 2/3", null, "1", " 2/3", null, null, " 2" ]
|
|
187
|
+
* numericRegex.exec("2/3") // [ "2/3", null, "2", "/3", null, null, null ]
|
|
188
|
+
* numericRegex.exec("2 / 3") // [ "2 / 3", null, "2", " / 3", null, null, null ]
|
|
189
|
+
* numericRegex.exec("-2 1/3") // [ "-2 1/3", "-", "2", " 1/3", null, null, " 1" ]
|
|
190
|
+
* numericRegex.exec("1e3") // [ "1e3", null, "1", "e3", "e3", null, null ]
|
|
191
|
+
* numericRegex.exec("1.5e-3") // [ "1.5e-3", null, "1", ".5e-3", null, "e-3", null ]
|
|
192
|
+
* numericRegex.exec("1,000") // [ "1,000", null, "1,000", null, null, null, null ]
|
|
193
|
+
* ```
|
|
194
|
+
*
|
|
195
|
+
* @remarks
|
|
196
|
+
*
|
|
197
|
+
* This pattern and {@link numericRegexWithTrailingInvalid} are maintained as two separate
|
|
198
|
+
* literals and must be kept in sync. They differ _only_ in the tail: `$` here versus
|
|
199
|
+
* `(\s*[^.\d/].*)?` there. `src/index.test.ts` asserts that equality.
|
|
200
|
+
*
|
|
201
|
+
* Group 2 is `((?:\d(?:[,_]\d|\d)*)?)`, deliberately `?` and not `*`. Every string the
|
|
202
|
+
* inner group matches begins and ends with a digit, so concatenating two of them yields
|
|
203
|
+
* another string of the same shape: an outer `*` would add no strings to the language,
|
|
204
|
+
* only exponentially many ways to split one digit run across iterations. That made a
|
|
205
|
+
* failing match catastrophically backtrack — `'1'.repeat(30) + '!'` took ~15s on V8.
|
|
206
|
+
*/
|
|
207
|
+
const numericRegex = /^(?=[-+]?\s*\.\d|[-+]?\s*\d)([-+])?\s*((?:\d(?:[,_]\d|\d)*)?)(([eE][+-]?\d(?:[,_]\d|\d)*)?|\.\d(?:[,_]\d|\d)*([eE][+-]?\d(?:[,_]\d|\d)*)?|(\s+\d(?:[,_]\d|\d)*\s*)?\s*\/\s*\d(?:[,_]\d|\d)*)?$/;
|
|
208
|
+
/**
|
|
209
|
+
* Same as {@link numericRegex}, but allows (and ignores) trailing invalid characters.
|
|
210
|
+
* Capture groups 1–6 are identical to {@link numericRegex}'s; capture group 7 contains the
|
|
211
|
+
* trailing invalid portion.
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
*
|
|
215
|
+
* ```ts
|
|
216
|
+
* numericRegexWithTrailingInvalid.exec("1abc")
|
|
217
|
+
* // [ "1abc", null, "1", null, null, null, null, "abc" ]
|
|
218
|
+
* numericRegexWithTrailingInvalid.exec("1 2/3 xyz")
|
|
219
|
+
* // [ "1 2/3 xyz", null, "1", " 2/3", null, null, " 2", " xyz" ]
|
|
220
|
+
* ```
|
|
221
|
+
*
|
|
222
|
+
* @remarks
|
|
223
|
+
*
|
|
224
|
+
* Must be kept in sync with {@link numericRegex} — see that pattern's remarks.
|
|
225
|
+
*/
|
|
226
|
+
const numericRegexWithTrailingInvalid = /^(?=[-+]?\s*\.\d|[-+]?\s*\d)([-+])?\s*((?:\d(?:[,_]\d|\d)*)?)(([eE][+-]?\d(?:[,_]\d|\d)*)?|\.\d(?:[,_]\d|\d)*([eE][+-]?\d(?:[,_]\d|\d)*)?|(\s+\d(?:[,_]\d|\d)*\s*)?\s*\/\s*\d(?:[,_]\d|\d)*)?(\s*[^.\d/].*)?/;
|
|
227
|
+
/**
|
|
228
|
+
* Captures any Unicode vulgar fractions.
|
|
229
|
+
*/
|
|
230
|
+
const vulgarFractionsRegex = /([¼½¾⅐⅑⅒⅓⅔⅕⅖⅗⅘⅙⅚⅛⅜⅝⅞⅟])/g;
|
|
231
|
+
/**
|
|
232
|
+
* Map of Roman numeral sequences to their decimal equivalents.
|
|
233
|
+
*/
|
|
234
|
+
const romanNumeralValues = {
|
|
235
|
+
MMM: 3e3,
|
|
236
|
+
MM: 2e3,
|
|
237
|
+
M: 1e3,
|
|
238
|
+
CM: 900,
|
|
239
|
+
DCCC: 800,
|
|
240
|
+
DCC: 700,
|
|
241
|
+
DC: 600,
|
|
242
|
+
D: 500,
|
|
243
|
+
CD: 400,
|
|
244
|
+
CCC: 300,
|
|
245
|
+
CC: 200,
|
|
246
|
+
C: 100,
|
|
247
|
+
XC: 90,
|
|
248
|
+
LXXX: 80,
|
|
249
|
+
LXX: 70,
|
|
250
|
+
LX: 60,
|
|
251
|
+
L: 50,
|
|
252
|
+
XL: 40,
|
|
253
|
+
XXX: 30,
|
|
254
|
+
XX: 20,
|
|
255
|
+
XII: 12,
|
|
256
|
+
XI: 11,
|
|
257
|
+
X: 10,
|
|
258
|
+
IX: 9,
|
|
259
|
+
VIII: 8,
|
|
260
|
+
VII: 7,
|
|
261
|
+
VI: 6,
|
|
262
|
+
V: 5,
|
|
263
|
+
IV: 4,
|
|
264
|
+
III: 3,
|
|
265
|
+
II: 2,
|
|
266
|
+
I: 1
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* Map of Unicode Roman numeral code points to their ASCII equivalents.
|
|
270
|
+
*/
|
|
271
|
+
const romanNumeralUnicodeToAsciiMap = {
|
|
272
|
+
Ⅰ: "I",
|
|
273
|
+
Ⅱ: "II",
|
|
274
|
+
Ⅲ: "III",
|
|
275
|
+
Ⅳ: "IV",
|
|
276
|
+
Ⅴ: "V",
|
|
277
|
+
Ⅵ: "VI",
|
|
278
|
+
Ⅶ: "VII",
|
|
279
|
+
Ⅷ: "VIII",
|
|
280
|
+
Ⅸ: "IX",
|
|
281
|
+
Ⅹ: "X",
|
|
282
|
+
Ⅺ: "XI",
|
|
283
|
+
Ⅻ: "XII",
|
|
284
|
+
Ⅼ: "L",
|
|
285
|
+
Ⅽ: "C",
|
|
286
|
+
Ⅾ: "D",
|
|
287
|
+
Ⅿ: "M",
|
|
288
|
+
ⅰ: "I",
|
|
289
|
+
ⅱ: "II",
|
|
290
|
+
ⅲ: "III",
|
|
291
|
+
ⅳ: "IV",
|
|
292
|
+
ⅴ: "V",
|
|
293
|
+
ⅵ: "VI",
|
|
294
|
+
ⅶ: "VII",
|
|
295
|
+
ⅷ: "VIII",
|
|
296
|
+
ⅸ: "IX",
|
|
297
|
+
ⅹ: "X",
|
|
298
|
+
ⅺ: "XI",
|
|
299
|
+
ⅻ: "XII",
|
|
300
|
+
ⅼ: "L",
|
|
301
|
+
ⅽ: "C",
|
|
302
|
+
ⅾ: "D",
|
|
303
|
+
ⅿ: "M"
|
|
304
|
+
};
|
|
305
|
+
/**
|
|
306
|
+
* Captures all Unicode Roman numeral code points.
|
|
307
|
+
*/
|
|
308
|
+
const romanNumeralUnicodeRegex = /([ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿ])/gi;
|
|
309
|
+
/**
|
|
310
|
+
* Captures a valid Roman numeral sequence.
|
|
311
|
+
*
|
|
312
|
+
* Capture groups:
|
|
313
|
+
*
|
|
314
|
+
* | # | Description | Example |
|
|
315
|
+
* | --- | --------------- | ------------------------ |
|
|
316
|
+
* | `0` | Entire string | "MCCXIV" from "MCCXIV" |
|
|
317
|
+
* | `1` | Thousands | "M" from "MCCXIV" |
|
|
318
|
+
* | `2` | Hundreds | "CC" from "MCCXIV" |
|
|
319
|
+
* | `3` | Tens | "X" from "MCCXIV" |
|
|
320
|
+
* | `4` | Ones | "IV" from "MCCXIV" |
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
*
|
|
324
|
+
* ```ts
|
|
325
|
+
* romanNumeralRegex.exec("M") // [ "M", "M", "", "", "" ]
|
|
326
|
+
* romanNumeralRegex.exec("XII") // [ "XII", "", "", "X", "II" ]
|
|
327
|
+
* romanNumeralRegex.exec("MCCXIV") // [ "MCCXIV", "M", "CC", "X", "IV" ]
|
|
328
|
+
* ```
|
|
329
|
+
*/
|
|
330
|
+
const romanNumeralRegex = /^(?=[MDCLXVI])(M{0,3})(C[MD]|D?C{0,3})(X[CL]|L?X{0,3})(I[XV]|V?I{0,3})$/i;
|
|
331
|
+
/**
|
|
332
|
+
* Default options for {@link numericQuantity}.
|
|
333
|
+
*/
|
|
334
|
+
const defaultOptions = {
|
|
335
|
+
round: 3,
|
|
336
|
+
allowTrailingInvalid: false,
|
|
337
|
+
romanNumerals: false,
|
|
338
|
+
bigIntOnOverflow: false,
|
|
339
|
+
decimalSeparator: ".",
|
|
340
|
+
allowCurrency: false,
|
|
341
|
+
percentage: false,
|
|
342
|
+
verbose: false
|
|
343
|
+
};
|
|
344
|
+
//#endregion
|
|
345
|
+
//#region src/parseRomanNumerals.ts
|
|
346
|
+
/**
|
|
347
|
+
* Converts a string of Roman numerals to a number, like `parseInt`
|
|
348
|
+
* for Roman numerals. Uses modern, strict rules (only 1 to 3999).
|
|
349
|
+
*
|
|
350
|
+
* The string can include ASCII representations of Roman numerals
|
|
351
|
+
* or Unicode Roman numeral code points (`U+2160` through `U+217F`).
|
|
352
|
+
*/
|
|
353
|
+
const parseRomanNumerals = (romanNumerals) => {
|
|
354
|
+
var _romanNumeralValues, _romanNumeralValues2, _romanNumeralValues3, _romanNumeralValues4;
|
|
355
|
+
const normalized = romanNumerals.replace(romanNumeralUnicodeRegex, (_m, rn) => romanNumeralUnicodeToAsciiMap[rn]).toUpperCase();
|
|
356
|
+
const regexResult = romanNumeralRegex.exec(normalized);
|
|
357
|
+
if (!regexResult) return NaN;
|
|
358
|
+
const [, thousands, hundreds, tens, ones] = regexResult;
|
|
359
|
+
return ((_romanNumeralValues = romanNumeralValues[thousands]) !== null && _romanNumeralValues !== void 0 ? _romanNumeralValues : 0) + ((_romanNumeralValues2 = romanNumeralValues[hundreds]) !== null && _romanNumeralValues2 !== void 0 ? _romanNumeralValues2 : 0) + ((_romanNumeralValues3 = romanNumeralValues[tens]) !== null && _romanNumeralValues3 !== void 0 ? _romanNumeralValues3 : 0) + ((_romanNumeralValues4 = romanNumeralValues[ones]) !== null && _romanNumeralValues4 !== void 0 ? _romanNumeralValues4 : 0);
|
|
360
|
+
};
|
|
361
|
+
//#endregion
|
|
362
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
363
|
+
function _typeof(o) {
|
|
364
|
+
"@babel/helpers - typeof";
|
|
365
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
366
|
+
return typeof o;
|
|
367
|
+
} : function(o) {
|
|
368
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
369
|
+
}, _typeof(o);
|
|
370
|
+
}
|
|
371
|
+
//#endregion
|
|
372
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
373
|
+
function toPrimitive(t, r) {
|
|
374
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
375
|
+
var e = t[Symbol.toPrimitive];
|
|
376
|
+
if (void 0 !== e) {
|
|
377
|
+
var i = e.call(t, r || "default");
|
|
378
|
+
if ("object" != _typeof(i)) return i;
|
|
379
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
380
|
+
}
|
|
381
|
+
return ("string" === r ? String : Number)(t);
|
|
382
|
+
}
|
|
383
|
+
//#endregion
|
|
384
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
385
|
+
function toPropertyKey(t) {
|
|
386
|
+
var i = toPrimitive(t, "string");
|
|
387
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
388
|
+
}
|
|
389
|
+
//#endregion
|
|
390
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
391
|
+
function _defineProperty(e, r, t) {
|
|
392
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
393
|
+
value: t,
|
|
394
|
+
enumerable: !0,
|
|
395
|
+
configurable: !0,
|
|
396
|
+
writable: !0
|
|
397
|
+
}) : e[r] = t, e;
|
|
398
|
+
}
|
|
399
|
+
//#endregion
|
|
400
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/objectSpread2.js
|
|
401
|
+
function ownKeys(e, r) {
|
|
402
|
+
var t = Object.keys(e);
|
|
403
|
+
if (Object.getOwnPropertySymbols) {
|
|
404
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
405
|
+
r && (o = o.filter(function(r) {
|
|
406
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
407
|
+
})), t.push.apply(t, o);
|
|
408
|
+
}
|
|
409
|
+
return t;
|
|
410
|
+
}
|
|
411
|
+
function _objectSpread2(e) {
|
|
412
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
413
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
414
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
415
|
+
_defineProperty(e, r, t[r]);
|
|
416
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
417
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
return e;
|
|
421
|
+
}
|
|
422
|
+
//#endregion
|
|
423
|
+
//#region src/numericQuantity.ts
|
|
424
|
+
const leadingSlashRegex = /^\s*\//;
|
|
425
|
+
const currencyPrefixRegex = new RegExp("^([-+]?)\\s*(\\p{Sc}+)\\s*", "u");
|
|
426
|
+
const currencySuffixRegex = new RegExp("\\s*(\\p{Sc}+)\\s*$", "u");
|
|
427
|
+
const percentageSuffixRegex = /\s*%$/;
|
|
428
|
+
const maxSafeBigInt = BigInt(Number.MAX_SAFE_INTEGER);
|
|
429
|
+
/**
|
|
430
|
+
* Upper bound on `10 ** exp` magnitudes evaluated exactly. Anything beyond this
|
|
431
|
+
* overflows/underflows the `number` path to `Infinity`/`0` anyway, so bounding it
|
|
432
|
+
* avoids allocating absurdly large `bigint`s (and `BigInt(Infinity)` throwing).
|
|
433
|
+
*/
|
|
434
|
+
const maxExactExponent = 1e4;
|
|
435
|
+
const pow10 = (exp) => 10n ** BigInt(exp);
|
|
436
|
+
/**
|
|
437
|
+
* Evaluates the parsed numeric components as an exact `bigint` rational (magnitude only,
|
|
438
|
+
* sign is applied by the caller) and rounds the result half-up.
|
|
439
|
+
*
|
|
440
|
+
* Returns the rounded `bigint` only if its magnitude exceeds `Number.MAX_SAFE_INTEGER`;
|
|
441
|
+
* otherwise returns `undefined`, meaning "no overflow, use the `number` path".
|
|
442
|
+
*
|
|
443
|
+
* @param group1 - Whole number or numerator (separators already stripped).
|
|
444
|
+
* @param group2 - Decimal/exponent/fraction tail, if any.
|
|
445
|
+
* @param divideBy100 - Whether a percentage suffix was stripped.
|
|
446
|
+
*/
|
|
447
|
+
const toRoundedBigInt = (group1, group2, divideBy100) => {
|
|
448
|
+
let numerator;
|
|
449
|
+
let denominator = 1n;
|
|
450
|
+
if (!group2) numerator = BigInt(group1);
|
|
451
|
+
else if (group2.startsWith(".") || group2.startsWith("e") || group2.startsWith("E")) {
|
|
452
|
+
const expIndex = group2.search(/[eE]/);
|
|
453
|
+
const exponent = expIndex === -1 ? 0 : parseInt(group2.slice(expIndex + 1));
|
|
454
|
+
if (!Number.isFinite(exponent) || Math.abs(exponent) > maxExactExponent) return void 0;
|
|
455
|
+
const fractionDigits = (expIndex === -1 ? group2 : group2.slice(0, expIndex)).slice(1);
|
|
456
|
+
numerator = BigInt(`${group1}${fractionDigits}`);
|
|
457
|
+
if (fractionDigits) denominator = pow10(fractionDigits.length);
|
|
458
|
+
if (exponent > 0) numerator *= pow10(exponent);
|
|
459
|
+
else if (exponent < 0) denominator *= pow10(-exponent);
|
|
460
|
+
} else if (leadingSlashRegex.test(group2)) {
|
|
461
|
+
numerator = BigInt(group1);
|
|
462
|
+
denominator = BigInt(group2.replace("/", "").trim());
|
|
463
|
+
} else {
|
|
464
|
+
const [n, d] = group2.split("/");
|
|
465
|
+
denominator = BigInt(d.trim());
|
|
466
|
+
numerator = BigInt(group1) * denominator + BigInt(n.trim());
|
|
467
|
+
}
|
|
468
|
+
if (divideBy100) denominator *= 100n;
|
|
469
|
+
if (denominator === 0n) return void 0;
|
|
470
|
+
const rounded = (2n * numerator + denominator) / (2n * denominator);
|
|
471
|
+
return rounded > maxSafeBigInt ? rounded : void 0;
|
|
472
|
+
};
|
|
473
|
+
function numericQuantity(quantity, options = defaultOptions) {
|
|
474
|
+
var _regexResult$7$length, _regexResult$;
|
|
475
|
+
const opts = _objectSpread2(_objectSpread2({}, defaultOptions), options);
|
|
476
|
+
let originalInput;
|
|
477
|
+
if (typeof quantity === "string") originalInput = quantity;
|
|
478
|
+
else try {
|
|
479
|
+
originalInput = String(quantity);
|
|
480
|
+
} catch (_unused) {
|
|
481
|
+
originalInput = "";
|
|
482
|
+
}
|
|
483
|
+
let currencyPrefix;
|
|
484
|
+
let currencySuffix;
|
|
485
|
+
let percentageSuffix;
|
|
486
|
+
let trailingInvalid;
|
|
487
|
+
let parsedSign;
|
|
488
|
+
let parsedWhole;
|
|
489
|
+
let parsedNumerator;
|
|
490
|
+
let parsedDenominator;
|
|
491
|
+
const buildVerboseResult = (value) => {
|
|
492
|
+
const result = {
|
|
493
|
+
value,
|
|
494
|
+
input: originalInput
|
|
495
|
+
};
|
|
496
|
+
if (currencyPrefix) result.currencyPrefix = currencyPrefix;
|
|
497
|
+
if (currencySuffix) result.currencySuffix = currencySuffix;
|
|
498
|
+
if (percentageSuffix) result.percentageSuffix = percentageSuffix;
|
|
499
|
+
if (trailingInvalid) result.trailingInvalid = trailingInvalid;
|
|
500
|
+
if (parsedSign) result.sign = parsedSign;
|
|
501
|
+
if (parsedWhole !== void 0) result.whole = parsedWhole;
|
|
502
|
+
if (parsedNumerator !== void 0) result.numerator = parsedNumerator;
|
|
503
|
+
if (parsedDenominator !== void 0) result.denominator = parsedDenominator;
|
|
504
|
+
return result;
|
|
505
|
+
};
|
|
506
|
+
const returnValue = (value) => opts.verbose ? buildVerboseResult(value) : value;
|
|
507
|
+
/**
|
|
508
|
+
* Divides by 100 if a percentage suffix was stripped. Exact scaling, no rounding:
|
|
509
|
+
* `round` applies to the quantity as written, before this division.
|
|
510
|
+
*/
|
|
511
|
+
const applyPercentage = (value) => percentageSuffix && opts.percentage !== "number" ? value / 100 : value;
|
|
512
|
+
if (typeof quantity === "symbol") return returnValue(NaN);
|
|
513
|
+
if (typeof quantity === "number" || typeof quantity === "bigint") return returnValue(quantity);
|
|
514
|
+
let finalResult = NaN;
|
|
515
|
+
let workingString = originalInput;
|
|
516
|
+
let affixStripped = true;
|
|
517
|
+
while (affixStripped) {
|
|
518
|
+
affixStripped = false;
|
|
519
|
+
if (opts.allowCurrency) {
|
|
520
|
+
const prefixMatch = currencyPrefixRegex.exec(workingString);
|
|
521
|
+
if (prefixMatch === null || prefixMatch === void 0 ? void 0 : prefixMatch[2]) {
|
|
522
|
+
var _currencyPrefix;
|
|
523
|
+
currencyPrefix = ((_currencyPrefix = currencyPrefix) !== null && _currencyPrefix !== void 0 ? _currencyPrefix : "") + prefixMatch[2];
|
|
524
|
+
workingString = (prefixMatch[1] || "") + workingString.slice(prefixMatch[0].length);
|
|
525
|
+
affixStripped = true;
|
|
526
|
+
}
|
|
527
|
+
const suffixMatch = currencySuffixRegex.exec(workingString);
|
|
528
|
+
if (suffixMatch) {
|
|
529
|
+
var _currencySuffix;
|
|
530
|
+
currencySuffix = suffixMatch[1] + ((_currencySuffix = currencySuffix) !== null && _currencySuffix !== void 0 ? _currencySuffix : "");
|
|
531
|
+
workingString = workingString.slice(0, -suffixMatch[0].length);
|
|
532
|
+
affixStripped = true;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
if (!percentageSuffix && opts.percentage) {
|
|
536
|
+
const pctMatch = percentageSuffixRegex.exec(workingString);
|
|
537
|
+
if (pctMatch) {
|
|
538
|
+
percentageSuffix = true;
|
|
539
|
+
workingString = workingString.slice(0, -pctMatch[0].length);
|
|
540
|
+
affixStripped = true;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
const quantityAsString = normalizeDigits(workingString.replace(vulgarFractionsRegex, (_m, vf) => ` ${vulgarFractionToAsciiMap[vf]}`).replace(superSubDigitsRegex, (ch) => superSubDigitToAsciiMap[ch]).replace("⁄", "/").trim());
|
|
545
|
+
if (quantityAsString.length === 0) return returnValue(NaN);
|
|
546
|
+
let normalizedString = quantityAsString;
|
|
547
|
+
if (opts.decimalSeparator === ",") {
|
|
548
|
+
const commaCount = (quantityAsString.match(/,/g) || []).length;
|
|
549
|
+
if (commaCount === 1) normalizedString = quantityAsString.replaceAll(".", "_").replace(",", ".");
|
|
550
|
+
else if (commaCount > 1) {
|
|
551
|
+
const firstCommaIndex = quantityAsString.indexOf(",");
|
|
552
|
+
const secondCommaIndex = quantityAsString.indexOf(",", firstCommaIndex + 1);
|
|
553
|
+
normalizedString = quantityAsString.substring(0, secondCommaIndex).replaceAll(".", "_").replace(",", ".");
|
|
554
|
+
} else normalizedString = quantityAsString.replaceAll(".", "_");
|
|
555
|
+
}
|
|
556
|
+
const regexResult = numericRegexWithTrailingInvalid.exec(normalizedString);
|
|
557
|
+
if (!regexResult) {
|
|
558
|
+
if (!opts.romanNumerals) return returnValue(NaN);
|
|
559
|
+
return returnValue(applyPercentage(parseRomanNumerals(quantityAsString)));
|
|
560
|
+
}
|
|
561
|
+
const consumedLength = regexResult[0].length - ((_regexResult$7$length = (_regexResult$ = regexResult[7]) === null || _regexResult$ === void 0 ? void 0 : _regexResult$.length) !== null && _regexResult$7$length !== void 0 ? _regexResult$7$length : 0);
|
|
562
|
+
const rawTrailing = quantityAsString.slice(consumedLength).trim();
|
|
563
|
+
if (rawTrailing) {
|
|
564
|
+
trailingInvalid = rawTrailing;
|
|
565
|
+
if (!opts.allowTrailingInvalid) return returnValue(NaN);
|
|
566
|
+
}
|
|
567
|
+
const [, sign, rawGroup1, rawGroup2] = regexResult;
|
|
568
|
+
if (sign === "-" || sign === "+") parsedSign = sign;
|
|
569
|
+
const numberGroup1 = rawGroup1.replaceAll(",", "").replaceAll("_", "");
|
|
570
|
+
const numberGroup2 = rawGroup2 === null || rawGroup2 === void 0 ? void 0 : rawGroup2.replaceAll(",", "").replaceAll("_", "");
|
|
571
|
+
if (opts.bigIntOnOverflow) {
|
|
572
|
+
const asBigInt = toRoundedBigInt(numberGroup1, numberGroup2, !!percentageSuffix && opts.percentage !== "number");
|
|
573
|
+
if (asBigInt !== void 0) return returnValue(sign === "-" ? -asBigInt : asBigInt);
|
|
574
|
+
}
|
|
575
|
+
finalResult = !numberGroup1 && numberGroup2 && numberGroup2.startsWith(".") ? 0 : parseInt(numberGroup1);
|
|
576
|
+
if (!numberGroup2) {
|
|
577
|
+
finalResult = sign === "-" ? finalResult * -1 : finalResult;
|
|
578
|
+
return returnValue(applyPercentage(finalResult));
|
|
579
|
+
}
|
|
580
|
+
const roundTo = typeof opts.round === "number" && Number.isFinite(opts.round) ? Math.floor(Math.max(0, opts.round)) : false;
|
|
581
|
+
const roundingFactorRaw = roundTo === false ? NaN : 10 ** roundTo;
|
|
582
|
+
const roundingFactor = Number.isFinite(roundingFactorRaw) ? roundingFactorRaw : NaN;
|
|
583
|
+
/** Rounds to `roundTo` decimal places, falling back to `value` if the scaling overflows. */
|
|
584
|
+
const round = (value, scaled) => {
|
|
585
|
+
const result = Math.round(scaled) / roundingFactor;
|
|
586
|
+
return Number.isFinite(result) || !Number.isFinite(value) ? result : value;
|
|
587
|
+
};
|
|
588
|
+
if (numberGroup2.startsWith(".") || numberGroup2.startsWith("e") || numberGroup2.startsWith("E")) {
|
|
589
|
+
const decimalValue = parseFloat(`${finalResult}${numberGroup2}`);
|
|
590
|
+
finalResult = isNaN(roundingFactor) ? decimalValue : round(decimalValue, decimalValue * roundingFactor);
|
|
591
|
+
} else if (leadingSlashRegex.test(numberGroup2)) {
|
|
592
|
+
const numerator = parseInt(numberGroup1);
|
|
593
|
+
const denominator = parseInt(numberGroup2.replace("/", ""));
|
|
594
|
+
parsedNumerator = numerator;
|
|
595
|
+
parsedDenominator = denominator;
|
|
596
|
+
finalResult = isNaN(roundingFactor) ? numerator / denominator : round(numerator / denominator, numerator * roundingFactor / denominator);
|
|
597
|
+
} else {
|
|
598
|
+
const [numerator, denominator] = numberGroup2.split("/").map((v) => parseInt(v));
|
|
599
|
+
parsedWhole = finalResult;
|
|
600
|
+
parsedNumerator = numerator;
|
|
601
|
+
parsedDenominator = denominator;
|
|
602
|
+
finalResult += isNaN(roundingFactor) ? numerator / denominator : round(numerator / denominator, numerator * roundingFactor / denominator);
|
|
603
|
+
}
|
|
604
|
+
finalResult = sign === "-" ? finalResult * -1 : finalResult;
|
|
605
|
+
return returnValue(applyPercentage(finalResult));
|
|
606
|
+
}
|
|
607
|
+
//#endregion
|
|
608
|
+
//#region src/isNumericQuantity.ts
|
|
609
|
+
/**
|
|
610
|
+
* Checks if a value represents a valid numeric quantity.
|
|
611
|
+
*
|
|
612
|
+
* Returns `true` if the value can be parsed as a number, `false` otherwise.
|
|
613
|
+
* Accepts the same options as `numericQuantity`.
|
|
614
|
+
*/
|
|
615
|
+
const isNumericQuantity = (quantity, options) => {
|
|
616
|
+
const result = numericQuantity(quantity, _objectSpread2(_objectSpread2({}, options), {}, { verbose: false }));
|
|
617
|
+
return typeof result === "bigint" || !isNaN(result);
|
|
618
|
+
};
|
|
619
|
+
//#endregion
|
|
620
|
+
export { defaultOptions, isNumericQuantity, normalizeDigits, numericQuantity, numericRegex, numericRegexWithTrailingInvalid, parseRomanNumerals, romanNumeralRegex, romanNumeralUnicodeRegex, romanNumeralUnicodeToAsciiMap, romanNumeralValues, superSubDigitToAsciiMap, superSubDigitsRegex, vulgarFractionToAsciiMap, vulgarFractionsRegex };
|
|
621
|
+
|
|
622
|
+
//# sourceMappingURL=numeric-quantity.legacy-esm.js.map
|