@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,2 @@
|
|
|
1
|
+
import{numericQuantity as e}from"numeric-quantity";const t=.0075,n=Object.freeze({vulgarFractions:!1,tolerance:t,fractionSlash:!1,romanNumerals:!1,zeroFormat:``,allowTrailingInvalid:!0}),r=Object.freeze({"¼":`1/4`,"½":`1/2`,"¾":`3/4`,"⅐":`1/7`,"⅑":`1/9`,"⅒":`1/10`,"⅓":`1/3`,"⅔":`2/3`,"⅕":`1/5`,"⅖":`2/5`,"⅗":`3/5`,"⅘":`4/5`,"⅙":`1/6`,"⅚":`5/6`,"⅛":`1/8`,"⅜":`3/8`,"⅝":`5/8`,"⅞":`7/8`}),i=Object.freeze([[1/16,`1/16`],[1/10,`⅒`],[1/9,`⅑`],[1/8,`⅛`],[1/7,`⅐`],[1/6,`⅙`],[3/16,`3/16`],[1/5,`⅕`],[1/4,`¼`],[5/16,`5/16`],[1/3,`⅓`],[3/8,`⅜`],[2/5,`⅖`],[7/16,`7/16`],[1/2,`½`],[9/16,`9/16`],[3/5,`⅗`],[5/8,`⅝`],[2/3,`⅔`],[11/16,`11/16`],[3/4,`¾`],[4/5,`⅘`],[13/16,`13/16`],[5/6,`⅚`],[7/8,`⅞`],[15/16,`15/16`]].map(e=>Object.freeze(e))),a=e=>[...e].map(e=>`⁰¹²³⁴⁵⁶⁷⁸⁹`[+e]).join(``),o=e=>[...e].map(e=>`₀₁₂₃₄₅₆₇₈₉`[+e]).join(``),s=(e,{fractionSlash:t,vulgarFractions:n})=>{if(n)return e;let i=r[e]??e;if(t){let[e,t]=i.split(`/`);return`${a(e)}⁄${o(t)}`}return i},c=e=>e===!1||typeof e==`number`&&e>=0,l=e=>{let t={...n,...typeof e==`boolean`?{vulgarFractions:e}:typeof e==`object`&&e?e:{}};return c(t.tolerance)||(t.tolerance=n.tolerance),typeof t.zeroFormat!=`string`&&(t.zeroFormat=n.zeroFormat),t.allowTrailingInvalid!==!1&&(t.allowTrailingInvalid=!0),t},u=`.C.CC.CCC.CD.D.DC.DCC.DCCC.CM..X.XX.XXX.XL.L.LX.LXX.LXXX.XC..I.II.III.IV.V.VI.VII.VIII.IX`.split(`.`),d=e=>{if(typeof e!=`number`&&typeof e!=`bigint`||!(e>=1&&e<4e3))return null;let t=Number(e),n=`${Math.floor(t)}`.split(``),r=``,i=3;for(;i--;)r=`${u[+n.pop()+i*10]||``}${r}`;return`${Array(+n.join(``)+1).join(`M`)}${r}`},f=(t,n)=>{if(typeof t!=`number`&&typeof t!=`string`&&typeof t!=`bigint`)return null;let a=l(n),o=typeof t!=`number`&&typeof t!=`bigint`?e(t,{allowTrailingInvalid:a.allowTrailingInvalid,romanNumerals:a.romanNumerals,bigIntOnOverflow:!0,round:!1}):t;if(typeof o==`number`&&isNaN(o))return null;if(Number(o)===0)return a.zeroFormat;if(a.romanNumerals)return d(o);let c=typeof o==`bigint`?o<0n?-o:o:Math.abs(o),u=typeof c==`bigint`?c:Math.floor(c),f=`${u||``}`,p=typeof c==`bigint`?0:c-u;if(p===0)return`${o}`;let m=null,h=1/0;if(a.tolerance!==!1)for(let[e,t]of i){let n=Math.abs(p-e);if(n<a.tolerance||n===0){if(n===0){m=t;break}n<h&&(m=t,h=n)}}if(m){let e=s(m,a),t=e in r,n=f?a.separator??(t?``:` `):``;return`${o<0?`-`:``}${f}${n}${e}`}return`${o}`};export{n as defaultOptions,t as defaultTolerance,f as formatQuantity,d as formatRomanNumerals,i as fractionDecimalMatches,r as vulgarToAsciiMap};
|
|
2
|
+
//# sourceMappingURL=format-quantity.production.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-quantity.production.mjs","names":[],"sources":["../src/constants.ts","../src/formatQuantity.ts"],"sourcesContent":["import type {\n ResolvedFormatQuantityOptions,\n SimpleFraction,\n Sixteenth,\n VulgarFraction,\n} from './types';\n\n/**\n * Default tolerance used by {@link formatQuantity} when determining if a number\n * is close enough to a fraction value to be considered equivalent.\n */\nexport const defaultTolerance = 0.0075 as const;\n\n/**\n * Default options for {@link formatQuantity}.\n */\nexport const defaultOptions: Readonly<ResolvedFormatQuantityOptions> = Object.freeze({\n vulgarFractions: false,\n tolerance: defaultTolerance,\n fractionSlash: false,\n romanNumerals: false,\n zeroFormat: '',\n allowTrailingInvalid: true,\n});\n\n/**\n * Map of vulgar fractions to their traditional ASCII equivalents.\n */\nexport const vulgarToAsciiMap: Readonly<Record<VulgarFraction, SimpleFraction>> = Object.freeze({\n '¼': '1/4',\n '½': '1/2',\n '¾': '3/4',\n '⅐': '1/7',\n '⅑': '1/9',\n '⅒': '1/10',\n '⅓': '1/3',\n '⅔': '2/3',\n '⅕': '1/5',\n '⅖': '2/5',\n '⅗': '3/5',\n '⅘': '4/5',\n '⅙': '1/6',\n '⅚': '5/6',\n '⅛': '1/8',\n '⅜': '3/8',\n '⅝': '5/8',\n '⅞': '7/8',\n});\n\n/**\n * Map of \"close enough\" values to the {@link VulgarFraction} or {@link Sixteenth} fraction\n * string matches. The value +/- the `tolerance` option (or {@link defaultTolerance} if not\n * specified) is considered close enough to match the fraction.\n */\nexport const fractionDecimalMatches: readonly (readonly [number, VulgarFraction | Sixteenth])[] =\n Object.freeze(\n (\n [\n [1 / 16, '1/16'],\n [1 / 10, '⅒'],\n [1 / 9, '⅑'],\n [1 / 8, '⅛'],\n [1 / 7, '⅐'],\n [1 / 6, '⅙'],\n [3 / 16, '3/16'],\n [1 / 5, '⅕'],\n [1 / 4, '¼'],\n [5 / 16, '5/16'],\n [1 / 3, '⅓'],\n [3 / 8, '⅜'],\n [2 / 5, '⅖'],\n [7 / 16, '7/16'],\n [1 / 2, '½'],\n [9 / 16, '9/16'],\n [3 / 5, '⅗'],\n [5 / 8, '⅝'],\n [2 / 3, '⅔'],\n [11 / 16, '11/16'],\n [3 / 4, '¾'],\n [4 / 5, '⅘'],\n [13 / 16, '13/16'],\n [5 / 6, '⅚'],\n [7 / 8, '⅞'],\n [15 / 16, '15/16'],\n ] satisfies [number, VulgarFraction | Sixteenth][]\n ).map(entry => Object.freeze(entry))\n );\n","import { numericQuantity } from 'numeric-quantity';\nimport { defaultOptions, fractionDecimalMatches, vulgarToAsciiMap } from './constants';\nimport type {\n FormatQuantity,\n ResolvedFormatQuantityOptions,\n SimpleFraction,\n Sixteenth,\n VulgarFraction,\n} from './types';\n\nconst superscriptDigits = '⁰¹²³⁴⁵⁶⁷⁸⁹';\nconst subscriptDigits = '₀₁₂₃₄₅₆₇₈₉';\n\n// oxlint-disable-next-line typescript/no-misused-spread\nconst toSuperscript = (s: string) => [...s].map(c => superscriptDigits[+c]).join('');\n// oxlint-disable-next-line typescript/no-misused-spread\nconst toSubscript = (s: string) => [...s].map(c => subscriptDigits[+c]).join('');\n\n/**\n * Applies the `vulgarFractions` or `fractionSlash` options as necessary.\n */\nconst getFraction = (\n vulgarFractionOrSixteenth: VulgarFraction | Sixteenth,\n { fractionSlash, vulgarFractions }: ResolvedFormatQuantityOptions\n) => {\n if (vulgarFractions) {\n return vulgarFractionOrSixteenth;\n }\n\n const plainFraction: SimpleFraction =\n vulgarToAsciiMap[vulgarFractionOrSixteenth as VulgarFraction] ?? vulgarFractionOrSixteenth;\n\n if (fractionSlash) {\n const [num, den] = plainFraction.split('/');\n return `${toSuperscript(num)}⁄${toSubscript(den)}`;\n }\n\n return plainFraction;\n};\n\n/**\n * Only `false` (matching disabled) or a non-negative number is a valid\n * `tolerance`. Everything else—negative numbers, `NaN`, non-numbers,\n * `null`, `undefined`—resolves to {@link defaultTolerance}.\n */\nconst isValidTolerance = (tolerance: unknown): tolerance is number | false =>\n tolerance === false || (typeof tolerance === 'number' && tolerance >= 0);\n\n/**\n * Merges options object with default options, converting boolean to object if necessary.\n */\nconst normalizeOptions = (\n options: Parameters<FormatQuantity>[1]\n): ResolvedFormatQuantityOptions => {\n const opts: ResolvedFormatQuantityOptions = {\n ...defaultOptions,\n ...(typeof options === 'boolean'\n ? { vulgarFractions: options }\n : typeof options === 'object' && options !== null\n ? options\n : {}),\n };\n\n if (!isValidTolerance(opts.tolerance)) {\n opts.tolerance = defaultOptions.tolerance;\n }\n\n if (typeof opts.zeroFormat !== 'string') {\n opts.zeroFormat = defaultOptions.zeroFormat;\n }\n\n if (opts.allowTrailingInvalid !== false) {\n opts.allowTrailingInvalid = true;\n }\n\n return opts;\n};\n\n// oxfmt-ignore\nconst romanNumeralsByPlace = [\n '', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM',\n '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC',\n '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX',\n] as const;\n\n/**\n * Formats a number or bigint as Roman numerals. The number must be between\n * 1 and 3999, inclusive; any other value—including non-numbers,\n * `NaN`, and non-finite numbers—yields `null`.\n */\nexport const formatRomanNumerals = (quantity: number | bigint): string | null => {\n if (\n (typeof quantity !== 'number' && typeof quantity !== 'bigint') ||\n !(quantity >= 1 && quantity < 4000)\n ) {\n return null;\n }\n\n const qty = Number(quantity);\n\n const floored = Math.floor(qty);\n\n const digits = `${floored}`.split('');\n let roman = '';\n let i = 3;\n while (i--) {\n roman = `${romanNumeralsByPlace[+digits.pop()! + i * 10] || ''}${roman}`;\n }\n\n return `${Array(+digits.join('') + 1).join('M')}${roman}`;\n};\n\n/**\n * Formats a number (or string that appears to be a number)\n * as one would see it written in imperial measurements, e.g.\n * \"1 1/2\" instead of \"1.5\". To use vulgar fraction characters\n * like \"½\", pass `true` as the second argument. For other options\n * see {@link FormatQuantityOptions}.\n */\nexport const formatQuantity: FormatQuantity = (qty, options) => {\n // Only numbers, bigints, and strings are accepted. Anything else (objects, booleans,\n // nullish, arrays like `[1]` that would coerce to a numeric string) is\n // rejected up front so off-type inputs behave consistently.\n if (typeof qty !== 'number' && typeof qty !== 'string' && typeof qty !== 'bigint') {\n return null;\n }\n\n const opts = normalizeOptions(options);\n\n const qtyAsNumber =\n typeof qty !== 'number' && typeof qty !== 'bigint'\n ? numericQuantity(qty, {\n allowTrailingInvalid: opts.allowTrailingInvalid,\n romanNumerals: opts.romanNumerals,\n bigIntOnOverflow: true,\n round: false,\n })\n : qty;\n\n // Return `null` if input is not number-like.\n if (typeof qtyAsNumber === 'number' && isNaN(qtyAsNumber)) {\n return null;\n }\n\n // Return empty string (or configured `zeroFormat`) if the value is zero.\n if (Number(qtyAsNumber) === 0) {\n return opts.zeroFormat;\n }\n\n if (opts.romanNumerals) {\n return formatRomanNumerals(qtyAsNumber);\n }\n\n const absoluteValue =\n typeof qtyAsNumber === 'bigint'\n ? qtyAsNumber < 0n\n ? -qtyAsNumber\n : qtyAsNumber\n : Math.abs(qtyAsNumber);\n const flooredAbsVal =\n typeof absoluteValue === 'bigint' ? absoluteValue : Math.floor(absoluteValue);\n const wholeNumberStr = `${flooredAbsVal || ''}`;\n const decimalValue =\n typeof absoluteValue === 'bigint' ? 0 : absoluteValue - (flooredAbsVal as number);\n\n // For integers just return the given value as a string.\n if (decimalValue === 0) {\n return `${qtyAsNumber}`;\n }\n\n let closestMatch: VulgarFraction | Sixteenth | null = null;\n let closestMatchDiff = Infinity;\n // `tolerance: false` disables fraction matching entirely.\n if (opts.tolerance !== false) {\n for (const [num, vf] of fractionDecimalMatches) {\n const diff = Math.abs(decimalValue - num);\n // `diff === 0` keeps exact quotients matching even at `tolerance: 0`.\n if (diff < opts.tolerance || diff === 0) {\n if (diff === 0) {\n closestMatch = vf;\n break;\n }\n if (diff < closestMatchDiff) {\n closestMatch = vf;\n closestMatchDiff = diff;\n }\n }\n }\n }\n\n if (closestMatch) {\n const fraction = getFraction(closestMatch, opts);\n const isVulgar = fraction in vulgarToAsciiMap;\n const sep = wholeNumberStr ? (opts.separator ?? (isVulgar ? '' : ' ')) : '';\n return `${qtyAsNumber < 0 ? '-' : ''}${wholeNumberStr}${sep}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ports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.FormatQuantity={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let t=.0075,n=Object.freeze({vulgarFractions:!1,tolerance:t,fractionSlash:!1,romanNumerals:!1,zeroFormat:``,allowTrailingInvalid:!0}),r=Object.freeze({"¼":`1/4`,"½":`1/2`,"¾":`3/4`,"⅐":`1/7`,"⅑":`1/9`,"⅒":`1/10`,"⅓":`1/3`,"⅔":`2/3`,"⅕":`1/5`,"⅖":`2/5`,"⅗":`3/5`,"⅘":`4/5`,"⅙":`1/6`,"⅚":`5/6`,"⅛":`1/8`,"⅜":`3/8`,"⅝":`5/8`,"⅞":`7/8`}),i=Object.freeze([[1/16,`1/16`],[1/10,`⅒`],[1/9,`⅑`],[1/8,`⅛`],[1/7,`⅐`],[1/6,`⅙`],[3/16,`3/16`],[1/5,`⅕`],[1/4,`¼`],[5/16,`5/16`],[1/3,`⅓`],[3/8,`⅜`],[2/5,`⅖`],[7/16,`7/16`],[1/2,`½`],[9/16,`9/16`],[3/5,`⅗`],[5/8,`⅝`],[2/3,`⅔`],[11/16,`11/16`],[3/4,`¾`],[4/5,`⅘`],[13/16,`13/16`],[5/6,`⅚`],[7/8,`⅞`],[15/16,`15/16`]].map(e=>Object.freeze(e))),a=[48,1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,42528,43216,43264,43472,43504,43600,44016,65296,66720,68912,68928,69734,69872,69942,70096,70384,70736,70864,71248,71360,71376,71386,71472,71904,72016,72688,72784,73040,73120,73184,73552,90416,92768,92864,93008,93552,118e3,120782,120792,120802,120812,120822,123200,123632,124144,124401,125264,130032],o=e=>e.replace(/\p{Nd}/gu,e=>{let t=e.codePointAt(0);if(t<=57)return e;let n=0,r=a.length-1;for(;n<r;){let e=n+r+1>>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:`XII`,Ⅼ:`L`,Ⅽ:`C`,Ⅾ:`D`,Ⅿ:`M`,ⅰ:`I`,ⅱ:`II`,ⅲ:`III`,ⅳ:`IV`,ⅴ:`V`,ⅵ:`VI`,ⅶ:`VII`,ⅷ:`VIII`,ⅸ:`IX`,ⅹ:`X`,ⅺ:`XI`,ⅻ:`XII`,ⅼ:`L`,ⅽ:`C`,ⅾ:`D`,ⅿ:`M`},m=/([ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿ])/gi,h=/^(?=[MDCLXVI])(M{0,3})(C[MD]|D?C{0,3})(X[CL]|L?X{0,3})(I[XV]|V?I{0,3})$/i,g={round:3,allowTrailingInvalid:!1,romanNumerals:!1,bigIntOnOverflow:!1,decimalSeparator:`.`,allowCurrency:!1,percentage:!1,verbose:!1},_=e=>{let t=e.replace(m,(e,t)=>p[t]).toUpperCase(),n=h.exec(t);if(!n)return NaN;let[,r,i,a,o]=n;return(f[r]??0)+(f[i]??0)+(f[a]??0)+(f[o]??0)},v=/^\s*\//,y=/^([-+]?)\s*(\p{Sc}+)\s*/u,b=/\s*(\p{Sc}+)\s*$/u,x=/\s*%$/,S=BigInt(2**53-1),C=e=>10n**BigInt(e),w=(e,t,n)=>{let r,i=1n;if(!t)r=BigInt(e);else if(t.startsWith(`.`)||t.startsWith(`e`)||t.startsWith(`E`)){let n=t.search(/[eE]/),a=n===-1?0:parseInt(t.slice(n+1));if(!Number.isFinite(a)||Math.abs(a)>1e4)return;let o=(n===-1?t:t.slice(0,n)).slice(1);r=BigInt(`${e}${o}`),o&&(i=C(o.length)),a>0?r*=C(a):a<0&&(i*=C(-a))}else if(v.test(t))r=BigInt(e),i=BigInt(t.replace(`/`,``).trim());else{let[n,a]=t.split(`/`);i=BigInt(a.trim()),r=BigInt(e)*i+BigInt(n.trim())}if(n&&(i*=100n),i===0n)return;let a=(2n*r+i)/(2n*i);return a>S?a:void 0};function T(e,t=g){let n={...g,...t},r;if(typeof e==`string`)r=e;else try{r=String(e)}catch{r=``}let i,a,f,p,m,h,S,C,T=e=>{let t={value:e,input:r};return i&&(t.currencyPrefix=i),a&&(t.currencySuffix=a),f&&(t.percentageSuffix=f),p&&(t.trailingInvalid=p),m&&(t.sign=m),h!==void 0&&(t.whole=h),S!==void 0&&(t.numerator=S),C!==void 0&&(t.denominator=C),t},E=e=>n.verbose?T(e):e,D=e=>f&&n.percentage!==`number`?e/100:e;if(typeof e==`symbol`)return E(NaN);if(typeof e==`number`||typeof e==`bigint`)return E(e);let O=NaN,k=r,A=!0;for(;A;){if(A=!1,n.allowCurrency){let e=y.exec(k);e?.[2]&&(i=(i??``)+e[2],k=(e[1]||``)+k.slice(e[0].length),A=!0);let t=b.exec(k);t&&(a=t[1]+(a??``),k=k.slice(0,-t[0].length),A=!0)}if(!f&&n.percentage){let e=x.exec(k);e&&(f=!0,k=k.slice(0,-e[0].length),A=!0)}}let j=o(k.replace(d,(e,t)=>` ${l[t]}`).replace(c,e=>s[e]).replace(`⁄`,`/`).trim());if(j.length===0)return E(NaN);let M=j;if(n.decimalSeparator===`,`){let e=(j.match(/,/g)||[]).length;if(e===1)M=j.replaceAll(`.`,`_`).replace(`,`,`.`);else if(e>1){let e=j.indexOf(`,`),t=j.indexOf(`,`,e+1);M=j.substring(0,t).replaceAll(`.`,`_`).replace(`,`,`.`)}else M=j.replaceAll(`.`,`_`)}let N=u.exec(M);if(!N)return n.romanNumerals?E(D(_(j))):E(NaN);let P=N[0].length-(N[7]?.length??0),F=j.slice(P).trim();if(F&&(p=F,!n.allowTrailingInvalid))return E(NaN);let[,I,L,R]=N;(I===`-`||I===`+`)&&(m=I);let z=L.replaceAll(`,`,``).replaceAll(`_`,``),B=R?.replaceAll(`,`,``).replaceAll(`_`,``);if(n.bigIntOnOverflow){let e=w(z,B,!!f&&n.percentage!==`number`);if(e!==void 0)return E(I===`-`?-e:e)}if(O=!z&&B&&B.startsWith(`.`)?0:parseInt(z),!B)return O=I===`-`?O*-1:O,E(D(O));let V=typeof n.round==`number`&&Number.isFinite(n.round)?Math.floor(Math.max(0,n.round)):!1,H=V===!1?NaN:10**V,U=Number.isFinite(H)?H:NaN,W=(e,t)=>{let n=Math.round(t)/U;return Number.isFinite(n)||!Number.isFinite(e)?n:e};if(B.startsWith(`.`)||B.startsWith(`e`)||B.startsWith(`E`)){let e=parseFloat(`${O}${B}`);O=isNaN(U)?e:W(e,e*U)}else if(v.test(B)){let e=parseInt(z),t=parseInt(B.replace(`/`,``));S=e,C=t,O=isNaN(U)?e/t:W(e/t,e*U/t)}else{let[e,t]=B.split(`/`).map(e=>parseInt(e));h=O,S=e,C=t,O+=isNaN(U)?e/t:W(e/t,e*U/t)}return O=I===`-`?O*-1:O,E(D(O))}let E=e=>[...e].map(e=>`⁰¹²³⁴⁵⁶⁷⁸⁹`[+e]).join(``),D=e=>[...e].map(e=>`₀₁₂₃₄₅₆₇₈₉`[+e]).join(``),O=(e,{fractionSlash:t,vulgarFractions:n})=>{if(n)return e;let i=r[e]??e;if(t){let[e,t]=i.split(`/`);return`${E(e)}⁄${D(t)}`}return i},k=e=>e===!1||typeof e==`number`&&e>=0,A=e=>{let t={...n,...typeof e==`boolean`?{vulgarFractions:e}:typeof e==`object`&&e?e:{}};return k(t.tolerance)||(t.tolerance=n.tolerance),typeof t.zeroFormat!=`string`&&(t.zeroFormat=n.zeroFormat),t.allowTrailingInvalid!==!1&&(t.allowTrailingInvalid=!0),t},j=`.C.CC.CCC.CD.D.DC.DCC.DCCC.CM..X.XX.XXX.XL.L.LX.LXX.LXXX.XC..I.II.III.IV.V.VI.VII.VIII.IX`.split(`.`),M=e=>{if(typeof e!=`number`&&typeof e!=`bigint`||!(e>=1&&e<4e3))return null;let t=Number(e),n=`${Math.floor(t)}`.split(``),r=``,i=3;for(;i--;)r=`${j[+n.pop()+i*10]||``}${r}`;return`${Array(+n.join(``)+1).join(`M`)}${r}`};e.defaultOptions=n,e.defaultTolerance=t,e.formatQuantity=(e,t)=>{if(typeof e!=`number`&&typeof e!=`string`&&typeof e!=`bigint`)return null;let n=A(t),a=typeof e!=`number`&&typeof e!=`bigint`?T(e,{allowTrailingInvalid:n.allowTrailingInvalid,romanNumerals:n.romanNumerals,bigIntOnOverflow:!0,round:!1}):e;if(typeof a==`number`&&isNaN(a))return null;if(Number(a)===0)return n.zeroFormat;if(n.romanNumerals)return M(a);let o=typeof a==`bigint`?a<0n?-a:a:Math.abs(a),s=typeof o==`bigint`?o:Math.floor(o),c=`${s||``}`,l=typeof o==`bigint`?0:o-s;if(l===0)return`${a}`;let u=null,d=1/0;if(n.tolerance!==!1)for(let[e,t]of i){let r=Math.abs(l-e);if(r<n.tolerance||r===0){if(r===0){u=t;break}r<d&&(u=t,d=r)}}if(u){let e=O(u,n),t=e in r,i=c?n.separator??(t?``:` `):``;return`${a<0?`-`:``}${c}${i}${e}`}return`${a}`},e.formatRomanNumerals=M,e.fractionDecimalMatches=i,e.vulgarToAsciiMap=r});
|
|
2
|
+
typeof window<"u"&&typeof exports=="object"&&(window.FormatQuantity=exports);
|
|
3
|
+
//# sourceMappingURL=format-quantity.umd.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-quantity.umd.min.js","names":["defaultOptions"],"sources":["../src/constants.ts","../node_modules/numeric-quantity/dist/numeric-quantity.mjs","../src/formatQuantity.ts"],"sourcesContent":["import type {\n ResolvedFormatQuantityOptions,\n SimpleFraction,\n Sixteenth,\n VulgarFraction,\n} from './types';\n\n/**\n * Default tolerance used by {@link formatQuantity} when determining if a number\n * is close enough to a fraction value to be considered equivalent.\n */\nexport const defaultTolerance = 0.0075 as const;\n\n/**\n * Default options for {@link formatQuantity}.\n */\nexport const defaultOptions: Readonly<ResolvedFormatQuantityOptions> = Object.freeze({\n vulgarFractions: false,\n tolerance: defaultTolerance,\n fractionSlash: false,\n romanNumerals: false,\n zeroFormat: '',\n allowTrailingInvalid: true,\n});\n\n/**\n * Map of vulgar fractions to their traditional ASCII equivalents.\n */\nexport const vulgarToAsciiMap: Readonly<Record<VulgarFraction, SimpleFraction>> = Object.freeze({\n '¼': '1/4',\n '½': '1/2',\n '¾': '3/4',\n '⅐': '1/7',\n '⅑': '1/9',\n '⅒': '1/10',\n '⅓': '1/3',\n '⅔': '2/3',\n '⅕': '1/5',\n '⅖': '2/5',\n '⅗': '3/5',\n '⅘': '4/5',\n '⅙': '1/6',\n '⅚': '5/6',\n '⅛': '1/8',\n '⅜': '3/8',\n '⅝': '5/8',\n '⅞': '7/8',\n});\n\n/**\n * Map of \"close enough\" values to the {@link VulgarFraction} or {@link Sixteenth} fraction\n * string matches. The value +/- the `tolerance` option (or {@link defaultTolerance} if not\n * specified) is considered close enough to match the fraction.\n */\nexport const fractionDecimalMatches: readonly (readonly [number, VulgarFraction | Sixteenth])[] =\n Object.freeze(\n (\n [\n [1 / 16, '1/16'],\n [1 / 10, '⅒'],\n [1 / 9, '⅑'],\n [1 / 8, '⅛'],\n [1 / 7, '⅐'],\n [1 / 6, '⅙'],\n [3 / 16, '3/16'],\n [1 / 5, '⅕'],\n [1 / 4, '¼'],\n [5 / 16, '5/16'],\n [1 / 3, '⅓'],\n [3 / 8, '⅜'],\n [2 / 5, '⅖'],\n [7 / 16, '7/16'],\n [1 / 2, '½'],\n [9 / 16, '9/16'],\n [3 / 5, '⅗'],\n [5 / 8, '⅝'],\n [2 / 3, '⅔'],\n [11 / 16, '11/16'],\n [3 / 4, '¾'],\n [4 / 5, '⅘'],\n [13 / 16, '13/16'],\n [5 / 6, '⅚'],\n [7 / 8, '⅞'],\n [15 / 16, '15/16'],\n ] satisfies [number, VulgarFraction | Sixteenth][]\n ).map(entry => Object.freeze(entry))\n );\n","//#region src/constants.ts\n/**\n* Unicode decimal digit block start code points.\n* Each block contains 10 contiguous digits (0-9).\n* This list covers all \\p{Nd} (Decimal_Number) blocks through Unicode 17.0.\n* The drift test in index.test.ts validates completeness against the JS engine.\n*/\nconst decimalDigitBlockStarts = [\n\t48,\n\t1632,\n\t1776,\n\t1984,\n\t2406,\n\t2534,\n\t2662,\n\t2790,\n\t2918,\n\t3046,\n\t3174,\n\t3302,\n\t3430,\n\t3558,\n\t3664,\n\t3792,\n\t3872,\n\t4160,\n\t4240,\n\t6112,\n\t6160,\n\t6470,\n\t6608,\n\t6784,\n\t6800,\n\t6992,\n\t7088,\n\t7232,\n\t7248,\n\t42528,\n\t43216,\n\t43264,\n\t43472,\n\t43504,\n\t43600,\n\t44016,\n\t65296,\n\t66720,\n\t68912,\n\t68928,\n\t69734,\n\t69872,\n\t69942,\n\t70096,\n\t70384,\n\t70736,\n\t70864,\n\t71248,\n\t71360,\n\t71376,\n\t71386,\n\t71472,\n\t71904,\n\t72016,\n\t72688,\n\t72784,\n\t73040,\n\t73120,\n\t73184,\n\t73552,\n\t90416,\n\t92768,\n\t92864,\n\t93008,\n\t93552,\n\t118e3,\n\t120782,\n\t120792,\n\t120802,\n\t120812,\n\t120822,\n\t123200,\n\t123632,\n\t124144,\n\t124401,\n\t125264,\n\t130032\n];\n/**\n* Normalizes non-ASCII decimal digits to ASCII digits.\n* Converts characters from Unicode decimal digit blocks (e.g., Arabic-Indic,\n* Devanagari, Bengali) to their ASCII equivalents (0-9).\n*\n* All current Unicode \\p{Nd} blocks are included in decimalDigitBlockStarts.\n*/\nconst normalizeDigits = (str) => str.replace(/\\p{Nd}/gu, (ch) => {\n\tconst cp = ch.codePointAt(0);\n\tif (cp <= 57) return ch;\n\tlet lo = 0;\n\tlet hi = decimalDigitBlockStarts.length - 1;\n\twhile (lo < hi) {\n\t\tconst mid = lo + hi + 1 >>> 1;\n\t\tif (decimalDigitBlockStarts[mid] <= cp) lo = mid;\n\t\telse hi = mid - 1;\n\t}\n\treturn String(cp - decimalDigitBlockStarts[lo]);\n});\n/**\n* Map of Unicode superscript and subscript digit code points to ASCII digits.\n*/\nconst superSubDigitToAsciiMap = {\n\t\"⁰\": \"0\",\n\t\"¹\": \"1\",\n\t\"²\": \"2\",\n\t\"³\": \"3\",\n\t\"⁴\": \"4\",\n\t\"⁵\": \"5\",\n\t\"⁶\": \"6\",\n\t\"⁷\": \"7\",\n\t\"⁸\": \"8\",\n\t\"⁹\": \"9\",\n\t\"₀\": \"0\",\n\t\"₁\": \"1\",\n\t\"₂\": \"2\",\n\t\"₃\": \"3\",\n\t\"₄\": \"4\",\n\t\"₅\": \"5\",\n\t\"₆\": \"6\",\n\t\"₇\": \"7\",\n\t\"₈\": \"8\",\n\t\"₉\": \"9\"\n};\n/**\n* Captures Unicode superscript and subscript digits.\n*/\nconst superSubDigitsRegex = /[⁰¹²³⁴⁵⁶⁷⁸⁹₀₁₂₃₄₅₆₇₈₉]/g;\n/**\n* Map of Unicode fraction code points to their ASCII equivalents.\n*/\nconst vulgarFractionToAsciiMap = {\n\t\"¼\": \"1/4\",\n\t\"½\": \"1/2\",\n\t\"¾\": \"3/4\",\n\t\"⅐\": \"1/7\",\n\t\"⅑\": \"1/9\",\n\t\"⅒\": \"1/10\",\n\t\"⅓\": \"1/3\",\n\t\"⅔\": \"2/3\",\n\t\"⅕\": \"1/5\",\n\t\"⅖\": \"2/5\",\n\t\"⅗\": \"3/5\",\n\t\"⅘\": \"4/5\",\n\t\"⅙\": \"1/6\",\n\t\"⅚\": \"5/6\",\n\t\"⅛\": \"1/8\",\n\t\"⅜\": \"3/8\",\n\t\"⅝\": \"5/8\",\n\t\"⅞\": \"7/8\",\n\t\"⅟\": \"1/\"\n};\n/**\n* Captures the individual elements of a numeric string. Commas and underscores are allowed\n* as separators, as long as they appear between digits and are not consecutive.\n*\n* Capture groups:\n*\n* | # | Description | Example(s) |\n* | --- | -------------------------------------------------- | ----------------------------------------------------------------------- |\n* | `0` | entire match | `\"2 1/3\"` from `\"2 1/3\"` |\n* | `1` | sign (`-` or `+`) | `\"-\"` from `\"-2 1/3\"` |\n* | `2` | whole number or numerator | `\"2\"` from `\"2 1/3\"`; `\"1\"` from `\"1/3\"` |\n* | `3` | entire tail: fraction, decimal, and/or exponent | `\" 1/3\"` from `\"2 1/3\"`; `\".23\"` from `\"1.23\"`; `\".5e3\"` from `\"1.5e3\"` |\n* | `4` | exponent, when there is no decimal portion | `\"e3\"` from `\"1e3\"` |\n* | `5` | exponent, when there is a decimal portion | `\"e-3\"` from `\"1.5e-3\"` |\n* | `6` | numerator of a mixed number (incl. leading space) | `\" 2\"` from `\"1 2/3\"` |\n*\n* Groups 4–6 are subgroups of group 3 and are not used directly by\n* {@link numericQuantity}; only groups 1–3 are consumed.\n*\n* _Capture groups 2 and 3 may include comma/underscore separators._\n*\n* @example\n*\n* ```ts\n* numericRegex.exec(\"1\") // [ \"1\", null, \"1\", null, null, null, null ]\n* numericRegex.exec(\"1.23\") // [ \"1.23\", null, \"1\", \".23\", null, null, null ]\n* numericRegex.exec(\"1 2/3\") // [ \"1 2/3\", null, \"1\", \" 2/3\", null, null, \" 2\" ]\n* numericRegex.exec(\"2/3\") // [ \"2/3\", null, \"2\", \"/3\", null, null, null ]\n* numericRegex.exec(\"2 / 3\") // [ \"2 / 3\", null, \"2\", \" / 3\", null, null, null ]\n* numericRegex.exec(\"-2 1/3\") // [ \"-2 1/3\", \"-\", \"2\", \" 1/3\", null, null, \" 1\" ]\n* numericRegex.exec(\"1e3\") // [ \"1e3\", null, \"1\", \"e3\", \"e3\", null, null ]\n* numericRegex.exec(\"1.5e-3\") // [ \"1.5e-3\", null, \"1\", \".5e-3\", null, \"e-3\", null ]\n* numericRegex.exec(\"1,000\") // [ \"1,000\", null, \"1,000\", null, null, null, null ]\n* ```\n*\n* @remarks\n*\n* This pattern and {@link numericRegexWithTrailingInvalid} are maintained as two separate\n* literals and must be kept in sync. They differ _only_ in the tail: `$` here versus\n* `(\\s*[^.\\d/].*)?` there. `src/index.test.ts` asserts that equality.\n*/\nconst 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)*)?$/;\n/**\n* Same as {@link numericRegex}, but allows (and ignores) trailing invalid characters.\n* Capture groups 1–6 are identical to {@link numericRegex}'s; capture group 7 contains the\n* trailing invalid portion.\n*\n* @example\n*\n* ```ts\n* numericRegexWithTrailingInvalid.exec(\"1abc\")\n* // [ \"1abc\", null, \"1\", null, null, null, null, \"abc\" ]\n* numericRegexWithTrailingInvalid.exec(\"1 2/3 xyz\")\n* // [ \"1 2/3 xyz\", null, \"1\", \" 2/3\", null, null, \" 2\", \" xyz\" ]\n* ```\n*\n* @remarks\n*\n* Must be kept in sync with {@link numericRegex} — see that pattern's remarks.\n*/\nconst 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/].*)?/;\n/**\n* Captures any Unicode vulgar fractions.\n*/\nconst vulgarFractionsRegex = /([¼½¾⅐⅑⅒⅓⅔⅕⅖⅗⅘⅙⅚⅛⅜⅝⅞⅟])/g;\n/**\n* Map of Roman numeral sequences to their decimal equivalents.\n*/\nconst romanNumeralValues = {\n\tMMM: 3e3,\n\tMM: 2e3,\n\tM: 1e3,\n\tCM: 900,\n\tDCCC: 800,\n\tDCC: 700,\n\tDC: 600,\n\tD: 500,\n\tCD: 400,\n\tCCC: 300,\n\tCC: 200,\n\tC: 100,\n\tXC: 90,\n\tLXXX: 80,\n\tLXX: 70,\n\tLX: 60,\n\tL: 50,\n\tXL: 40,\n\tXXX: 30,\n\tXX: 20,\n\tXII: 12,\n\tXI: 11,\n\tX: 10,\n\tIX: 9,\n\tVIII: 8,\n\tVII: 7,\n\tVI: 6,\n\tV: 5,\n\tIV: 4,\n\tIII: 3,\n\tII: 2,\n\tI: 1\n};\n/**\n* Map of Unicode Roman numeral code points to their ASCII equivalents.\n*/\nconst romanNumeralUnicodeToAsciiMap = {\n\tⅠ: \"I\",\n\tⅡ: \"II\",\n\tⅢ: \"III\",\n\tⅣ: \"IV\",\n\tⅤ: \"V\",\n\tⅥ: \"VI\",\n\tⅦ: \"VII\",\n\tⅧ: \"VIII\",\n\tⅨ: \"IX\",\n\tⅩ: \"X\",\n\tⅪ: \"XI\",\n\tⅫ: \"XII\",\n\tⅬ: \"L\",\n\tⅭ: \"C\",\n\tⅮ: \"D\",\n\tⅯ: \"M\",\n\tⅰ: \"I\",\n\tⅱ: \"II\",\n\tⅲ: \"III\",\n\tⅳ: \"IV\",\n\tⅴ: \"V\",\n\tⅵ: \"VI\",\n\tⅶ: \"VII\",\n\tⅷ: \"VIII\",\n\tⅸ: \"IX\",\n\tⅹ: \"X\",\n\tⅺ: \"XI\",\n\tⅻ: \"XII\",\n\tⅼ: \"L\",\n\tⅽ: \"C\",\n\tⅾ: \"D\",\n\tⅿ: \"M\"\n};\n/**\n* Captures all Unicode Roman numeral code points.\n*/\nconst romanNumeralUnicodeRegex = /([ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿ])/gi;\n/**\n* Captures a valid Roman numeral sequence.\n*\n* Capture groups:\n*\n* | # | Description | Example |\n* | --- | --------------- | ------------------------ |\n* | `0` | Entire string | \"MCCXIV\" from \"MCCXIV\" |\n* | `1` | Thousands | \"M\" from \"MCCXIV\" |\n* | `2` | Hundreds | \"CC\" from \"MCCXIV\" |\n* | `3` | Tens | \"X\" from \"MCCXIV\" |\n* | `4` | Ones | \"IV\" from \"MCCXIV\" |\n*\n* @example\n*\n* ```ts\n* romanNumeralRegex.exec(\"M\") // [ \"M\", \"M\", \"\", \"\", \"\" ]\n* romanNumeralRegex.exec(\"XII\") // [ \"XII\", \"\", \"\", \"X\", \"II\" ]\n* romanNumeralRegex.exec(\"MCCXIV\") // [ \"MCCXIV\", \"M\", \"CC\", \"X\", \"IV\" ]\n* ```\n*/\nconst romanNumeralRegex = /^(?=[MDCLXVI])(M{0,3})(C[MD]|D?C{0,3})(X[CL]|L?X{0,3})(I[XV]|V?I{0,3})$/i;\n/**\n* Default options for {@link numericQuantity}.\n*/\nconst defaultOptions = {\n\tround: 3,\n\tallowTrailingInvalid: false,\n\tromanNumerals: false,\n\tbigIntOnOverflow: false,\n\tdecimalSeparator: \".\",\n\tallowCurrency: false,\n\tpercentage: false,\n\tverbose: false\n};\n//#endregion\n//#region src/parseRomanNumerals.ts\n/**\n* Converts a string of Roman numerals to a number, like `parseInt`\n* for Roman numerals. Uses modern, strict rules (only 1 to 3999).\n*\n* The string can include ASCII representations of Roman numerals\n* or Unicode Roman numeral code points (`U+2160` through `U+217F`).\n*/\nconst parseRomanNumerals = (romanNumerals) => {\n\tconst normalized = romanNumerals.replace(romanNumeralUnicodeRegex, (_m, rn) => romanNumeralUnicodeToAsciiMap[rn]).toUpperCase();\n\tconst regexResult = romanNumeralRegex.exec(normalized);\n\tif (!regexResult) return NaN;\n\tconst [, thousands, hundreds, tens, ones] = regexResult;\n\treturn (romanNumeralValues[thousands] ?? 0) + (romanNumeralValues[hundreds] ?? 0) + (romanNumeralValues[tens] ?? 0) + (romanNumeralValues[ones] ?? 0);\n};\n//#endregion\n//#region src/numericQuantity.ts\nconst leadingSlashRegex = /^\\s*\\//;\nconst currencyPrefixRegex = /^([-+]?)\\s*(\\p{Sc}+)\\s*/u;\nconst currencySuffixRegex = /\\s*(\\p{Sc}+)\\s*$/u;\nconst percentageSuffixRegex = /\\s*%$/;\nconst maxSafeBigInt = BigInt(Number.MAX_SAFE_INTEGER);\n/**\n* Upper bound on `10 ** exp` magnitudes evaluated exactly. Anything beyond this\n* overflows/underflows the `number` path to `Infinity`/`0` anyway, so bounding it\n* avoids allocating absurdly large `bigint`s (and `BigInt(Infinity)` throwing).\n*/\nconst maxExactExponent = 1e4;\nconst pow10 = (exp) => 10n ** BigInt(exp);\n/**\n* Evaluates the parsed numeric components as an exact `bigint` rational (magnitude only,\n* sign is applied by the caller) and rounds the result half-up.\n*\n* Returns the rounded `bigint` only if its magnitude exceeds `Number.MAX_SAFE_INTEGER`;\n* otherwise returns `undefined`, meaning \"no overflow, use the `number` path\".\n*\n* @param group1 - Whole number or numerator (separators already stripped).\n* @param group2 - Decimal/exponent/fraction tail, if any.\n* @param divideBy100 - Whether a percentage suffix was stripped.\n*/\nconst toRoundedBigInt = (group1, group2, divideBy100) => {\n\tlet numerator;\n\tlet denominator = 1n;\n\tif (!group2) numerator = BigInt(group1);\n\telse if (group2.startsWith(\".\") || group2.startsWith(\"e\") || group2.startsWith(\"E\")) {\n\t\tconst expIndex = group2.search(/[eE]/);\n\t\tconst exponent = expIndex === -1 ? 0 : parseInt(group2.slice(expIndex + 1));\n\t\tif (!Number.isFinite(exponent) || Math.abs(exponent) > maxExactExponent) return void 0;\n\t\tconst fractionDigits = (expIndex === -1 ? group2 : group2.slice(0, expIndex)).slice(1);\n\t\tnumerator = BigInt(`${group1}${fractionDigits}`);\n\t\tif (fractionDigits) denominator = pow10(fractionDigits.length);\n\t\tif (exponent > 0) numerator *= pow10(exponent);\n\t\telse if (exponent < 0) denominator *= pow10(-exponent);\n\t} else if (leadingSlashRegex.test(group2)) {\n\t\tnumerator = BigInt(group1);\n\t\tdenominator = BigInt(group2.replace(\"/\", \"\").trim());\n\t} else {\n\t\tconst [n, d] = group2.split(\"/\");\n\t\tdenominator = BigInt(d.trim());\n\t\tnumerator = BigInt(group1) * denominator + BigInt(n.trim());\n\t}\n\tif (divideBy100) denominator *= 100n;\n\tif (denominator === 0n) return void 0;\n\tconst rounded = (2n * numerator + denominator) / (2n * denominator);\n\treturn rounded > maxSafeBigInt ? rounded : void 0;\n};\nfunction numericQuantity(quantity, options = defaultOptions) {\n\tvar _regexResult$;\n\tconst opts = {\n\t\t...defaultOptions,\n\t\t...options\n\t};\n\tlet originalInput;\n\tif (typeof quantity === \"string\") originalInput = quantity;\n\telse try {\n\t\toriginalInput = String(quantity);\n\t} catch {\n\t\toriginalInput = \"\";\n\t}\n\tlet currencyPrefix;\n\tlet currencySuffix;\n\tlet percentageSuffix;\n\tlet trailingInvalid;\n\tlet parsedSign;\n\tlet parsedWhole;\n\tlet parsedNumerator;\n\tlet parsedDenominator;\n\tconst buildVerboseResult = (value) => {\n\t\tconst result = {\n\t\t\tvalue,\n\t\t\tinput: originalInput\n\t\t};\n\t\tif (currencyPrefix) result.currencyPrefix = currencyPrefix;\n\t\tif (currencySuffix) result.currencySuffix = currencySuffix;\n\t\tif (percentageSuffix) result.percentageSuffix = percentageSuffix;\n\t\tif (trailingInvalid) result.trailingInvalid = trailingInvalid;\n\t\tif (parsedSign) result.sign = parsedSign;\n\t\tif (parsedWhole !== void 0) result.whole = parsedWhole;\n\t\tif (parsedNumerator !== void 0) result.numerator = parsedNumerator;\n\t\tif (parsedDenominator !== void 0) result.denominator = parsedDenominator;\n\t\treturn result;\n\t};\n\tconst returnValue = (value) => opts.verbose ? buildVerboseResult(value) : value;\n\t/**\n\t* Divides by 100 if a percentage suffix was stripped. Exact scaling, no rounding:\n\t* `round` applies to the quantity as written, before this division.\n\t*/\n\tconst applyPercentage = (value) => percentageSuffix && opts.percentage !== \"number\" ? value / 100 : value;\n\tif (typeof quantity === \"symbol\") return returnValue(NaN);\n\tif (typeof quantity === \"number\" || typeof quantity === \"bigint\") return returnValue(quantity);\n\tlet finalResult = NaN;\n\tlet workingString = originalInput;\n\tlet affixStripped = true;\n\twhile (affixStripped) {\n\t\taffixStripped = false;\n\t\tif (opts.allowCurrency) {\n\t\t\tconst prefixMatch = currencyPrefixRegex.exec(workingString);\n\t\t\tif (prefixMatch === null || prefixMatch === void 0 ? void 0 : prefixMatch[2]) {\n\t\t\t\tcurrencyPrefix = (currencyPrefix ?? \"\") + prefixMatch[2];\n\t\t\t\tworkingString = (prefixMatch[1] || \"\") + workingString.slice(prefixMatch[0].length);\n\t\t\t\taffixStripped = true;\n\t\t\t}\n\t\t\tconst suffixMatch = currencySuffixRegex.exec(workingString);\n\t\t\tif (suffixMatch) {\n\t\t\t\tcurrencySuffix = suffixMatch[1] + (currencySuffix ?? \"\");\n\t\t\t\tworkingString = workingString.slice(0, -suffixMatch[0].length);\n\t\t\t\taffixStripped = true;\n\t\t\t}\n\t\t}\n\t\tif (!percentageSuffix && opts.percentage) {\n\t\t\tconst pctMatch = percentageSuffixRegex.exec(workingString);\n\t\t\tif (pctMatch) {\n\t\t\t\tpercentageSuffix = true;\n\t\t\t\tworkingString = workingString.slice(0, -pctMatch[0].length);\n\t\t\t\taffixStripped = true;\n\t\t\t}\n\t\t}\n\t}\n\tconst quantityAsString = normalizeDigits(workingString.replace(vulgarFractionsRegex, (_m, vf) => ` ${vulgarFractionToAsciiMap[vf]}`).replace(superSubDigitsRegex, (ch) => superSubDigitToAsciiMap[ch]).replace(\"⁄\", \"/\").trim());\n\tif (quantityAsString.length === 0) return returnValue(NaN);\n\tlet normalizedString = quantityAsString;\n\tif (opts.decimalSeparator === \",\") {\n\t\tconst commaCount = (quantityAsString.match(/,/g) || []).length;\n\t\tif (commaCount === 1) normalizedString = quantityAsString.replaceAll(\".\", \"_\").replace(\",\", \".\");\n\t\telse if (commaCount > 1) {\n\t\t\tconst firstCommaIndex = quantityAsString.indexOf(\",\");\n\t\t\tconst secondCommaIndex = quantityAsString.indexOf(\",\", firstCommaIndex + 1);\n\t\t\tnormalizedString = quantityAsString.substring(0, secondCommaIndex).replaceAll(\".\", \"_\").replace(\",\", \".\");\n\t\t} else normalizedString = quantityAsString.replaceAll(\".\", \"_\");\n\t}\n\tconst regexResult = numericRegexWithTrailingInvalid.exec(normalizedString);\n\tif (!regexResult) {\n\t\tif (!opts.romanNumerals) return returnValue(NaN);\n\t\treturn returnValue(applyPercentage(parseRomanNumerals(quantityAsString)));\n\t}\n\tconst consumedLength = regexResult[0].length - (((_regexResult$ = regexResult[7]) === null || _regexResult$ === void 0 ? void 0 : _regexResult$.length) ?? 0);\n\tconst rawTrailing = quantityAsString.slice(consumedLength).trim();\n\tif (rawTrailing) {\n\t\ttrailingInvalid = rawTrailing;\n\t\tif (!opts.allowTrailingInvalid) return returnValue(NaN);\n\t}\n\tconst [, sign, rawGroup1, rawGroup2] = regexResult;\n\tif (sign === \"-\" || sign === \"+\") parsedSign = sign;\n\tconst numberGroup1 = rawGroup1.replaceAll(\",\", \"\").replaceAll(\"_\", \"\");\n\tconst numberGroup2 = rawGroup2 === null || rawGroup2 === void 0 ? void 0 : rawGroup2.replaceAll(\",\", \"\").replaceAll(\"_\", \"\");\n\tif (opts.bigIntOnOverflow) {\n\t\tconst asBigInt = toRoundedBigInt(numberGroup1, numberGroup2, !!percentageSuffix && opts.percentage !== \"number\");\n\t\tif (asBigInt !== void 0) return returnValue(sign === \"-\" ? -asBigInt : asBigInt);\n\t}\n\tfinalResult = !numberGroup1 && numberGroup2 && numberGroup2.startsWith(\".\") ? 0 : parseInt(numberGroup1);\n\tif (!numberGroup2) {\n\t\tfinalResult = sign === \"-\" ? finalResult * -1 : finalResult;\n\t\treturn returnValue(applyPercentage(finalResult));\n\t}\n\tconst roundTo = typeof opts.round === \"number\" && Number.isFinite(opts.round) ? Math.floor(Math.max(0, opts.round)) : false;\n\tconst roundingFactorRaw = roundTo === false ? NaN : 10 ** roundTo;\n\tconst roundingFactor = Number.isFinite(roundingFactorRaw) ? roundingFactorRaw : NaN;\n\t/** Rounds to `roundTo` decimal places, falling back to `value` if the scaling overflows. */\n\tconst round = (value, scaled) => {\n\t\tconst result = Math.round(scaled) / roundingFactor;\n\t\treturn Number.isFinite(result) || !Number.isFinite(value) ? result : value;\n\t};\n\tif (numberGroup2.startsWith(\".\") || numberGroup2.startsWith(\"e\") || numberGroup2.startsWith(\"E\")) {\n\t\tconst decimalValue = parseFloat(`${finalResult}${numberGroup2}`);\n\t\tfinalResult = isNaN(roundingFactor) ? decimalValue : round(decimalValue, decimalValue * roundingFactor);\n\t} else if (leadingSlashRegex.test(numberGroup2)) {\n\t\tconst numerator = parseInt(numberGroup1);\n\t\tconst denominator = parseInt(numberGroup2.replace(\"/\", \"\"));\n\t\tparsedNumerator = numerator;\n\t\tparsedDenominator = denominator;\n\t\tfinalResult = isNaN(roundingFactor) ? numerator / denominator : round(numerator / denominator, numerator * roundingFactor / denominator);\n\t} else {\n\t\tconst [numerator, denominator] = numberGroup2.split(\"/\").map((v) => parseInt(v));\n\t\tparsedWhole = finalResult;\n\t\tparsedNumerator = numerator;\n\t\tparsedDenominator = denominator;\n\t\tfinalResult += isNaN(roundingFactor) ? numerator / denominator : round(numerator / denominator, numerator * roundingFactor / denominator);\n\t}\n\tfinalResult = sign === \"-\" ? finalResult * -1 : finalResult;\n\treturn returnValue(applyPercentage(finalResult));\n}\n//#endregion\n//#region src/isNumericQuantity.ts\n/**\n* Checks if a value represents a valid numeric quantity.\n*\n* Returns `true` if the value can be parsed as a number, `false` otherwise.\n* Accepts the same options as `numericQuantity`.\n*/\nconst isNumericQuantity = (quantity, options) => {\n\tconst result = numericQuantity(quantity, {\n\t\t...options,\n\t\tverbose: false\n\t});\n\treturn typeof result === \"bigint\" || !isNaN(result);\n};\n//#endregion\nexport { defaultOptions, isNumericQuantity, normalizeDigits, numericQuantity, numericRegex, numericRegexWithTrailingInvalid, parseRomanNumerals, romanNumeralRegex, romanNumeralUnicodeRegex, romanNumeralUnicodeToAsciiMap, romanNumeralValues, superSubDigitToAsciiMap, superSubDigitsRegex, vulgarFractionToAsciiMap, vulgarFractionsRegex };\n\n//# sourceMappingURL=numeric-quantity.mjs.map","import { numericQuantity } from 'numeric-quantity';\nimport { defaultOptions, fractionDecimalMatches, vulgarToAsciiMap } from './constants';\nimport type {\n FormatQuantity,\n ResolvedFormatQuantityOptions,\n SimpleFraction,\n Sixteenth,\n VulgarFraction,\n} from './types';\n\nconst superscriptDigits = '⁰¹²³⁴⁵⁶⁷⁸⁹';\nconst subscriptDigits = '₀₁₂₃₄₅₆₇₈₉';\n\n// oxlint-disable-next-line typescript/no-misused-spread\nconst toSuperscript = (s: string) => [...s].map(c => superscriptDigits[+c]).join('');\n// oxlint-disable-next-line typescript/no-misused-spread\nconst toSubscript = (s: string) => [...s].map(c => subscriptDigits[+c]).join('');\n\n/**\n * Applies the `vulgarFractions` or `fractionSlash` options as necessary.\n */\nconst getFraction = (\n vulgarFractionOrSixteenth: VulgarFraction | Sixteenth,\n { fractionSlash, vulgarFractions }: ResolvedFormatQuantityOptions\n) => {\n if (vulgarFractions) {\n return vulgarFractionOrSixteenth;\n }\n\n const plainFraction: SimpleFraction =\n vulgarToAsciiMap[vulgarFractionOrSixteenth as VulgarFraction] ?? vulgarFractionOrSixteenth;\n\n if (fractionSlash) {\n const [num, den] = plainFraction.split('/');\n return `${toSuperscript(num)}⁄${toSubscript(den)}`;\n }\n\n return plainFraction;\n};\n\n/**\n * Only `false` (matching disabled) or a non-negative number is a valid\n * `tolerance`. Everything else—negative numbers, `NaN`, non-numbers,\n * `null`, `undefined`—resolves to {@link defaultTolerance}.\n */\nconst isValidTolerance = (tolerance: unknown): tolerance is number | false =>\n tolerance === false || (typeof tolerance === 'number' && tolerance >= 0);\n\n/**\n * Merges options object with default options, converting boolean to object if necessary.\n */\nconst normalizeOptions = (\n options: Parameters<FormatQuantity>[1]\n): ResolvedFormatQuantityOptions => {\n const opts: ResolvedFormatQuantityOptions = {\n ...defaultOptions,\n ...(typeof options === 'boolean'\n ? { vulgarFractions: options }\n : typeof options === 'object' && options !== null\n ? options\n : {}),\n };\n\n if (!isValidTolerance(opts.tolerance)) {\n opts.tolerance = defaultOptions.tolerance;\n }\n\n if (typeof opts.zeroFormat !== 'string') {\n opts.zeroFormat = defaultOptions.zeroFormat;\n }\n\n if (opts.allowTrailingInvalid !== false) {\n opts.allowTrailingInvalid = true;\n }\n\n return opts;\n};\n\n// oxfmt-ignore\nconst romanNumeralsByPlace = [\n '', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM',\n '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC',\n '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX',\n] as const;\n\n/**\n * Formats a number or bigint as Roman numerals. The number must be between\n * 1 and 3999, inclusive; any other value—including non-numbers,\n * `NaN`, and non-finite numbers—yields `null`.\n */\nexport const formatRomanNumerals = (quantity: number | bigint): string | null => {\n if (\n (typeof quantity !== 'number' && typeof quantity !== 'bigint') ||\n !(quantity >= 1 && quantity < 4000)\n ) {\n return null;\n }\n\n const qty = Number(quantity);\n\n const floored = Math.floor(qty);\n\n const digits = `${floored}`.split('');\n let roman = '';\n let i = 3;\n while (i--) {\n roman = `${romanNumeralsByPlace[+digits.pop()! + i * 10] || ''}${roman}`;\n }\n\n return `${Array(+digits.join('') + 1).join('M')}${roman}`;\n};\n\n/**\n * Formats a number (or string that appears to be a number)\n * as one would see it written in imperial measurements, e.g.\n * \"1 1/2\" instead of \"1.5\". To use vulgar fraction characters\n * like \"½\", pass `true` as the second argument. For other options\n * see {@link FormatQuantityOptions}.\n */\nexport const formatQuantity: FormatQuantity = (qty, options) => {\n // Only numbers, bigints, and strings are accepted. Anything else (objects, booleans,\n // nullish, arrays like `[1]` that would coerce to a numeric string) is\n // rejected up front so off-type inputs behave consistently.\n if (typeof qty !== 'number' && typeof qty !== 'string' && typeof qty !== 'bigint') {\n return null;\n }\n\n const opts = normalizeOptions(options);\n\n const qtyAsNumber =\n typeof qty !== 'number' && typeof qty !== 'bigint'\n ? numericQuantity(qty, {\n allowTrailingInvalid: opts.allowTrailingInvalid,\n romanNumerals: opts.romanNumerals,\n bigIntOnOverflow: true,\n round: false,\n })\n : qty;\n\n // Return `null` if input is not number-like.\n if (typeof qtyAsNumber === 'number' && isNaN(qtyAsNumber)) {\n return null;\n }\n\n // Return empty string (or configured `zeroFormat`) if the value is zero.\n if (Number(qtyAsNumber) === 0) {\n return opts.zeroFormat;\n }\n\n if (opts.romanNumerals) {\n return formatRomanNumerals(qtyAsNumber);\n }\n\n const absoluteValue =\n typeof qtyAsNumber === 'bigint'\n ? qtyAsNumber < 0n\n ? -qtyAsNumber\n : qtyAsNumber\n : Math.abs(qtyAsNumber);\n const flooredAbsVal =\n typeof absoluteValue === 'bigint' ? absoluteValue : Math.floor(absoluteValue);\n const wholeNumberStr = `${flooredAbsVal || ''}`;\n const decimalValue =\n typeof absoluteValue === 'bigint' ? 0 : absoluteValue - (flooredAbsVal as number);\n\n // For integers just return the given value as a string.\n if (decimalValue === 0) {\n return `${qtyAsNumber}`;\n }\n\n let closestMatch: VulgarFraction | Sixteenth | null = null;\n let closestMatchDiff = Infinity;\n // `tolerance: false` disables fraction matching entirely.\n if (opts.tolerance !== false) {\n for (const [num, vf] of fractionDecimalMatches) {\n const diff = Math.abs(decimalValue - num);\n // `diff === 0` keeps exact quotients matching even at `tolerance: 0`.\n if (diff < opts.tolerance || diff === 0) {\n if (diff === 0) {\n closestMatch = vf;\n break;\n }\n if (diff < closestMatchDiff) {\n closestMatch = vf;\n closestMatchDiff = diff;\n }\n }\n }\n }\n\n if (closestMatch) {\n const fraction = getFraction(closestMatch, opts);\n const isVulgar = fraction in vulgarToAsciiMap;\n const sep = wholeNumberStr ? (opts.separator ?? (isVulgar ? '' : ' ')) : '';\n return `${qtyAsNumber < 0 ? '-' : ''}${wholeNumberStr}${sep}${fraction}`;\n }\n\n return `${qtyAsNumber}`;\n};\n"],"x_google_ignoreList":[1],"mappings":"sRAWA,IAAa,EAAmB,MAKnB,EAA0D,OAAO,OAAO,CACnF,gBAAiB,GACjB,UAAW,EACX,cAAe,GACf,cAAe,G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,KACA,KACA,KACA,KACA,KACA,KACA,KACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,MACD,EAQM,EAAmB,GAAQ,EAAI,QAAQ,WAAa,GAAO,CAChE,IAAM,EAAK,EAAG,YAAY,CAAC,EAC3B,GAAI,GAAM,GAAI,OAAO,EACrB,IAAI,EAAK,EACL,EAAK,EAAwB,OAAS,EAC1C,KAAO,EAAK,GAAI,CACf,IAAM,EAAM,EAAK,EAAK,IAAM,EACxB,EAAwB,IAAQ,EAAI,EAAK,EACxC,EAAK,EAAM,CACjB,CACA,OAAO,OAAO,EAAK,EAAwB,EAAG,CAC/C,CAAC,EAIK,EAA0B,CAC/B,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,GACN,EAIM,EAAsB,0BAItB,EAA2B,CAChC,IAAK,MACL,IAAK,MACL,IAAK,MACL,IAAK,MACL,IAAK,MACL,IAAK,OACL,IAAK,MACL,IAAK,MACL,IAAK,MACL,IAAK,MACL,IAAK,MACL,IAAK,MACL,IAAK,MACL,IAAK,MACL,IAAK,MACL,IAAK,MACL,IAAK,MACL,IAAK,MACL,IAAK,IACN,EA6DM,EAAkC,+MAIlC,EAAuB,2BAIvB,EAAqB,CAC1B,IAAK,IACL,GAAI,IACJ,EAAG,IACH,GAAI,IACJ,KAAM,IACN,IAAK,IACL,GAAI,IACJ,EAAG,IACH,GAAI,IACJ,IAAK,IACL,GA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,GAChE,CAEA,MAAO,GAAG,GACZ"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "3.2.0",
|
|
3
|
+
"name": "format-quantity",
|
|
4
|
+
"author": "Jake Boone <jakeboone02@gmail.com>",
|
|
5
|
+
"description": "Number formatter for imperial measurements with support for vulgar fractions",
|
|
6
|
+
"type": "commonjs",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"main": "./dist/cjs/index.js",
|
|
11
|
+
"module": "./dist/format-quantity.legacy-esm.js",
|
|
12
|
+
"exports": {
|
|
13
|
+
"./package.json": "./package.json",
|
|
14
|
+
".": {
|
|
15
|
+
"import": {
|
|
16
|
+
"types": "./dist/format-quantity.d.mts",
|
|
17
|
+
"default": "./dist/format-quantity.mjs"
|
|
18
|
+
},
|
|
19
|
+
"require": {
|
|
20
|
+
"types": "./dist/cjs/index.d.ts",
|
|
21
|
+
"default": "./dist/cjs/index.js"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"types": "./dist/format-quantity.legacy-esm.d.ts",
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"unpkg": "./dist/format-quantity.umd.min.js",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"keywords": [
|
|
30
|
+
"recipe",
|
|
31
|
+
"ingredient",
|
|
32
|
+
"quantity",
|
|
33
|
+
"number",
|
|
34
|
+
"format",
|
|
35
|
+
"string",
|
|
36
|
+
"fractions",
|
|
37
|
+
"imperial",
|
|
38
|
+
"roman",
|
|
39
|
+
"numerals"
|
|
40
|
+
],
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/jakeboone02/format-quantity/issues"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/jakeboone02/format-quantity",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "git+https://github.com/jakeboone02/format-quantity.git"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"start": "bun --hot main.html",
|
|
51
|
+
"build": "bun --bun x tsdown",
|
|
52
|
+
"docs:plugins": "bun build ./node_modules/typedoc-plugin-katex/src/index.tsx --outdir=. --target=node --external=typedoc --entry-naming=typedoc-plugin-katex.mjs",
|
|
53
|
+
"docs": "typedoc",
|
|
54
|
+
"test": "bun test",
|
|
55
|
+
"watch": "bun test --watch",
|
|
56
|
+
"lint": "bunx oxlint",
|
|
57
|
+
"publish:npm": "np",
|
|
58
|
+
"fmt": "oxfmt"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@types/bun": "^1.4.0",
|
|
62
|
+
"@types/node": "^26.4.0",
|
|
63
|
+
"@types/web": "^0.0.354",
|
|
64
|
+
"@typescript/native-preview": "^7.0.0-dev.20260707.2",
|
|
65
|
+
"np": "^12.0.1",
|
|
66
|
+
"oxfmt": "^0.65.0",
|
|
67
|
+
"oxlint": "^1.80.0",
|
|
68
|
+
"oxlint-tsgolint": "^7.0.2001",
|
|
69
|
+
"pkg-pr-new": "^0.0.88",
|
|
70
|
+
"tsdown": "^0.22.14",
|
|
71
|
+
"typedoc": "^0.28.20",
|
|
72
|
+
"typedoc-plugin-katex": "^0.1.2",
|
|
73
|
+
"typescript": "^6.0.3"
|
|
74
|
+
},
|
|
75
|
+
"engines": {
|
|
76
|
+
"node": ">=20"
|
|
77
|
+
},
|
|
78
|
+
"dependencies": {
|
|
79
|
+
"numeric-quantity": "^3.3.1"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Copyright (c) 2023, Oath Inc.
|
|
2
|
+
|
|
3
|
+
Licensed under the terms of the New BSD license. See below for terms.
|
|
4
|
+
|
|
5
|
+
Redistribution and use of this software in source and binary forms,
|
|
6
|
+
with or without modification, are permitted provided that the following
|
|
7
|
+
conditions are met:
|
|
8
|
+
|
|
9
|
+
- Redistributions of source code must retain the above
|
|
10
|
+
copyright notice, this list of conditions and the
|
|
11
|
+
following disclaimer.
|
|
12
|
+
|
|
13
|
+
- Redistributions in binary form must reproduce the above
|
|
14
|
+
copyright notice, this list of conditions and the
|
|
15
|
+
following disclaimer in the documentation and/or other
|
|
16
|
+
materials provided with the distribution.
|
|
17
|
+
|
|
18
|
+
- Neither the name of Oath Inc. nor the names of its
|
|
19
|
+
contributors may be used to endorse or promote products
|
|
20
|
+
derived from this software without specific prior
|
|
21
|
+
written permission of Oath Inc.
|
|
22
|
+
|
|
23
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
24
|
+
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
25
|
+
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
26
|
+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
27
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
28
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
29
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
30
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
31
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
32
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
33
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { MessageFormatElement, ParserOptions, parse } from "@formatjs/icu-messageformat-parser";
|
|
2
|
+
//#region packages/ecma402-abstract/types/number.d.ts
|
|
3
|
+
type NumberFormatNotation = "standard" | "scientific" | "engineering" | "compact";
|
|
4
|
+
type RoundingPriorityType = "auto" | "morePrecision" | "lessPrecision";
|
|
5
|
+
type RoundingModeType = "ceil" | "floor" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven";
|
|
6
|
+
type UseGroupingType = "min2" | "auto" | "always" | boolean;
|
|
7
|
+
interface NumberFormatDigitOptions {
|
|
8
|
+
minimumIntegerDigits?: number;
|
|
9
|
+
minimumSignificantDigits?: number;
|
|
10
|
+
maximumSignificantDigits?: number;
|
|
11
|
+
minimumFractionDigits?: number;
|
|
12
|
+
maximumFractionDigits?: number;
|
|
13
|
+
roundingPriority?: RoundingPriorityType;
|
|
14
|
+
roundingIncrement?: number;
|
|
15
|
+
roundingMode?: RoundingModeType;
|
|
16
|
+
trailingZeroDisplay?: TrailingZeroDisplay;
|
|
17
|
+
}
|
|
18
|
+
type NumberFormatOptionsLocaleMatcher = "lookup" | "best fit";
|
|
19
|
+
type NumberFormatOptionsStyle = "decimal" | "percent" | "currency" | "unit";
|
|
20
|
+
type NumberFormatOptionsCompactDisplay = "short" | "long";
|
|
21
|
+
type NumberFormatOptionsCurrencyDisplay = "symbol" | "code" | "name" | "narrowSymbol";
|
|
22
|
+
type NumberFormatOptionsCurrencySign = "standard" | "accounting";
|
|
23
|
+
type NumberFormatOptionsNotation = NumberFormatNotation;
|
|
24
|
+
type NumberFormatOptionsSignDisplay = "auto" | "always" | "never" | "exceptZero" | "negative";
|
|
25
|
+
type NumberFormatOptionsUnitDisplay = "long" | "short" | "narrow";
|
|
26
|
+
type TrailingZeroDisplay = "auto" | "stripIfInteger";
|
|
27
|
+
type NumberFormatOptions = Omit<Intl.NumberFormatOptions, "signDisplay" | "useGrouping"> & NumberFormatDigitOptions & {
|
|
28
|
+
localeMatcher?: NumberFormatOptionsLocaleMatcher;
|
|
29
|
+
style?: NumberFormatOptionsStyle;
|
|
30
|
+
compactDisplay?: NumberFormatOptionsCompactDisplay;
|
|
31
|
+
currencyDisplay?: NumberFormatOptionsCurrencyDisplay;
|
|
32
|
+
currencySign?: NumberFormatOptionsCurrencySign;
|
|
33
|
+
notation?: NumberFormatOptionsNotation;
|
|
34
|
+
signDisplay?: NumberFormatOptionsSignDisplay;
|
|
35
|
+
unit?: string;
|
|
36
|
+
unitDisplay?: NumberFormatOptionsUnitDisplay;
|
|
37
|
+
numberingSystem?: string;
|
|
38
|
+
trailingZeroDisplay?: TrailingZeroDisplay;
|
|
39
|
+
roundingPriority?: RoundingPriorityType;
|
|
40
|
+
roundingIncrement?: number;
|
|
41
|
+
roundingMode?: RoundingModeType;
|
|
42
|
+
useGrouping?: UseGroupingType;
|
|
43
|
+
};
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region packages/intl-messageformat/formatters.d.ts
|
|
46
|
+
declare global {
|
|
47
|
+
namespace FormatjsIntl {
|
|
48
|
+
interface Message {}
|
|
49
|
+
interface IntlConfig {}
|
|
50
|
+
interface Formats {}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
type Format<Source = string> = Source extends keyof FormatjsIntl.Formats ? FormatjsIntl.Formats[Source] : string;
|
|
54
|
+
export interface Formats {
|
|
55
|
+
number: Record<Format<"number">, NumberFormatOptions>;
|
|
56
|
+
date: Record<Format<"date">, Intl.DateTimeFormatOptions>;
|
|
57
|
+
time: Record<Format<"time">, Intl.DateTimeFormatOptions>;
|
|
58
|
+
}
|
|
59
|
+
export interface FormatterCache {
|
|
60
|
+
number: Record<string, NumberFormatOptions>;
|
|
61
|
+
dateTime: Record<string, Intl.DateTimeFormat>;
|
|
62
|
+
pluralRules: Record<string, Intl.PluralRules>;
|
|
63
|
+
}
|
|
64
|
+
export interface Formatters {
|
|
65
|
+
getNumberFormat(locals?: string | string[], opts?: NumberFormatOptions): Intl.NumberFormat;
|
|
66
|
+
getDateTimeFormat(...args: ConstructorParameters<typeof Intl.DateTimeFormat>): Intl.DateTimeFormat;
|
|
67
|
+
getPluralRules(...args: ConstructorParameters<typeof Intl.PluralRules>): Intl.PluralRules;
|
|
68
|
+
}
|
|
69
|
+
export declare enum PART_TYPE {
|
|
70
|
+
literal = 0,
|
|
71
|
+
object = 1
|
|
72
|
+
}
|
|
73
|
+
export interface LiteralPart {
|
|
74
|
+
type: PART_TYPE.literal;
|
|
75
|
+
value: string;
|
|
76
|
+
}
|
|
77
|
+
export interface ObjectPart<T = any> {
|
|
78
|
+
type: PART_TYPE.object;
|
|
79
|
+
value: T;
|
|
80
|
+
}
|
|
81
|
+
export type MessageFormatPart<T> = LiteralPart | ObjectPart<T>;
|
|
82
|
+
export type PrimitiveType = string | number | bigint | boolean | null | undefined | Date;
|
|
83
|
+
export declare function isFormatXMLElementFn<T>(el: PrimitiveType | T | FormatXMLElementFn<T>): el is FormatXMLElementFn<T>;
|
|
84
|
+
export declare function formatToParts<T>(els: MessageFormatElement[], locales: string | string[], formatters: Formatters, formats: Formats, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>, currentPluralValue?: number, originalMessage?: string): MessageFormatPart<T>[];
|
|
85
|
+
export type FormatXMLElementFn<T, R = string | T | (string | T)[]> = (parts: Array<string | T>) => R;
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region packages/intl-messageformat/message-types.d.ts
|
|
88
|
+
declare const formattedTextBrand: unique symbol;
|
|
89
|
+
/** Formatter-produced text, including fallbacks; not a translation or safety guarantee. */
|
|
90
|
+
type FormattedText = string & {
|
|
91
|
+
readonly [formattedTextBrand]: true;
|
|
92
|
+
};
|
|
93
|
+
declare const messageValues: unique symbol;
|
|
94
|
+
declare const messageTag: unique symbol;
|
|
95
|
+
/** An unformatted ICU argument, before framework-specific rich values are added. */
|
|
96
|
+
type MessageValue = PrimitiveType;
|
|
97
|
+
/** A tag placeholder whose callback type is supplied by the formatter. */
|
|
98
|
+
interface MessageTag {
|
|
99
|
+
readonly [messageTag]: true;
|
|
100
|
+
}
|
|
101
|
+
/** A message contract with no arguments. */
|
|
102
|
+
type NoMessageValues = Record<never, never>;
|
|
103
|
+
type MessageValues = Record<string, MessageValue | MessageTag>;
|
|
104
|
+
/** Type-only argument metadata shared by formatter integrations. */
|
|
105
|
+
interface MessageContract<V extends MessageValues> {
|
|
106
|
+
readonly [messageValues]: V;
|
|
107
|
+
}
|
|
108
|
+
type MessageValuesOf<D extends MessageContract<MessageValues>> = D[typeof messageValues];
|
|
109
|
+
interface UntypedMessageContract {
|
|
110
|
+
readonly [messageValues]?: never;
|
|
111
|
+
}
|
|
112
|
+
type ResolveMessageValues<V extends MessageValues, T, TChunk> = { [K in keyof V]: [V[K]] extends [undefined] ? V[K] : Exclude<V[K], undefined> extends MessageTag ? FormatXMLElementFn<string | TChunk, string | T | Array<string | T>> : MessageValue extends V[K] ? V[K] | T : Extract<V[K], MessageValue>; };
|
|
113
|
+
type MessageKeys<V> = V extends unknown ? keyof V : never;
|
|
114
|
+
type TypedMessageValues<V extends MessageValues, T = string, TChunk = T> = (V extends unknown ? (values: ResolveMessageValues<V, T, TChunk>) => void : never) extends ((values: infer Values) => void) ? Values : never;
|
|
115
|
+
type MessageFormatArguments<V extends MessageValues, T = string, TChunk = T, Extra extends unknown[] = []> = MessageKeys<V> extends never ? [values?: Record<string, never>, ...extra: Extra] : {} extends TypedMessageValues<V, T, TChunk> ? [values?: TypedMessageValues<V, T, TChunk>, ...extra: Extra] : [values: TypedMessageValues<V, T, TChunk>, ...extra: Extra];
|
|
116
|
+
type UntypedMessageFormat = <T = void>(values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>) => string | T | (string | T)[];
|
|
117
|
+
type UntypedMessageFormatToParts = <T>(values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>) => MessageFormatPart<T>[];
|
|
118
|
+
type MessageFormatFunction<V extends MessageValues | undefined> = [V] extends [MessageValues] ? <T = string>(...args: MessageFormatArguments<Extract<V, MessageValues>, T>) => string | T | (string | T)[] : UntypedMessageFormat;
|
|
119
|
+
type MessageFormatToPartsFunction<V extends MessageValues | undefined> = [V] extends [MessageValues] ? <T = string>(...args: MessageFormatArguments<Extract<V, MessageValues>, T>) => MessageFormatPart<T>[] : UntypedMessageFormatToParts;
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region packages/intl-messageformat/core.d.ts
|
|
122
|
+
export interface Options extends Omit<ParserOptions, "locale"> {
|
|
123
|
+
formatters?: Formatters;
|
|
124
|
+
}
|
|
125
|
+
export declare class IntlMessageFormat<V extends MessageValues | undefined = undefined> {
|
|
126
|
+
private readonly ast;
|
|
127
|
+
private readonly locales;
|
|
128
|
+
private readonly resolvedLocale?;
|
|
129
|
+
private readonly formatters;
|
|
130
|
+
private readonly formats;
|
|
131
|
+
private readonly message;
|
|
132
|
+
private readonly formatterCache;
|
|
133
|
+
constructor(message: string | MessageFormatElement[], locales?: string | string[], overrideFormats?: Partial<Formats>, opts?: Options);
|
|
134
|
+
format: MessageFormatFunction<V>;
|
|
135
|
+
formatToParts: MessageFormatToPartsFunction<V>;
|
|
136
|
+
resolvedOptions: () => {
|
|
137
|
+
locale: string;
|
|
138
|
+
};
|
|
139
|
+
getAst: () => MessageFormatElement[];
|
|
140
|
+
private static memoizedDefaultLocale;
|
|
141
|
+
static get defaultLocale(): string;
|
|
142
|
+
static resolveLocale: (locales: string | string[]) => Intl.Locale | undefined;
|
|
143
|
+
static __parse: typeof parse | undefined;
|
|
144
|
+
static formats: Formats;
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region packages/intl-messageformat/error.d.ts
|
|
148
|
+
export declare enum ErrorCode {
|
|
149
|
+
MISSING_VALUE = "MISSING_VALUE",
|
|
150
|
+
INVALID_VALUE = "INVALID_VALUE",
|
|
151
|
+
MISSING_INTL_API = "MISSING_INTL_API"
|
|
152
|
+
}
|
|
153
|
+
export declare class FormatError extends Error {
|
|
154
|
+
readonly code: ErrorCode;
|
|
155
|
+
/**
|
|
156
|
+
* Original message we're trying to format
|
|
157
|
+
* `undefined` if we're only dealing w/ AST
|
|
158
|
+
*
|
|
159
|
+
* @type {(string | undefined)}
|
|
160
|
+
* @memberof FormatError
|
|
161
|
+
*/
|
|
162
|
+
readonly originalMessage: string | undefined;
|
|
163
|
+
constructor(msg: string, code: ErrorCode, originalMessage?: string);
|
|
164
|
+
toString(): string;
|
|
165
|
+
}
|
|
166
|
+
export declare class InvalidValueError extends FormatError {
|
|
167
|
+
constructor(variableId: string, value: any, options: string[], originalMessage?: string);
|
|
168
|
+
}
|
|
169
|
+
export declare class InvalidValueTypeError extends FormatError {
|
|
170
|
+
constructor(value: any, type: string, originalMessage?: string);
|
|
171
|
+
}
|
|
172
|
+
export declare class MissingValueError extends FormatError {
|
|
173
|
+
constructor(variableId: string, originalMessage?: string);
|
|
174
|
+
}
|
|
175
|
+
//#endregion
|
|
176
|
+
export { type FormattedText, IntlMessageFormat as default, type MessageContract, type MessageFormatArguments, type MessageFormatFunction, type MessageFormatToPartsFunction, type MessageTag, type MessageValue, type MessageValues, type MessageValuesOf, type NoMessageValues, type TypedMessageValues, type UntypedMessageContract };
|
|
177
|
+
//# sourceMappingURL=index.d.ts.map
|