yummies 5.4.5 → 5.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.changeset/README.md +8 -0
- package/.changeset/config.json +11 -0
- package/.github/FUNDING.yml +1 -0
- package/.github/workflows/main.yml +34 -0
- package/.github/workflows/version-or-publish.yml +45 -0
- package/.nvmrc +1 -0
- package/.vscode/settings.json +19 -0
- package/CHANGELOG.md +215 -0
- package/CONTRIBUTING.md +8 -0
- package/Makefile +7 -0
- package/assets/logo.png +0 -0
- package/assets/logo.pxz +0 -0
- package/biome.json +3 -0
- package/commitfmt.toml +18 -0
- package/lefthook.yml +14 -0
- package/package.json +3 -389
- package/scripts/post-build.ts +71 -0
- package/src/async.ts +86 -0
- package/src/common.ts +26 -0
- package/src/complex/counter.test.ts +41 -0
- package/src/complex/counter.ts +40 -0
- package/src/complex/global-config.ts +55 -0
- package/src/complex/index.ts +3 -0
- package/src/complex/modules-factory.ts +65 -0
- package/src/cookie.ts +11 -0
- package/src/css.ts +60 -0
- package/src/data.test.ts +99 -0
- package/src/data.ts +65 -0
- package/src/date-time.test.ts +119 -0
- package/src/date-time.ts +236 -0
- package/src/device.ts +42 -0
- package/src/encodings.ts +270 -0
- package/src/errors.ts +40 -0
- package/src/file.ts +25 -0
- package/src/format/_exports.ts +4 -0
- package/{dist/format/constants.js → src/format/constants.ts} +2 -0
- package/{dist/format/index.js → src/format/index.ts} +2 -1
- package/src/format/number.test.ts +16 -0
- package/src/format/number.ts +96 -0
- package/src/format/percent.ts +40 -0
- package/src/format/skip-spaces.ts +4 -0
- package/src/html.ts +238 -0
- package/{dist/id.js → src/id.ts} +16 -6
- package/src/imports.ts +52 -0
- package/src/math.ts +20 -0
- package/src/media.ts +134 -0
- package/src/mobx/apply-observable.ts +20 -0
- package/src/mobx/create-enhanced-atom.ts +28 -0
- package/src/mobx/deep-observable-struct.test.ts +69 -0
- package/src/mobx/deep-observable-struct.ts +69 -0
- package/src/mobx/get-mobx-administration.ts +10 -0
- package/src/mobx/index.ts +5 -0
- package/src/mobx/lazy-observe.ts +59 -0
- package/src/ms.ts +20 -0
- package/src/number.ts +14 -0
- package/src/parser/_exports.ts +3 -0
- package/{dist/parser/index.js → src/parser/index.ts} +2 -1
- package/src/parser/number.test.ts +38 -0
- package/src/parser/number.ts +73 -0
- package/src/parser/percent.ts +11 -0
- package/src/parser/string.ts +29 -0
- package/src/price.ts +33 -0
- package/src/random.ts +27 -0
- package/src/react/hooks/index.ts +21 -0
- package/src/react/hooks/use-abort-controller.ts +15 -0
- package/src/react/hooks/use-abort-signal.ts +5 -0
- package/src/react/hooks/use-click-outside.ts +27 -0
- package/{dist/react/hooks/use-constant.js → src/react/hooks/use-constant.ts} +9 -6
- package/{dist/react/hooks/use-define-ref.js → src/react/hooks/use-define-ref.ts} +10 -7
- package/src/react/hooks/use-element-ref.ts +11 -0
- package/src/react/hooks/use-event-listener.ts +29 -0
- package/src/react/hooks/use-event.ts +23 -0
- package/src/react/hooks/use-flag.ts +27 -0
- package/src/react/hooks/use-force-update.ts +9 -0
- package/src/react/hooks/use-initial-height.ts +16 -0
- package/{dist/react/hooks/use-instance.js → src/react/hooks/use-instance.ts} +31 -9
- package/src/react/hooks/use-intersection-observer.ts +18 -0
- package/src/react/hooks/use-last-defined-value.ts +9 -0
- package/src/react/hooks/use-last-value-ref.ts +11 -0
- package/src/react/hooks/use-life-cycle.ts +17 -0
- package/src/react/hooks/use-resize-observer.ts +14 -0
- package/src/react/hooks/use-sync-ref.ts +7 -0
- package/src/react/hooks/use-toggle.ts +9 -0
- package/src/react/hooks/use-value.ts +10 -0
- package/src/react/hooks/use-visibility-state.ts +19 -0
- package/src/react/index.ts +1 -0
- package/src/sound.ts +15 -0
- package/src/storage.ts +137 -0
- package/src/text.test.ts +91 -0
- package/src/text.ts +60 -0
- package/src/type-guard/_exports.ts +154 -0
- package/src/type-guard/index.test.ts +127 -0
- package/{dist/type-guard/index.js → src/type-guard/index.ts} +2 -1
- package/src/vibrate.ts +8 -0
- package/tsconfig.json +26 -0
- package/tsconfig.test.json +33 -0
- package/vitest.config.ts +20 -0
- package/dist/async.cjs +0 -70
- package/dist/async.d.cts +0 -28
- package/dist/async.d.cts.map +0 -1
- package/dist/async.d.ts +0 -28
- package/dist/async.d.ts.map +0 -1
- package/dist/async.js +0 -62
- package/dist/common.cjs +0 -18
- package/dist/common.d.cts +0 -15
- package/dist/common.d.cts.map +0 -1
- package/dist/common.d.ts +0 -15
- package/dist/common.d.ts.map +0 -1
- package/dist/common.js +0 -14
- package/dist/complex/counter.cjs +0 -21
- package/dist/complex/counter.d.cts +0 -15
- package/dist/complex/counter.d.cts.map +0 -1
- package/dist/complex/counter.d.ts +0 -15
- package/dist/complex/counter.d.ts.map +0 -1
- package/dist/complex/counter.js +0 -17
- package/dist/complex/global-config.cjs +0 -46
- package/dist/complex/global-config.d.cts +0 -11
- package/dist/complex/global-config.d.cts.map +0 -1
- package/dist/complex/global-config.d.ts +0 -11
- package/dist/complex/global-config.d.ts.map +0 -1
- package/dist/complex/global-config.js +0 -41
- package/dist/complex/index.cjs +0 -19
- package/dist/complex/index.d.cts +0 -4
- package/dist/complex/index.d.cts.map +0 -1
- package/dist/complex/index.d.ts +0 -4
- package/dist/complex/index.d.ts.map +0 -1
- package/dist/complex/index.js +0 -3
- package/dist/complex/modules-factory.cjs +0 -50
- package/dist/complex/modules-factory.d.cts +0 -49
- package/dist/complex/modules-factory.d.cts.map +0 -1
- package/dist/complex/modules-factory.d.ts +0 -49
- package/dist/complex/modules-factory.d.ts.map +0 -1
- package/dist/complex/modules-factory.js +0 -46
- package/dist/cookie.cjs +0 -13
- package/dist/cookie.d.cts +0 -3
- package/dist/cookie.d.cts.map +0 -1
- package/dist/cookie.d.ts +0 -3
- package/dist/cookie.d.ts.map +0 -1
- package/dist/cookie.js +0 -9
- package/dist/css.cjs +0 -28
- package/dist/css.d.cts +0 -36
- package/dist/css.d.cts.map +0 -1
- package/dist/css.d.ts +0 -36
- package/dist/css.d.ts.map +0 -1
- package/dist/css.js +0 -20
- package/dist/data.cjs +0 -58
- package/dist/data.d.cts +0 -4
- package/dist/data.d.cts.map +0 -1
- package/dist/data.d.ts +0 -4
- package/dist/data.d.ts.map +0 -1
- package/dist/data.js +0 -52
- package/dist/date-time.cjs +0 -171
- package/dist/date-time.d.cts +0 -28
- package/dist/date-time.d.cts.map +0 -1
- package/dist/date-time.d.ts +0 -28
- package/dist/date-time.d.ts.map +0 -1
- package/dist/date-time.js +0 -160
- package/dist/device.cjs +0 -28
- package/dist/device.d.cts +0 -8
- package/dist/device.d.cts.map +0 -1
- package/dist/device.d.ts +0 -8
- package/dist/device.d.ts.map +0 -1
- package/dist/device.js +0 -21
- package/dist/encodings.cjs +0 -270
- package/dist/encodings.d.cts +0 -2
- package/dist/encodings.d.cts.map +0 -1
- package/dist/encodings.d.ts +0 -2
- package/dist/encodings.d.ts.map +0 -1
- package/dist/encodings.js +0 -267
- package/dist/errors.cjs +0 -34
- package/dist/errors.d.cts +0 -19
- package/dist/errors.d.cts.map +0 -1
- package/dist/errors.d.ts +0 -19
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -30
- package/dist/file.cjs +0 -29
- package/dist/file.d.cts +0 -3
- package/dist/file.d.cts.map +0 -1
- package/dist/file.d.ts +0 -3
- package/dist/file.d.ts.map +0 -1
- package/dist/file.js +0 -24
- package/dist/format/_exports.cjs +0 -20
- package/dist/format/_exports.d.cts +0 -5
- package/dist/format/_exports.d.cts.map +0 -1
- package/dist/format/_exports.d.ts +0 -5
- package/dist/format/_exports.d.ts.map +0 -1
- package/dist/format/_exports.js +0 -4
- package/dist/format/constants.cjs +0 -6
- package/dist/format/constants.d.cts +0 -4
- package/dist/format/constants.d.cts.map +0 -1
- package/dist/format/constants.d.ts +0 -4
- package/dist/format/constants.d.ts.map +0 -1
- package/dist/format/index.cjs +0 -40
- package/dist/format/index.d.cts +0 -3
- package/dist/format/index.d.cts.map +0 -1
- package/dist/format/index.d.ts +0 -3
- package/dist/format/index.d.ts.map +0 -1
- package/dist/format/number.cjs +0 -48
- package/dist/format/number.d.cts +0 -36
- package/dist/format/number.d.cts.map +0 -1
- package/dist/format/number.d.ts +0 -36
- package/dist/format/number.d.ts.map +0 -1
- package/dist/format/number.js +0 -44
- package/dist/format/percent.cjs +0 -27
- package/dist/format/percent.d.cts +0 -15
- package/dist/format/percent.d.cts.map +0 -1
- package/dist/format/percent.d.ts +0 -15
- package/dist/format/percent.d.ts.map +0 -1
- package/dist/format/percent.js +0 -23
- package/dist/format/skip-spaces.cjs +0 -8
- package/dist/format/skip-spaces.d.cts +0 -5
- package/dist/format/skip-spaces.d.cts.map +0 -1
- package/dist/format/skip-spaces.d.ts +0 -5
- package/dist/format/skip-spaces.d.ts.map +0 -1
- package/dist/format/skip-spaces.js +0 -4
- package/dist/html.cjs +0 -202
- package/dist/html.d.cts +0 -44
- package/dist/html.d.cts.map +0 -1
- package/dist/html.d.ts +0 -44
- package/dist/html.d.ts.map +0 -1
- package/dist/html.js +0 -182
- package/dist/id.cjs +0 -76
- package/dist/id.d.cts +0 -63
- package/dist/id.d.cts.map +0 -1
- package/dist/id.d.ts +0 -63
- package/dist/id.d.ts.map +0 -1
- package/dist/imports.cjs +0 -45
- package/dist/imports.d.cts +0 -15
- package/dist/imports.d.cts.map +0 -1
- package/dist/imports.d.ts +0 -15
- package/dist/imports.d.ts.map +0 -1
- package/dist/imports.js +0 -40
- package/dist/math.cjs +0 -23
- package/dist/math.d.cts +0 -13
- package/dist/math.d.cts.map +0 -1
- package/dist/math.d.ts +0 -13
- package/dist/math.d.ts.map +0 -1
- package/dist/math.js +0 -17
- package/dist/media.cjs +0 -115
- package/dist/media.d.cts +0 -20
- package/dist/media.d.cts.map +0 -1
- package/dist/media.d.ts +0 -20
- package/dist/media.d.ts.map +0 -1
- package/dist/media.js +0 -103
- package/dist/mobx/apply-observable.cjs +0 -16
- package/dist/mobx/apply-observable.d.cts +0 -4
- package/dist/mobx/apply-observable.d.cts.map +0 -1
- package/dist/mobx/apply-observable.d.ts +0 -4
- package/dist/mobx/apply-observable.d.ts.map +0 -1
- package/dist/mobx/apply-observable.js +0 -12
- package/dist/mobx/create-enhanced-atom.cjs +0 -16
- package/dist/mobx/create-enhanced-atom.d.cts +0 -11
- package/dist/mobx/create-enhanced-atom.d.cts.map +0 -1
- package/dist/mobx/create-enhanced-atom.d.ts +0 -11
- package/dist/mobx/create-enhanced-atom.d.ts.map +0 -1
- package/dist/mobx/create-enhanced-atom.js +0 -12
- package/dist/mobx/deep-observable-struct.cjs +0 -61
- package/dist/mobx/deep-observable-struct.d.cts +0 -7
- package/dist/mobx/deep-observable-struct.d.cts.map +0 -1
- package/dist/mobx/deep-observable-struct.d.ts +0 -7
- package/dist/mobx/deep-observable-struct.d.ts.map +0 -1
- package/dist/mobx/deep-observable-struct.js +0 -57
- package/dist/mobx/get-mobx-administration.cjs +0 -6
- package/dist/mobx/get-mobx-administration.d.cts +0 -6
- package/dist/mobx/get-mobx-administration.d.cts.map +0 -1
- package/dist/mobx/get-mobx-administration.d.ts +0 -6
- package/dist/mobx/get-mobx-administration.d.ts.map +0 -1
- package/dist/mobx/get-mobx-administration.js +0 -2
- package/dist/mobx/index.cjs +0 -21
- package/dist/mobx/index.d.cts +0 -6
- package/dist/mobx/index.d.cts.map +0 -1
- package/dist/mobx/index.d.ts +0 -6
- package/dist/mobx/index.d.ts.map +0 -1
- package/dist/mobx/index.js +0 -5
- package/dist/mobx/lazy-observe.cjs +0 -47
- package/dist/mobx/lazy-observe.d.cts +0 -8
- package/dist/mobx/lazy-observe.d.cts.map +0 -1
- package/dist/mobx/lazy-observe.d.ts +0 -8
- package/dist/mobx/lazy-observe.d.ts.map +0 -1
- package/dist/mobx/lazy-observe.js +0 -43
- package/dist/ms.cjs +0 -22
- package/dist/ms.d.cts +0 -19
- package/dist/ms.d.cts.map +0 -1
- package/dist/ms.d.ts +0 -19
- package/dist/ms.d.ts.map +0 -1
- package/dist/ms.js +0 -18
- package/dist/number.cjs +0 -16
- package/dist/number.d.cts +0 -8
- package/dist/number.d.cts.map +0 -1
- package/dist/number.d.ts +0 -8
- package/dist/number.d.ts.map +0 -1
- package/dist/number.js +0 -13
- package/dist/parser/_exports.cjs +0 -19
- package/dist/parser/_exports.d.cts +0 -4
- package/dist/parser/_exports.d.cts.map +0 -1
- package/dist/parser/_exports.d.ts +0 -4
- package/dist/parser/_exports.d.ts.map +0 -1
- package/dist/parser/_exports.js +0 -3
- package/dist/parser/index.cjs +0 -40
- package/dist/parser/index.d.cts +0 -3
- package/dist/parser/index.d.cts.map +0 -1
- package/dist/parser/index.d.ts +0 -3
- package/dist/parser/index.d.ts.map +0 -1
- package/dist/parser/number.cjs +0 -48
- package/dist/parser/number.d.cts +0 -21
- package/dist/parser/number.d.cts.map +0 -1
- package/dist/parser/number.d.ts +0 -21
- package/dist/parser/number.d.ts.map +0 -1
- package/dist/parser/number.js +0 -44
- package/dist/parser/percent.cjs +0 -8
- package/dist/parser/percent.d.cts +0 -4
- package/dist/parser/percent.d.cts.map +0 -1
- package/dist/parser/percent.d.ts +0 -4
- package/dist/parser/percent.d.ts.map +0 -1
- package/dist/parser/percent.js +0 -4
- package/dist/parser/string.cjs +0 -18
- package/dist/parser/string.d.cts +0 -7
- package/dist/parser/string.d.cts.map +0 -1
- package/dist/parser/string.d.ts +0 -7
- package/dist/parser/string.d.ts.map +0 -1
- package/dist/parser/string.js +0 -14
- package/dist/price.cjs +0 -21
- package/dist/price.d.cts +0 -6
- package/dist/price.d.cts.map +0 -1
- package/dist/price.d.ts +0 -6
- package/dist/price.d.ts.map +0 -1
- package/dist/price.js +0 -17
- package/dist/random.cjs +0 -25
- package/dist/random.d.cts +0 -9
- package/dist/random.d.cts.map +0 -1
- package/dist/random.d.ts +0 -9
- package/dist/random.d.ts.map +0 -1
- package/dist/random.js +0 -14
- package/dist/react/hooks/index.cjs +0 -37
- package/dist/react/hooks/index.d.cts +0 -22
- package/dist/react/hooks/index.d.cts.map +0 -1
- package/dist/react/hooks/index.d.ts +0 -22
- package/dist/react/hooks/index.d.ts.map +0 -1
- package/dist/react/hooks/index.js +0 -21
- package/dist/react/hooks/use-abort-controller.cjs +0 -15
- package/dist/react/hooks/use-abort-controller.d.cts +0 -2
- package/dist/react/hooks/use-abort-controller.d.cts.map +0 -1
- package/dist/react/hooks/use-abort-controller.d.ts +0 -2
- package/dist/react/hooks/use-abort-controller.d.ts.map +0 -1
- package/dist/react/hooks/use-abort-controller.js +0 -11
- package/dist/react/hooks/use-abort-signal.cjs +0 -8
- package/dist/react/hooks/use-abort-signal.d.cts +0 -2
- package/dist/react/hooks/use-abort-signal.d.cts.map +0 -1
- package/dist/react/hooks/use-abort-signal.d.ts +0 -2
- package/dist/react/hooks/use-abort-signal.d.ts.map +0 -1
- package/dist/react/hooks/use-abort-signal.js +0 -4
- package/dist/react/hooks/use-click-outside.cjs +0 -17
- package/dist/react/hooks/use-click-outside.d.cts +0 -9
- package/dist/react/hooks/use-click-outside.d.cts.map +0 -1
- package/dist/react/hooks/use-click-outside.d.ts +0 -9
- package/dist/react/hooks/use-click-outside.d.ts.map +0 -1
- package/dist/react/hooks/use-click-outside.js +0 -13
- package/dist/react/hooks/use-constant.cjs +0 -19
- package/dist/react/hooks/use-constant.d.cts +0 -9
- package/dist/react/hooks/use-constant.d.cts.map +0 -1
- package/dist/react/hooks/use-constant.d.ts +0 -9
- package/dist/react/hooks/use-constant.d.ts.map +0 -1
- package/dist/react/hooks/use-define-ref.cjs +0 -19
- package/dist/react/hooks/use-define-ref.d.cts +0 -10
- package/dist/react/hooks/use-define-ref.d.cts.map +0 -1
- package/dist/react/hooks/use-define-ref.d.ts +0 -10
- package/dist/react/hooks/use-define-ref.d.ts.map +0 -1
- package/dist/react/hooks/use-element-ref.cjs +0 -12
- package/dist/react/hooks/use-element-ref.d.cts +0 -2
- package/dist/react/hooks/use-element-ref.d.cts.map +0 -1
- package/dist/react/hooks/use-element-ref.d.ts +0 -2
- package/dist/react/hooks/use-element-ref.d.ts.map +0 -1
- package/dist/react/hooks/use-element-ref.js +0 -8
- package/dist/react/hooks/use-event-listener.cjs +0 -17
- package/dist/react/hooks/use-event-listener.d.cts +0 -8
- package/dist/react/hooks/use-event-listener.d.cts.map +0 -1
- package/dist/react/hooks/use-event-listener.d.ts +0 -8
- package/dist/react/hooks/use-event-listener.d.ts.map +0 -1
- package/dist/react/hooks/use-event-listener.js +0 -13
- package/dist/react/hooks/use-event.cjs +0 -23
- package/dist/react/hooks/use-event.d.cts +0 -3
- package/dist/react/hooks/use-event.d.cts.map +0 -1
- package/dist/react/hooks/use-event.d.ts +0 -3
- package/dist/react/hooks/use-event.d.ts.map +0 -1
- package/dist/react/hooks/use-event.js +0 -19
- package/dist/react/hooks/use-flag.cjs +0 -19
- package/dist/react/hooks/use-flag.d.cts +0 -8
- package/dist/react/hooks/use-flag.d.cts.map +0 -1
- package/dist/react/hooks/use-flag.d.ts +0 -8
- package/dist/react/hooks/use-flag.d.ts.map +0 -1
- package/dist/react/hooks/use-flag.js +0 -15
- package/dist/react/hooks/use-force-update.cjs +0 -11
- package/dist/react/hooks/use-force-update.d.cts +0 -2
- package/dist/react/hooks/use-force-update.d.cts.map +0 -1
- package/dist/react/hooks/use-force-update.d.ts +0 -2
- package/dist/react/hooks/use-force-update.d.ts.map +0 -1
- package/dist/react/hooks/use-force-update.js +0 -7
- package/dist/react/hooks/use-initial-height.cjs +0 -15
- package/dist/react/hooks/use-initial-height.d.cts +0 -5
- package/dist/react/hooks/use-initial-height.d.cts.map +0 -1
- package/dist/react/hooks/use-initial-height.d.ts +0 -5
- package/dist/react/hooks/use-initial-height.d.ts.map +0 -1
- package/dist/react/hooks/use-initial-height.js +0 -11
- package/dist/react/hooks/use-instance.cjs +0 -31
- package/dist/react/hooks/use-instance.d.cts +0 -27
- package/dist/react/hooks/use-instance.d.cts.map +0 -1
- package/dist/react/hooks/use-instance.d.ts +0 -27
- package/dist/react/hooks/use-instance.d.ts.map +0 -1
- package/dist/react/hooks/use-intersection-observer.cjs +0 -14
- package/dist/react/hooks/use-intersection-observer.d.cts +0 -2
- package/dist/react/hooks/use-intersection-observer.d.cts.map +0 -1
- package/dist/react/hooks/use-intersection-observer.d.ts +0 -2
- package/dist/react/hooks/use-intersection-observer.d.ts.map +0 -1
- package/dist/react/hooks/use-intersection-observer.js +0 -10
- package/dist/react/hooks/use-last-defined-value.cjs +0 -12
- package/dist/react/hooks/use-last-defined-value.d.cts +0 -2
- package/dist/react/hooks/use-last-defined-value.d.cts.map +0 -1
- package/dist/react/hooks/use-last-defined-value.d.ts +0 -2
- package/dist/react/hooks/use-last-defined-value.d.ts.map +0 -1
- package/dist/react/hooks/use-last-defined-value.js +0 -8
- package/dist/react/hooks/use-last-value-ref.cjs +0 -12
- package/dist/react/hooks/use-last-value-ref.d.cts +0 -2
- package/dist/react/hooks/use-last-value-ref.d.cts.map +0 -1
- package/dist/react/hooks/use-last-value-ref.d.ts +0 -2
- package/dist/react/hooks/use-last-value-ref.d.ts.map +0 -1
- package/dist/react/hooks/use-last-value-ref.js +0 -8
- package/dist/react/hooks/use-life-cycle.cjs +0 -14
- package/dist/react/hooks/use-life-cycle.d.cts +0 -5
- package/dist/react/hooks/use-life-cycle.d.cts.map +0 -1
- package/dist/react/hooks/use-life-cycle.d.ts +0 -5
- package/dist/react/hooks/use-life-cycle.d.ts.map +0 -1
- package/dist/react/hooks/use-life-cycle.js +0 -10
- package/dist/react/hooks/use-resize-observer.cjs +0 -15
- package/dist/react/hooks/use-resize-observer.d.cts +0 -2
- package/dist/react/hooks/use-resize-observer.d.cts.map +0 -1
- package/dist/react/hooks/use-resize-observer.d.ts +0 -2
- package/dist/react/hooks/use-resize-observer.d.ts.map +0 -1
- package/dist/react/hooks/use-resize-observer.js +0 -11
- package/dist/react/hooks/use-sync-ref.cjs +0 -10
- package/dist/react/hooks/use-sync-ref.d.cts +0 -2
- package/dist/react/hooks/use-sync-ref.d.cts.map +0 -1
- package/dist/react/hooks/use-sync-ref.d.ts +0 -2
- package/dist/react/hooks/use-sync-ref.d.ts.map +0 -1
- package/dist/react/hooks/use-sync-ref.js +0 -6
- package/dist/react/hooks/use-toggle.cjs +0 -10
- package/dist/react/hooks/use-toggle.d.cts +0 -2
- package/dist/react/hooks/use-toggle.d.cts.map +0 -1
- package/dist/react/hooks/use-toggle.d.ts +0 -2
- package/dist/react/hooks/use-toggle.d.ts.map +0 -1
- package/dist/react/hooks/use-toggle.js +0 -6
- package/dist/react/hooks/use-value.cjs +0 -12
- package/dist/react/hooks/use-value.d.cts +0 -5
- package/dist/react/hooks/use-value.d.cts.map +0 -1
- package/dist/react/hooks/use-value.d.ts +0 -5
- package/dist/react/hooks/use-value.d.ts.map +0 -1
- package/dist/react/hooks/use-value.js +0 -8
- package/dist/react/hooks/use-visibility-state.cjs +0 -18
- package/dist/react/hooks/use-visibility-state.d.cts +0 -2
- package/dist/react/hooks/use-visibility-state.d.cts.map +0 -1
- package/dist/react/hooks/use-visibility-state.d.ts +0 -2
- package/dist/react/hooks/use-visibility-state.d.ts.map +0 -1
- package/dist/react/hooks/use-visibility-state.js +0 -14
- package/dist/react/index.cjs +0 -17
- package/dist/react/index.d.cts +0 -2
- package/dist/react/index.d.cts.map +0 -1
- package/dist/react/index.d.ts +0 -2
- package/dist/react/index.d.ts.map +0 -1
- package/dist/react/index.js +0 -1
- package/dist/sound.cjs +0 -16
- package/dist/sound.d.cts +0 -7
- package/dist/sound.d.cts.map +0 -1
- package/dist/sound.d.ts +0 -7
- package/dist/sound.d.ts.map +0 -1
- package/dist/sound.js +0 -12
- package/dist/storage.cjs +0 -48
- package/dist/storage.d.cts +0 -39
- package/dist/storage.d.cts.map +0 -1
- package/dist/storage.d.ts +0 -39
- package/dist/storage.d.ts.map +0 -1
- package/dist/storage.js +0 -43
- package/dist/text.cjs +0 -53
- package/dist/text.d.cts +0 -15
- package/dist/text.d.cts.map +0 -1
- package/dist/text.d.ts +0 -15
- package/dist/text.d.ts.map +0 -1
- package/dist/text.js +0 -48
- package/dist/type-guard/_exports.cjs +0 -129
- package/dist/type-guard/_exports.d.cts +0 -86
- package/dist/type-guard/_exports.d.cts.map +0 -1
- package/dist/type-guard/_exports.d.ts +0 -86
- package/dist/type-guard/_exports.d.ts.map +0 -1
- package/dist/type-guard/_exports.js +0 -125
- package/dist/type-guard/index.cjs +0 -40
- package/dist/type-guard/index.d.cts +0 -3
- package/dist/type-guard/index.d.cts.map +0 -1
- package/dist/type-guard/index.d.ts +0 -3
- package/dist/type-guard/index.d.ts.map +0 -1
- package/dist/utils/types.cjs +0 -2
- package/dist/utils/types.d.cts +0 -395
- package/dist/utils/types.d.cts.map +0 -1
- package/dist/utils/types.d.ts +0 -395
- package/dist/utils/types.d.ts.map +0 -1
- package/dist/utils/types.js +0 -1
- package/dist/vibrate.cjs +0 -12
- package/dist/vibrate.d.cts +0 -5
- package/dist/vibrate.d.cts.map +0 -1
- package/dist/vibrate.d.ts +0 -5
- package/dist/vibrate.d.ts.map +0 -1
- package/dist/vibrate.js +0 -8
- package/utility-types.d.ts +0 -395
- package/utils/types.cjs +0 -2
- package/utils/types.d.cts +0 -395
- package/utils/types.d.cts.map +0 -1
- package/utils/types.d.ts +0 -395
- package/utils/types.d.ts.map +0 -1
- package/utils/types.js +0 -1
package/src/date-time.ts
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import dayjs, { type Dayjs, type ManipulateType } from 'dayjs';
|
|
2
|
+
import duration from 'dayjs/plugin/duration.js';
|
|
3
|
+
import relativeTime from 'dayjs/plugin/relativeTime.js';
|
|
4
|
+
|
|
5
|
+
import { format } from './format/index.js';
|
|
6
|
+
import { unitsToMs } from './ms.js';
|
|
7
|
+
import { declension } from './text.js';
|
|
8
|
+
import { typeGuard } from './type-guard/index.js';
|
|
9
|
+
import type { Maybe } from './utils/types.js';
|
|
10
|
+
|
|
11
|
+
import 'dayjs/locale/ru.js';
|
|
12
|
+
|
|
13
|
+
dayjs.extend(relativeTime);
|
|
14
|
+
dayjs.extend(duration);
|
|
15
|
+
dayjs.locale('ru');
|
|
16
|
+
|
|
17
|
+
const toLibFormat = (
|
|
18
|
+
value: Maybe<RawDateToFormat>,
|
|
19
|
+
asTime?: boolean,
|
|
20
|
+
): Dayjs => {
|
|
21
|
+
if (typeGuard.isNumber(value)) {
|
|
22
|
+
if (asTime) {
|
|
23
|
+
return dayjs.duration(value) as unknown as Dayjs;
|
|
24
|
+
}
|
|
25
|
+
return dayjs(value);
|
|
26
|
+
} else if (dayjs.isDayjs(value)) {
|
|
27
|
+
return value;
|
|
28
|
+
} else {
|
|
29
|
+
return dayjs(value);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type RawDateToFormat = Date | string | number | Dayjs;
|
|
34
|
+
|
|
35
|
+
export const formatDate = (
|
|
36
|
+
value: Maybe<RawDateToFormat>,
|
|
37
|
+
settings?: Maybe<{
|
|
38
|
+
format?:
|
|
39
|
+
| 'human'
|
|
40
|
+
| 'full'
|
|
41
|
+
| 'short'
|
|
42
|
+
| 'day'
|
|
43
|
+
| 'day-only'
|
|
44
|
+
| 'date'
|
|
45
|
+
| 'month'
|
|
46
|
+
| 'spent-time'
|
|
47
|
+
| 'time'
|
|
48
|
+
| 'time-short';
|
|
49
|
+
pattern?: string;
|
|
50
|
+
asTime?: boolean;
|
|
51
|
+
}>,
|
|
52
|
+
) => {
|
|
53
|
+
const dateFormat = settings?.format;
|
|
54
|
+
const datePattern = settings?.pattern;
|
|
55
|
+
const asTime = settings?.asTime;
|
|
56
|
+
|
|
57
|
+
value = toLibFormat(value, asTime);
|
|
58
|
+
|
|
59
|
+
if (typeGuard.isUndefined(value) || !value.isValid()) {
|
|
60
|
+
return format.NO_VALUE;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (datePattern) {
|
|
64
|
+
return value.format(datePattern);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
switch (dateFormat) {
|
|
68
|
+
case 'human': {
|
|
69
|
+
return value.fromNow();
|
|
70
|
+
}
|
|
71
|
+
case 'spent-time': {
|
|
72
|
+
return value.fromNow(true);
|
|
73
|
+
}
|
|
74
|
+
case 'full': {
|
|
75
|
+
return value.format('DD MMM YYYY HH:mm:ss');
|
|
76
|
+
}
|
|
77
|
+
case 'short': {
|
|
78
|
+
return value.format('DD MMM HH:mm');
|
|
79
|
+
}
|
|
80
|
+
case 'time': {
|
|
81
|
+
return value.format('HH:mm:ss');
|
|
82
|
+
}
|
|
83
|
+
case 'time-short': {
|
|
84
|
+
return value.format('HH:mm');
|
|
85
|
+
}
|
|
86
|
+
case 'day': {
|
|
87
|
+
return value.format('DD MMM YYYY');
|
|
88
|
+
}
|
|
89
|
+
case 'month': {
|
|
90
|
+
return value.format('MMMM YYYY');
|
|
91
|
+
}
|
|
92
|
+
default: {
|
|
93
|
+
return value.format('DD.MM.YYYY');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const dayTimeDuration = (timeInMs: number) => {
|
|
99
|
+
let left = Math.max(timeInMs, 0);
|
|
100
|
+
|
|
101
|
+
const days = Math.floor(left / unitsToMs.day);
|
|
102
|
+
left = left % unitsToMs.day;
|
|
103
|
+
|
|
104
|
+
const hours = Math.floor(left / unitsToMs.hour);
|
|
105
|
+
left = left % unitsToMs.hour;
|
|
106
|
+
|
|
107
|
+
const minutes = Math.floor(left / unitsToMs.min);
|
|
108
|
+
left = left % unitsToMs.min;
|
|
109
|
+
|
|
110
|
+
const seconds = Math.floor(left / unitsToMs.sec);
|
|
111
|
+
left = left % unitsToMs.sec;
|
|
112
|
+
|
|
113
|
+
const milliseconds = Math.floor(left);
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
days,
|
|
117
|
+
hours,
|
|
118
|
+
minutes,
|
|
119
|
+
seconds,
|
|
120
|
+
milliseconds,
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
type DateChangeParam = [amount: number, unit?: Maybe<ManipulateType>];
|
|
125
|
+
|
|
126
|
+
export const changeDate = (
|
|
127
|
+
date: Maybe<RawDateToFormat>,
|
|
128
|
+
...args: [
|
|
129
|
+
...DateChangeParam,
|
|
130
|
+
...Partial<DateChangeParam>,
|
|
131
|
+
...Partial<DateChangeParam>,
|
|
132
|
+
...Partial<DateChangeParam>,
|
|
133
|
+
...Partial<DateChangeParam>,
|
|
134
|
+
...Partial<DateChangeParam>,
|
|
135
|
+
]
|
|
136
|
+
) => {
|
|
137
|
+
let wrappedDate = toLibFormat(date);
|
|
138
|
+
|
|
139
|
+
for (let i = 0; i < args.length; i += 2) {
|
|
140
|
+
const amount = args[i] as DateChangeParam[0];
|
|
141
|
+
const unit = args[i + 1] as DateChangeParam[1];
|
|
142
|
+
if (unit != null) {
|
|
143
|
+
wrappedDate = wrappedDate.add(amount, unit);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return wrappedDate.toDate();
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export const timeDuration = (timeInMs: number) => {
|
|
151
|
+
const { days, hours, milliseconds, minutes, seconds } =
|
|
152
|
+
dayTimeDuration(timeInMs);
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
hours: hours + unitsToMs.day * days,
|
|
156
|
+
milliseconds,
|
|
157
|
+
minutes,
|
|
158
|
+
seconds,
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const durationFormatLabels = {
|
|
163
|
+
days: { compact: 'д', full: ['день', 'дня', 'дней'] },
|
|
164
|
+
hours: { compact: 'ч', full: ['час', 'часа', 'часов'] },
|
|
165
|
+
minutes: { compact: 'мин', full: ['минута', 'минуты', 'минут'] },
|
|
166
|
+
seconds: { compact: 'сек', full: ['секунда', 'секунды', 'секунд'] },
|
|
167
|
+
} as const;
|
|
168
|
+
|
|
169
|
+
export function getFormatDuration(
|
|
170
|
+
dateA: Date,
|
|
171
|
+
dateB: Date,
|
|
172
|
+
compact?: boolean,
|
|
173
|
+
): string;
|
|
174
|
+
export function getFormatDuration(ms: number, compact?: boolean): string;
|
|
175
|
+
|
|
176
|
+
export function getFormatDuration(...args: any[]): string {
|
|
177
|
+
let compact = false;
|
|
178
|
+
let diff = 0;
|
|
179
|
+
|
|
180
|
+
if (args[0] instanceof Date) {
|
|
181
|
+
const startedDate = dayjs(args[0]);
|
|
182
|
+
const endedDate = dayjs(args[1]);
|
|
183
|
+
|
|
184
|
+
diff = endedDate.diff(startedDate, 'ms');
|
|
185
|
+
compact = args[2] === true;
|
|
186
|
+
} else {
|
|
187
|
+
diff = args[0];
|
|
188
|
+
compact = args[1] === true;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const { days, hours, minutes, seconds } = dayTimeDuration(diff);
|
|
192
|
+
|
|
193
|
+
const formattedParts: string[] = [];
|
|
194
|
+
|
|
195
|
+
if (days) {
|
|
196
|
+
if (compact) {
|
|
197
|
+
formattedParts.push(`${days} ${durationFormatLabels.days.compact}`);
|
|
198
|
+
} else {
|
|
199
|
+
formattedParts.push(
|
|
200
|
+
`${days} ${declension(days, durationFormatLabels.days.full)}`,
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (hours) {
|
|
206
|
+
if (compact) {
|
|
207
|
+
formattedParts.push(`${hours} ${durationFormatLabels.hours.compact}`);
|
|
208
|
+
} else {
|
|
209
|
+
formattedParts.push(
|
|
210
|
+
`${hours} ${declension(hours, durationFormatLabels.hours.full)}`,
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (minutes) {
|
|
216
|
+
if (compact) {
|
|
217
|
+
formattedParts.push(`${minutes} ${durationFormatLabels.minutes.compact}`);
|
|
218
|
+
} else {
|
|
219
|
+
formattedParts.push(
|
|
220
|
+
`${minutes} ${declension(minutes, durationFormatLabels.minutes.full)}`,
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (seconds) {
|
|
226
|
+
if (compact) {
|
|
227
|
+
formattedParts.push(`${seconds} ${durationFormatLabels.seconds.compact}`);
|
|
228
|
+
} else {
|
|
229
|
+
formattedParts.push(
|
|
230
|
+
`${seconds} ${declension(seconds, durationFormatLabels.seconds.full)}`,
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return formattedParts.join(' ');
|
|
236
|
+
}
|
package/src/device.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export const getUserAgent = () =>
|
|
2
|
+
(
|
|
3
|
+
navigator.userAgent ||
|
|
4
|
+
navigator.vendor ||
|
|
5
|
+
// @ts-expect-error skip opera
|
|
6
|
+
globalThis.opera ||
|
|
7
|
+
''
|
|
8
|
+
).toLowerCase();
|
|
9
|
+
|
|
10
|
+
export const checkIsMobileDevice = () => {
|
|
11
|
+
const userAgent = getUserAgent();
|
|
12
|
+
|
|
13
|
+
if (
|
|
14
|
+
/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(
|
|
15
|
+
userAgent || '',
|
|
16
|
+
) ||
|
|
17
|
+
/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(
|
|
18
|
+
(userAgent || '').slice(0, 4),
|
|
19
|
+
)
|
|
20
|
+
) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return false;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const checkIsTabletDevice = () => {
|
|
28
|
+
const userAgent = getUserAgent();
|
|
29
|
+
|
|
30
|
+
return /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(
|
|
31
|
+
userAgent,
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const checkIsTouchDevice = () =>
|
|
36
|
+
checkIsMobileDevice() || checkIsTabletDevice();
|
|
37
|
+
|
|
38
|
+
export const isMobileDevice = checkIsMobileDevice();
|
|
39
|
+
|
|
40
|
+
export const isTabletDevice = checkIsTabletDevice();
|
|
41
|
+
|
|
42
|
+
export const isTouchDevice = isMobileDevice || isTabletDevice;
|
package/src/encodings.ts
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import type { AnyObject } from './utils/types.js';
|
|
2
|
+
|
|
3
|
+
const DMap: AnyObject = {
|
|
4
|
+
0: 0,
|
|
5
|
+
1: 1,
|
|
6
|
+
2: 2,
|
|
7
|
+
3: 3,
|
|
8
|
+
4: 4,
|
|
9
|
+
5: 5,
|
|
10
|
+
6: 6,
|
|
11
|
+
7: 7,
|
|
12
|
+
8: 8,
|
|
13
|
+
9: 9,
|
|
14
|
+
10: 10,
|
|
15
|
+
11: 11,
|
|
16
|
+
12: 12,
|
|
17
|
+
13: 13,
|
|
18
|
+
14: 14,
|
|
19
|
+
15: 15,
|
|
20
|
+
16: 16,
|
|
21
|
+
17: 17,
|
|
22
|
+
18: 18,
|
|
23
|
+
19: 19,
|
|
24
|
+
20: 20,
|
|
25
|
+
21: 21,
|
|
26
|
+
22: 22,
|
|
27
|
+
23: 23,
|
|
28
|
+
24: 24,
|
|
29
|
+
25: 25,
|
|
30
|
+
26: 26,
|
|
31
|
+
27: 27,
|
|
32
|
+
28: 28,
|
|
33
|
+
29: 29,
|
|
34
|
+
30: 30,
|
|
35
|
+
31: 31,
|
|
36
|
+
32: 32,
|
|
37
|
+
33: 33,
|
|
38
|
+
34: 34,
|
|
39
|
+
35: 35,
|
|
40
|
+
36: 36,
|
|
41
|
+
37: 37,
|
|
42
|
+
38: 38,
|
|
43
|
+
39: 39,
|
|
44
|
+
40: 40,
|
|
45
|
+
41: 41,
|
|
46
|
+
42: 42,
|
|
47
|
+
43: 43,
|
|
48
|
+
44: 44,
|
|
49
|
+
45: 45,
|
|
50
|
+
46: 46,
|
|
51
|
+
47: 47,
|
|
52
|
+
48: 48,
|
|
53
|
+
49: 49,
|
|
54
|
+
50: 50,
|
|
55
|
+
51: 51,
|
|
56
|
+
52: 52,
|
|
57
|
+
53: 53,
|
|
58
|
+
54: 54,
|
|
59
|
+
55: 55,
|
|
60
|
+
56: 56,
|
|
61
|
+
57: 57,
|
|
62
|
+
58: 58,
|
|
63
|
+
59: 59,
|
|
64
|
+
60: 60,
|
|
65
|
+
61: 61,
|
|
66
|
+
62: 62,
|
|
67
|
+
63: 63,
|
|
68
|
+
64: 64,
|
|
69
|
+
65: 65,
|
|
70
|
+
66: 66,
|
|
71
|
+
67: 67,
|
|
72
|
+
68: 68,
|
|
73
|
+
69: 69,
|
|
74
|
+
70: 70,
|
|
75
|
+
71: 71,
|
|
76
|
+
72: 72,
|
|
77
|
+
73: 73,
|
|
78
|
+
74: 74,
|
|
79
|
+
75: 75,
|
|
80
|
+
76: 76,
|
|
81
|
+
77: 77,
|
|
82
|
+
78: 78,
|
|
83
|
+
79: 79,
|
|
84
|
+
80: 80,
|
|
85
|
+
81: 81,
|
|
86
|
+
82: 82,
|
|
87
|
+
83: 83,
|
|
88
|
+
84: 84,
|
|
89
|
+
85: 85,
|
|
90
|
+
86: 86,
|
|
91
|
+
87: 87,
|
|
92
|
+
88: 88,
|
|
93
|
+
89: 89,
|
|
94
|
+
90: 90,
|
|
95
|
+
91: 91,
|
|
96
|
+
92: 92,
|
|
97
|
+
93: 93,
|
|
98
|
+
94: 94,
|
|
99
|
+
95: 95,
|
|
100
|
+
96: 96,
|
|
101
|
+
97: 97,
|
|
102
|
+
98: 98,
|
|
103
|
+
99: 99,
|
|
104
|
+
100: 100,
|
|
105
|
+
101: 101,
|
|
106
|
+
102: 102,
|
|
107
|
+
103: 103,
|
|
108
|
+
104: 104,
|
|
109
|
+
105: 105,
|
|
110
|
+
106: 106,
|
|
111
|
+
107: 107,
|
|
112
|
+
108: 108,
|
|
113
|
+
109: 109,
|
|
114
|
+
110: 110,
|
|
115
|
+
111: 111,
|
|
116
|
+
112: 112,
|
|
117
|
+
113: 113,
|
|
118
|
+
114: 114,
|
|
119
|
+
115: 115,
|
|
120
|
+
116: 116,
|
|
121
|
+
117: 117,
|
|
122
|
+
118: 118,
|
|
123
|
+
119: 119,
|
|
124
|
+
120: 120,
|
|
125
|
+
121: 121,
|
|
126
|
+
122: 122,
|
|
127
|
+
123: 123,
|
|
128
|
+
124: 124,
|
|
129
|
+
125: 125,
|
|
130
|
+
126: 126,
|
|
131
|
+
127: 127,
|
|
132
|
+
1027: 129,
|
|
133
|
+
8225: 135,
|
|
134
|
+
1046: 198,
|
|
135
|
+
8222: 132,
|
|
136
|
+
1047: 199,
|
|
137
|
+
1168: 165,
|
|
138
|
+
1048: 200,
|
|
139
|
+
1113: 154,
|
|
140
|
+
1049: 201,
|
|
141
|
+
1045: 197,
|
|
142
|
+
1050: 202,
|
|
143
|
+
1028: 170,
|
|
144
|
+
160: 160,
|
|
145
|
+
1040: 192,
|
|
146
|
+
1051: 203,
|
|
147
|
+
164: 164,
|
|
148
|
+
166: 166,
|
|
149
|
+
167: 167,
|
|
150
|
+
169: 169,
|
|
151
|
+
171: 171,
|
|
152
|
+
172: 172,
|
|
153
|
+
173: 173,
|
|
154
|
+
174: 174,
|
|
155
|
+
1053: 205,
|
|
156
|
+
176: 176,
|
|
157
|
+
177: 177,
|
|
158
|
+
1114: 156,
|
|
159
|
+
181: 181,
|
|
160
|
+
182: 182,
|
|
161
|
+
183: 183,
|
|
162
|
+
8221: 148,
|
|
163
|
+
187: 187,
|
|
164
|
+
1029: 189,
|
|
165
|
+
1056: 208,
|
|
166
|
+
1057: 209,
|
|
167
|
+
1058: 210,
|
|
168
|
+
8364: 136,
|
|
169
|
+
1112: 188,
|
|
170
|
+
1115: 158,
|
|
171
|
+
1059: 211,
|
|
172
|
+
1060: 212,
|
|
173
|
+
1030: 178,
|
|
174
|
+
1061: 213,
|
|
175
|
+
1062: 214,
|
|
176
|
+
1063: 215,
|
|
177
|
+
1116: 157,
|
|
178
|
+
1064: 216,
|
|
179
|
+
1065: 217,
|
|
180
|
+
1031: 175,
|
|
181
|
+
1066: 218,
|
|
182
|
+
1067: 219,
|
|
183
|
+
1068: 220,
|
|
184
|
+
1069: 221,
|
|
185
|
+
1070: 222,
|
|
186
|
+
1032: 163,
|
|
187
|
+
8226: 149,
|
|
188
|
+
1071: 223,
|
|
189
|
+
1072: 224,
|
|
190
|
+
8482: 153,
|
|
191
|
+
1073: 225,
|
|
192
|
+
8240: 137,
|
|
193
|
+
1118: 162,
|
|
194
|
+
1074: 226,
|
|
195
|
+
1110: 179,
|
|
196
|
+
8230: 133,
|
|
197
|
+
1075: 227,
|
|
198
|
+
1033: 138,
|
|
199
|
+
1076: 228,
|
|
200
|
+
1077: 229,
|
|
201
|
+
8211: 150,
|
|
202
|
+
1078: 230,
|
|
203
|
+
1119: 159,
|
|
204
|
+
1079: 231,
|
|
205
|
+
1042: 194,
|
|
206
|
+
1080: 232,
|
|
207
|
+
1034: 140,
|
|
208
|
+
1025: 168,
|
|
209
|
+
1081: 233,
|
|
210
|
+
1082: 234,
|
|
211
|
+
8212: 151,
|
|
212
|
+
1083: 235,
|
|
213
|
+
1169: 180,
|
|
214
|
+
1084: 236,
|
|
215
|
+
1052: 204,
|
|
216
|
+
1085: 237,
|
|
217
|
+
1035: 142,
|
|
218
|
+
1086: 238,
|
|
219
|
+
1087: 239,
|
|
220
|
+
1088: 240,
|
|
221
|
+
1089: 241,
|
|
222
|
+
1090: 242,
|
|
223
|
+
1036: 141,
|
|
224
|
+
1041: 193,
|
|
225
|
+
1091: 243,
|
|
226
|
+
1092: 244,
|
|
227
|
+
8224: 134,
|
|
228
|
+
1093: 245,
|
|
229
|
+
8470: 185,
|
|
230
|
+
1094: 246,
|
|
231
|
+
1054: 206,
|
|
232
|
+
1095: 247,
|
|
233
|
+
1096: 248,
|
|
234
|
+
8249: 139,
|
|
235
|
+
1097: 249,
|
|
236
|
+
1098: 250,
|
|
237
|
+
1044: 196,
|
|
238
|
+
1099: 251,
|
|
239
|
+
1111: 191,
|
|
240
|
+
1055: 207,
|
|
241
|
+
1100: 252,
|
|
242
|
+
1038: 161,
|
|
243
|
+
8220: 147,
|
|
244
|
+
1101: 253,
|
|
245
|
+
8250: 155,
|
|
246
|
+
1102: 254,
|
|
247
|
+
8216: 145,
|
|
248
|
+
1103: 255,
|
|
249
|
+
1043: 195,
|
|
250
|
+
1105: 184,
|
|
251
|
+
1039: 143,
|
|
252
|
+
1026: 128,
|
|
253
|
+
1106: 144,
|
|
254
|
+
8218: 130,
|
|
255
|
+
1107: 131,
|
|
256
|
+
8217: 146,
|
|
257
|
+
1108: 186,
|
|
258
|
+
1109: 190,
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
export function unicodeToWin1251(s: string) {
|
|
262
|
+
const L = [];
|
|
263
|
+
for (let i = 0; i < s.length; i++) {
|
|
264
|
+
const ord = s.charCodeAt(i);
|
|
265
|
+
if (!(ord in DMap))
|
|
266
|
+
throw new Error(`Character ${s.charAt(i)} isn't supported by win1251!`);
|
|
267
|
+
L.push(String.fromCharCode(DMap[ord]));
|
|
268
|
+
}
|
|
269
|
+
return L.join('');
|
|
270
|
+
}
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { typeGuard } from './type-guard/index.js';
|
|
2
|
+
import type { Maybe } from './utils/types.js';
|
|
3
|
+
|
|
4
|
+
type GetErrorTextEnhancer = (error: any) => string;
|
|
5
|
+
type GetErrorTextFormatErrorFn = (error: Error) => string;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Universal function for transforming any errors into readable error text
|
|
9
|
+
*
|
|
10
|
+
* This function can be enhanced with custom handlers using:
|
|
11
|
+
* - `getErrorText.unknownErrorText`
|
|
12
|
+
* - `getErrorText.formatError`
|
|
13
|
+
* - `getErrorText.enhance`
|
|
14
|
+
*/
|
|
15
|
+
export const getErrorText = (error: unknown) => {
|
|
16
|
+
if (!error) {
|
|
17
|
+
return getErrorText.unknownErrorText;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (typeGuard.isString(error)) {
|
|
21
|
+
return error || getErrorText.unknownErrorText;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (error instanceof Error) {
|
|
25
|
+
return (
|
|
26
|
+
(getErrorText.formatError?.(error) ?? error.message) ||
|
|
27
|
+
getErrorText.unknownErrorText
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (getErrorText.enhance) {
|
|
32
|
+
return getErrorText.enhance(error) ?? getErrorText.unknownErrorText;
|
|
33
|
+
} else {
|
|
34
|
+
return getErrorText.unknownErrorText;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
getErrorText.unknownErrorText = '';
|
|
39
|
+
getErrorText.formatError = null as Maybe<GetErrorTextFormatErrorFn>;
|
|
40
|
+
getErrorText.enhance = null as Maybe<GetErrorTextEnhancer>;
|
package/src/file.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const getBase64FromFile = (file: File) => {
|
|
2
|
+
return new Promise<string>((resolve, reject) => {
|
|
3
|
+
const reader = new FileReader();
|
|
4
|
+
reader.readAsDataURL(file);
|
|
5
|
+
reader.onload = () => {
|
|
6
|
+
resolve(reader.result!.toString());
|
|
7
|
+
};
|
|
8
|
+
reader.onerror = (error) => {
|
|
9
|
+
reject(error);
|
|
10
|
+
};
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const getTextFromFile = (file: File, encoding?: string) => {
|
|
15
|
+
return new Promise<string>((resolve, reject) => {
|
|
16
|
+
const reader = new FileReader();
|
|
17
|
+
reader.readAsText(file, encoding);
|
|
18
|
+
reader.onload = () => {
|
|
19
|
+
resolve(reader.result!.toString());
|
|
20
|
+
};
|
|
21
|
+
reader.onerror = (error) => {
|
|
22
|
+
reject(error);
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { number } from './number';
|
|
4
|
+
|
|
5
|
+
describe('format.number', () => {
|
|
6
|
+
test('[BUG] Infinite formatting of the number 23162 with an empty delimiter', () => {
|
|
7
|
+
expect(number(23_162, { digits: 4, cutZeros: true, delimiter: '' })).toBe(
|
|
8
|
+
'23162',
|
|
9
|
+
);
|
|
10
|
+
});
|
|
11
|
+
test('Formatting the number 23162', () => {
|
|
12
|
+
expect(number(23_162, { digits: 4, cutZeros: true, delimiter: '_' })).toBe(
|
|
13
|
+
'23_162',
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
});
|