yummies 5.7.0 → 5.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/async.js +26 -59
- package/async.js.map +1 -0
- package/common.d.ts +1 -1
- package/common.d.ts.map +1 -1
- package/common.js +5 -13
- package/common.js.map +1 -0
- package/complex/global-config.d.ts +1 -1
- package/complex/global-config.d.ts.map +1 -1
- package/complex/index.d.ts +3 -3
- package/complex/index.d.ts.map +1 -1
- package/complex/modules-factory.d.ts +1 -1
- package/complex/modules-factory.d.ts.map +1 -1
- package/complex.js +66 -0
- package/complex.js.map +1 -0
- package/cookie.d.ts +1 -1
- package/cookie.d.ts.map +1 -1
- package/cookie.js +4 -8
- package/cookie.js.map +1 -0
- package/css.d.ts +1 -1
- package/css.js +2780 -49
- package/css.js.map +1 -0
- package/data.js +32 -50
- package/data.js.map +1 -0
- package/date-time.d.ts +2 -3
- package/date-time.d.ts.map +1 -1
- package/date-time.js +588 -154
- package/date-time.js.map +1 -0
- package/device.js +23 -20
- package/device.js.map +1 -0
- package/encodings.js +269 -265
- package/encodings.js.map +1 -0
- package/errors.d.ts +1 -1
- package/errors.d.ts.map +1 -1
- package/errors.js +8 -29
- package/errors.js.map +1 -0
- package/file.js +19 -23
- package/file.js.map +1 -0
- package/format/_exports.d.ts +4 -4
- package/format/_exports.d.ts.map +1 -1
- package/format/index.d.ts +1 -1
- package/format/index.d.ts.map +1 -1
- package/format/number.d.ts +1 -1
- package/format/number.d.ts.map +1 -1
- package/format/percent.d.ts +2 -2
- package/format/percent.d.ts.map +1 -1
- package/format.js +27 -0
- package/format.js.map +1 -0
- package/html.d.ts +2 -2
- package/html.d.ts.map +1 -1
- package/html.js +636 -169
- package/html.js.map +1 -0
- package/id.js +25 -70
- package/id.js.map +1 -0
- package/imports.js +22 -37
- package/imports.js.map +1 -0
- package/math.d.ts +1 -1
- package/math.d.ts.map +1 -1
- package/math.js +10 -14
- package/math.js.map +1 -0
- package/media.js +54 -96
- package/media.js.map +1 -0
- package/mobx/apply-observable.d.ts +1 -1
- package/mobx/apply-observable.d.ts.map +1 -1
- package/mobx/create-enhanced-atom.d.ts +2 -2
- package/mobx/create-enhanced-atom.d.ts.map +1 -1
- package/mobx/deep-observable-struct.d.ts +1 -1
- package/mobx/deep-observable-struct.d.ts.map +1 -1
- package/mobx/get-mobx-administration.d.ts +2 -2
- package/mobx/get-mobx-administration.d.ts.map +1 -1
- package/mobx/index.d.ts +5 -5
- package/mobx/index.d.ts.map +1 -1
- package/mobx/lazy-observe.d.ts +6 -0
- package/mobx/lazy-observe.d.ts.map +1 -1
- package/mobx.js +89 -0
- package/mobx.js.map +1 -0
- package/ms.js +12 -17
- package/ms.js.map +1 -0
- package/number.js +9 -12
- package/number.js.map +1 -0
- package/package.json +93 -92
- package/parser/_exports.d.ts +3 -3
- package/parser/_exports.d.ts.map +1 -1
- package/parser/index.d.ts +1 -1
- package/parser/index.d.ts.map +1 -1
- package/parser/number.d.ts +1 -1
- package/parser/number.d.ts.map +1 -1
- package/parser/percent.d.ts +2 -2
- package/parser/percent.d.ts.map +1 -1
- package/parser/string.d.ts +1 -1
- package/parser/string.d.ts.map +1 -1
- package/parser.js +15 -0
- package/parser.js.map +1 -0
- package/price.js +13 -16
- package/price.js.map +1 -0
- package/random.js +11 -13
- package/random.js.map +1 -0
- package/react/hooks/index.d.ts +21 -21
- package/react/hooks/index.d.ts.map +1 -1
- package/react/hooks/use-click-outside.d.ts +1 -1
- package/react/hooks/use-define-ref.d.ts +1 -1
- package/react/hooks/use-element-ref.d.ts +1 -1
- package/react/hooks/use-event.d.ts +1 -1
- package/react/hooks/use-event.d.ts.map +1 -1
- package/react/hooks/use-initial-height.d.ts +1 -1
- package/react/hooks/use-last-value-ref.d.ts +1 -1
- package/react/hooks/use-resize-observer.d.ts +1 -1
- package/react/hooks/use-sync-ref.d.ts +1 -1
- package/react/hooks/use-toggle.d.ts +1 -1
- package/react/hooks/use-value.d.ts +1 -1
- package/react/index.d.ts +1 -1
- package/react/index.d.ts.map +1 -1
- package/react.js +152 -0
- package/react.js.map +1 -0
- package/sound.js +7 -11
- package/sound.js.map +1 -0
- package/text.js +20 -46
- package/text.js.map +1 -0
- package/type-guard/_exports.d.ts +1 -1
- package/type-guard/_exports.d.ts.map +1 -1
- package/type-guard/index.d.ts +1 -1
- package/type-guard/index.d.ts.map +1 -1
- package/type-guard.js +5 -0
- package/type-guard.js.map +1 -0
- package/utility-types.d.ts.map +1 -0
- package/utility-types.js +2 -0
- package/utility-types.js.map +1 -0
- package/utils/types.js +2 -1
- package/utils/types.js.map +1 -0
- package/vibrate.js +6 -7
- package/vibrate.js.map +1 -0
- package/~index-C3wKHvHr.js +80 -0
- package/~index-C3wKHvHr.js.map +1 -0
- package/~number-EWff2XI6.js +25 -0
- package/~number-EWff2XI6.js.map +1 -0
- package/~number-baxVnzrJ.js +32 -0
- package/~number-baxVnzrJ.js.map +1 -0
- package/async.cjs +0 -70
- package/async.d.cts +0 -28
- package/async.d.cts.map +0 -1
- package/common.cjs +0 -18
- package/common.d.cts +0 -15
- package/common.d.cts.map +0 -1
- package/complex/counter.cjs +0 -21
- package/complex/counter.d.cts +0 -15
- package/complex/counter.d.cts.map +0 -1
- package/complex/counter.js +0 -17
- package/complex/global-config.cjs +0 -46
- package/complex/global-config.d.cts +0 -11
- package/complex/global-config.d.cts.map +0 -1
- package/complex/global-config.js +0 -41
- package/complex/index.cjs +0 -19
- package/complex/index.d.cts +0 -4
- package/complex/index.d.cts.map +0 -1
- package/complex/index.js +0 -3
- package/complex/modules-factory.cjs +0 -50
- package/complex/modules-factory.d.cts +0 -49
- package/complex/modules-factory.d.cts.map +0 -1
- package/complex/modules-factory.js +0 -46
- package/cookie.cjs +0 -13
- package/cookie.d.cts +0 -3
- package/cookie.d.cts.map +0 -1
- package/css.cjs +0 -64
- package/css.d.cts +0 -42
- package/css.d.cts.map +0 -1
- package/data.cjs +0 -58
- package/data.d.cts +0 -4
- package/data.d.cts.map +0 -1
- package/date-time.cjs +0 -171
- package/date-time.d.cts +0 -28
- package/date-time.d.cts.map +0 -1
- package/device.cjs +0 -28
- package/device.d.cts +0 -8
- package/device.d.cts.map +0 -1
- package/encodings.cjs +0 -270
- package/encodings.d.cts +0 -2
- package/encodings.d.cts.map +0 -1
- package/errors.cjs +0 -34
- package/errors.d.cts +0 -19
- package/errors.d.cts.map +0 -1
- package/file.cjs +0 -29
- package/file.d.cts +0 -3
- package/file.d.cts.map +0 -1
- package/format/_exports.cjs +0 -20
- package/format/_exports.d.cts +0 -5
- package/format/_exports.d.cts.map +0 -1
- package/format/_exports.js +0 -4
- package/format/constants.cjs +0 -6
- package/format/constants.d.cts +0 -4
- package/format/constants.d.cts.map +0 -1
- package/format/constants.js +0 -3
- package/format/index.cjs +0 -40
- package/format/index.d.cts +0 -3
- package/format/index.d.cts.map +0 -1
- package/format/index.js +0 -4
- package/format/number.cjs +0 -48
- package/format/number.d.cts +0 -36
- package/format/number.d.cts.map +0 -1
- package/format/number.js +0 -44
- package/format/percent.cjs +0 -27
- package/format/percent.d.cts +0 -15
- package/format/percent.d.cts.map +0 -1
- package/format/percent.js +0 -23
- package/format/skip-spaces.cjs +0 -8
- package/format/skip-spaces.d.cts +0 -5
- package/format/skip-spaces.d.cts.map +0 -1
- package/format/skip-spaces.js +0 -4
- package/html.cjs +0 -202
- package/html.d.cts +0 -44
- package/html.d.cts.map +0 -1
- package/id.cjs +0 -76
- package/id.d.cts +0 -63
- package/id.d.cts.map +0 -1
- package/imports.cjs +0 -45
- package/imports.d.cts +0 -15
- package/imports.d.cts.map +0 -1
- package/math.cjs +0 -23
- package/math.d.cts +0 -13
- package/math.d.cts.map +0 -1
- package/media.cjs +0 -115
- package/media.d.cts +0 -20
- package/media.d.cts.map +0 -1
- package/mobx/apply-observable.cjs +0 -16
- package/mobx/apply-observable.d.cts +0 -4
- package/mobx/apply-observable.d.cts.map +0 -1
- package/mobx/apply-observable.js +0 -12
- package/mobx/create-enhanced-atom.cjs +0 -16
- package/mobx/create-enhanced-atom.d.cts +0 -11
- package/mobx/create-enhanced-atom.d.cts.map +0 -1
- package/mobx/create-enhanced-atom.js +0 -12
- package/mobx/deep-observable-struct.cjs +0 -61
- package/mobx/deep-observable-struct.d.cts +0 -7
- package/mobx/deep-observable-struct.d.cts.map +0 -1
- package/mobx/deep-observable-struct.js +0 -57
- package/mobx/get-mobx-administration.cjs +0 -6
- package/mobx/get-mobx-administration.d.cts +0 -6
- package/mobx/get-mobx-administration.d.cts.map +0 -1
- package/mobx/get-mobx-administration.js +0 -2
- package/mobx/index.cjs +0 -21
- package/mobx/index.d.cts +0 -6
- package/mobx/index.d.cts.map +0 -1
- package/mobx/index.js +0 -5
- package/mobx/lazy-observe.cjs +0 -52
- package/mobx/lazy-observe.d.cts +0 -8
- package/mobx/lazy-observe.d.cts.map +0 -1
- package/mobx/lazy-observe.js +0 -48
- package/ms.cjs +0 -22
- package/ms.d.cts +0 -19
- package/ms.d.cts.map +0 -1
- package/number.cjs +0 -16
- package/number.d.cts +0 -8
- package/number.d.cts.map +0 -1
- package/parser/_exports.cjs +0 -19
- package/parser/_exports.d.cts +0 -4
- package/parser/_exports.d.cts.map +0 -1
- package/parser/_exports.js +0 -3
- package/parser/index.cjs +0 -40
- package/parser/index.d.cts +0 -3
- package/parser/index.d.cts.map +0 -1
- package/parser/index.js +0 -4
- package/parser/number.cjs +0 -48
- package/parser/number.d.cts +0 -21
- package/parser/number.d.cts.map +0 -1
- package/parser/number.js +0 -44
- package/parser/percent.cjs +0 -8
- package/parser/percent.d.cts +0 -4
- package/parser/percent.d.cts.map +0 -1
- package/parser/percent.js +0 -4
- package/parser/string.cjs +0 -18
- package/parser/string.d.cts +0 -7
- package/parser/string.d.cts.map +0 -1
- package/parser/string.js +0 -14
- package/price.cjs +0 -21
- package/price.d.cts +0 -6
- package/price.d.cts.map +0 -1
- package/random.cjs +0 -25
- package/random.d.cts +0 -9
- package/random.d.cts.map +0 -1
- package/react/hooks/index.cjs +0 -37
- package/react/hooks/index.d.cts +0 -22
- package/react/hooks/index.d.cts.map +0 -1
- package/react/hooks/index.js +0 -21
- package/react/hooks/use-abort-controller.cjs +0 -15
- package/react/hooks/use-abort-controller.d.cts +0 -2
- package/react/hooks/use-abort-controller.d.cts.map +0 -1
- package/react/hooks/use-abort-controller.js +0 -11
- package/react/hooks/use-abort-signal.cjs +0 -8
- package/react/hooks/use-abort-signal.d.cts +0 -2
- package/react/hooks/use-abort-signal.d.cts.map +0 -1
- package/react/hooks/use-abort-signal.js +0 -4
- package/react/hooks/use-click-outside.cjs +0 -17
- package/react/hooks/use-click-outside.d.cts +0 -9
- package/react/hooks/use-click-outside.d.cts.map +0 -1
- package/react/hooks/use-click-outside.js +0 -13
- package/react/hooks/use-constant.cjs +0 -19
- package/react/hooks/use-constant.d.cts +0 -9
- package/react/hooks/use-constant.d.cts.map +0 -1
- package/react/hooks/use-constant.js +0 -15
- package/react/hooks/use-define-ref.cjs +0 -19
- package/react/hooks/use-define-ref.d.cts +0 -10
- package/react/hooks/use-define-ref.d.cts.map +0 -1
- package/react/hooks/use-define-ref.js +0 -15
- package/react/hooks/use-element-ref.cjs +0 -12
- package/react/hooks/use-element-ref.d.cts +0 -2
- package/react/hooks/use-element-ref.d.cts.map +0 -1
- package/react/hooks/use-element-ref.js +0 -8
- package/react/hooks/use-event-listener.cjs +0 -17
- package/react/hooks/use-event-listener.d.cts +0 -8
- package/react/hooks/use-event-listener.d.cts.map +0 -1
- package/react/hooks/use-event-listener.js +0 -13
- package/react/hooks/use-event.cjs +0 -23
- package/react/hooks/use-event.d.cts +0 -3
- package/react/hooks/use-event.d.cts.map +0 -1
- package/react/hooks/use-event.js +0 -19
- package/react/hooks/use-flag.cjs +0 -19
- package/react/hooks/use-flag.d.cts +0 -8
- package/react/hooks/use-flag.d.cts.map +0 -1
- package/react/hooks/use-flag.js +0 -15
- package/react/hooks/use-force-update.cjs +0 -11
- package/react/hooks/use-force-update.d.cts +0 -2
- package/react/hooks/use-force-update.d.cts.map +0 -1
- package/react/hooks/use-force-update.js +0 -7
- package/react/hooks/use-initial-height.cjs +0 -15
- package/react/hooks/use-initial-height.d.cts +0 -5
- package/react/hooks/use-initial-height.d.cts.map +0 -1
- package/react/hooks/use-initial-height.js +0 -11
- package/react/hooks/use-instance.cjs +0 -31
- package/react/hooks/use-instance.d.cts +0 -27
- package/react/hooks/use-instance.d.cts.map +0 -1
- package/react/hooks/use-instance.js +0 -27
- package/react/hooks/use-intersection-observer.cjs +0 -14
- package/react/hooks/use-intersection-observer.d.cts +0 -2
- package/react/hooks/use-intersection-observer.d.cts.map +0 -1
- package/react/hooks/use-intersection-observer.js +0 -10
- package/react/hooks/use-last-defined-value.cjs +0 -12
- package/react/hooks/use-last-defined-value.d.cts +0 -2
- package/react/hooks/use-last-defined-value.d.cts.map +0 -1
- package/react/hooks/use-last-defined-value.js +0 -8
- package/react/hooks/use-last-value-ref.cjs +0 -12
- package/react/hooks/use-last-value-ref.d.cts +0 -2
- package/react/hooks/use-last-value-ref.d.cts.map +0 -1
- package/react/hooks/use-last-value-ref.js +0 -8
- package/react/hooks/use-life-cycle.cjs +0 -14
- package/react/hooks/use-life-cycle.d.cts +0 -5
- package/react/hooks/use-life-cycle.d.cts.map +0 -1
- package/react/hooks/use-life-cycle.js +0 -10
- package/react/hooks/use-resize-observer.cjs +0 -15
- package/react/hooks/use-resize-observer.d.cts +0 -2
- package/react/hooks/use-resize-observer.d.cts.map +0 -1
- package/react/hooks/use-resize-observer.js +0 -11
- package/react/hooks/use-sync-ref.cjs +0 -10
- package/react/hooks/use-sync-ref.d.cts +0 -2
- package/react/hooks/use-sync-ref.d.cts.map +0 -1
- package/react/hooks/use-sync-ref.js +0 -6
- package/react/hooks/use-toggle.cjs +0 -10
- package/react/hooks/use-toggle.d.cts +0 -2
- package/react/hooks/use-toggle.d.cts.map +0 -1
- package/react/hooks/use-toggle.js +0 -6
- package/react/hooks/use-value.cjs +0 -12
- package/react/hooks/use-value.d.cts +0 -5
- package/react/hooks/use-value.d.cts.map +0 -1
- package/react/hooks/use-value.js +0 -8
- package/react/hooks/use-visibility-state.cjs +0 -18
- package/react/hooks/use-visibility-state.d.cts +0 -2
- package/react/hooks/use-visibility-state.d.cts.map +0 -1
- package/react/hooks/use-visibility-state.js +0 -14
- package/react/index.cjs +0 -17
- package/react/index.d.cts +0 -2
- package/react/index.d.cts.map +0 -1
- package/react/index.js +0 -1
- package/sound.cjs +0 -16
- package/sound.d.cts +0 -7
- package/sound.d.cts.map +0 -1
- package/storage.cjs +0 -48
- package/storage.d.cts +0 -39
- package/storage.d.cts.map +0 -1
- package/storage.js +0 -43
- package/text.cjs +0 -53
- package/text.d.cts +0 -15
- package/text.d.cts.map +0 -1
- package/type-guard/_exports.cjs +0 -129
- package/type-guard/_exports.d.cts +0 -86
- package/type-guard/_exports.d.cts.map +0 -1
- package/type-guard/_exports.js +0 -125
- package/type-guard/index.cjs +0 -40
- package/type-guard/index.d.cts +0 -3
- package/type-guard/index.d.cts.map +0 -1
- package/type-guard/index.js +0 -4
- package/utils/types.cjs +0 -2
- package/utils/types.d.cts +0 -395
- package/utils/types.d.cts.map +0 -1
- package/vibrate.cjs +0 -12
- package/vibrate.d.cts +0 -5
- package/vibrate.d.cts.map +0 -1
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
import { useSyncRef } from "./use-sync-ref.js";
|
|
3
|
-
export const useLifeCycle = (fn) => {
|
|
4
|
-
const fnRef = useSyncRef(fn);
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
const fnOperation = fnRef.current();
|
|
7
|
-
fnOperation.mount?.();
|
|
8
|
-
return fnOperation.unmount?.();
|
|
9
|
-
}, []);
|
|
10
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useResizeObserver = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const use_define_ref_js_1 = require("./use-define-ref.cjs");
|
|
6
|
-
const useResizeObserver = (callback) => {
|
|
7
|
-
const resizeObserverRef = (0, use_define_ref_js_1.useDefineRef)(() => new ResizeObserver(callback));
|
|
8
|
-
(0, react_1.useLayoutEffect)(() => {
|
|
9
|
-
return () => {
|
|
10
|
-
resizeObserverRef.current.disconnect();
|
|
11
|
-
};
|
|
12
|
-
}, []);
|
|
13
|
-
return resizeObserverRef;
|
|
14
|
-
};
|
|
15
|
-
exports.useResizeObserver = useResizeObserver;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-resize-observer.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-resize-observer.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,GAAI,UAAU,sBAAsB,qDAUjE,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { useLayoutEffect } from 'react';
|
|
2
|
-
import { useDefineRef } from "./use-define-ref.js";
|
|
3
|
-
export const useResizeObserver = (callback) => {
|
|
4
|
-
const resizeObserverRef = useDefineRef(() => new ResizeObserver(callback));
|
|
5
|
-
useLayoutEffect(() => {
|
|
6
|
-
return () => {
|
|
7
|
-
resizeObserverRef.current.disconnect();
|
|
8
|
-
};
|
|
9
|
-
}, []);
|
|
10
|
-
return resizeObserverRef;
|
|
11
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useSyncRef = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const useSyncRef = (value) => {
|
|
6
|
-
const ref = (0, react_1.useRef)(value);
|
|
7
|
-
ref.current = value;
|
|
8
|
-
return ref;
|
|
9
|
-
};
|
|
10
|
-
exports.useSyncRef = useSyncRef;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-sync-ref.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-sync-ref.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,GAAI,CAAC,EAAE,OAAO,CAAC,wCAIrC,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useToggle = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const useToggle = (initialState) => {
|
|
6
|
-
const [toggled, setToggled] = (0, react_1.useState)(!!initialState);
|
|
7
|
-
const toggle = (0, react_1.useCallback)(() => setToggled((toggled) => !toggled), []);
|
|
8
|
-
return [toggled, toggle, setToggled];
|
|
9
|
-
};
|
|
10
|
-
exports.useToggle = useToggle;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-toggle.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-toggle.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,GAAI,eAAe,OAAO,sGAM/C,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { useCallback, useState } from 'react';
|
|
2
|
-
export const useToggle = (initialState) => {
|
|
3
|
-
const [toggled, setToggled] = useState(!!initialState);
|
|
4
|
-
const toggle = useCallback(() => setToggled((toggled) => !toggled), []);
|
|
5
|
-
return [toggled, toggle, setToggled];
|
|
6
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useValue = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const useValue = (defaults) => {
|
|
6
|
-
const [value, setValue] = (0, react_1.useState)(defaults);
|
|
7
|
-
return {
|
|
8
|
-
value,
|
|
9
|
-
set: setValue,
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
exports.useValue = useValue;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-value.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-value.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,GAAI,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;;;CAOlD,CAAC"}
|
package/react/hooks/use-value.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useVisibilityState = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const useVisibilityState = () => {
|
|
6
|
-
const [state, setState] = (0, react_1.useState)();
|
|
7
|
-
(0, react_1.useEffect)(() => {
|
|
8
|
-
const handleVisibilityChange = () => {
|
|
9
|
-
setState(document.visibilityState);
|
|
10
|
-
};
|
|
11
|
-
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
12
|
-
return () => {
|
|
13
|
-
document.removeEventListener('visibilitychange', handleVisibilityChange);
|
|
14
|
-
};
|
|
15
|
-
}, []);
|
|
16
|
-
return state;
|
|
17
|
-
};
|
|
18
|
-
exports.useVisibilityState = useVisibilityState;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-visibility-state.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/use-visibility-state.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,2CAgB9B,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
export const useVisibilityState = () => {
|
|
3
|
-
const [state, setState] = useState();
|
|
4
|
-
useEffect(() => {
|
|
5
|
-
const handleVisibilityChange = () => {
|
|
6
|
-
setState(document.visibilityState);
|
|
7
|
-
};
|
|
8
|
-
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
9
|
-
return () => {
|
|
10
|
-
document.removeEventListener('visibilitychange', handleVisibilityChange);
|
|
11
|
-
};
|
|
12
|
-
}, []);
|
|
13
|
-
return state;
|
|
14
|
-
};
|
package/react/index.cjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./hooks/index.cjs"), exports);
|
package/react/index.d.cts
DELETED
package/react/index.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,kCAAiC"}
|
package/react/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./hooks/index.js";
|
package/sound.cjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.playSound = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Воспроизводит звук из файла
|
|
6
|
-
*/
|
|
7
|
-
const playSound = async (file, { volume = 1 } = {}) => {
|
|
8
|
-
let audio = new Audio(file);
|
|
9
|
-
audio.volume = volume;
|
|
10
|
-
audio.muted = !volume;
|
|
11
|
-
await audio.play();
|
|
12
|
-
audio.remove();
|
|
13
|
-
// @ts-expect-error
|
|
14
|
-
audio = null;
|
|
15
|
-
};
|
|
16
|
-
exports.playSound = playSound;
|
package/sound.d.cts
DELETED
package/sound.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sound.d.ts","sourceRoot":"","sources":["../src/sound.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,SAAS,GACpB,MAAM,MAAM,EACZ,aAAgB;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,kBASzC,CAAC"}
|
package/storage.cjs
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createStorageKey = void 0;
|
|
4
|
-
exports.createStorage = createStorage;
|
|
5
|
-
const storages = {
|
|
6
|
-
session: sessionStorage,
|
|
7
|
-
local: localStorage,
|
|
8
|
-
};
|
|
9
|
-
const createStorageKey = (prefix, key, namespace) => `${prefix}${namespace ? `/${namespace}` : ''}/${key}`;
|
|
10
|
-
exports.createStorageKey = createStorageKey;
|
|
11
|
-
const parseStorageValue = (value) => {
|
|
12
|
-
if (typeof value !== 'string') {
|
|
13
|
-
return value;
|
|
14
|
-
}
|
|
15
|
-
try {
|
|
16
|
-
const parsed = JSON.parse(value);
|
|
17
|
-
return parsed;
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
const formatValueToStorage = (value) => {
|
|
24
|
-
return JSON.stringify(value);
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Создает интерфейс для работы с хранилищем (localStorage, sessionStorage)
|
|
28
|
-
*/
|
|
29
|
-
function createStorage(storageConfig) {
|
|
30
|
-
return {
|
|
31
|
-
set: (cfg) => {
|
|
32
|
-
const config = cfg;
|
|
33
|
-
const storageType = (config.type ?? storageConfig.type);
|
|
34
|
-
const storagePrefix = (config.prefix ?? storageConfig.prefix);
|
|
35
|
-
const storage = storages[storageType];
|
|
36
|
-
storage.setItem((0, exports.createStorageKey)(storagePrefix, config.key, config.namespace), formatValueToStorage(config.value));
|
|
37
|
-
},
|
|
38
|
-
get: (cfg) => {
|
|
39
|
-
const config = cfg;
|
|
40
|
-
const storageType = (config.type ?? storageConfig.type);
|
|
41
|
-
const storagePrefix = (config.prefix ?? storageConfig.prefix);
|
|
42
|
-
const storage = storages[storageType];
|
|
43
|
-
return (parseStorageValue(storage.getItem((0, exports.createStorageKey)(storagePrefix, config.key, config.namespace))) ??
|
|
44
|
-
config.fallback ??
|
|
45
|
-
null);
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
}
|
package/storage.d.cts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export type StorageType = 'session' | 'local';
|
|
2
|
-
export declare const createStorageKey: (prefix: string, key: string, namespace?: string) => string;
|
|
3
|
-
export interface SetToStorageConfig<V> extends Omit<GetFromStorageConfig<V>, 'fallback'> {
|
|
4
|
-
value: V;
|
|
5
|
-
}
|
|
6
|
-
export interface GetFromStorageConfig<V> {
|
|
7
|
-
/**
|
|
8
|
-
* Ключ по которому можно получить значение из хранилища (имя ключа не полное, оно дополняется неймпспейсом проекта)
|
|
9
|
-
*/
|
|
10
|
-
key: string;
|
|
11
|
-
/**
|
|
12
|
-
* Тип хранилища
|
|
13
|
-
*/
|
|
14
|
-
type: StorageType;
|
|
15
|
-
/**
|
|
16
|
-
* дефолтное значение, которое будет использоваться если значения нет в хранилище
|
|
17
|
-
*/
|
|
18
|
-
fallback?: V;
|
|
19
|
-
/**
|
|
20
|
-
* Доп. делитель в ключ/utils/types'е
|
|
21
|
-
*/
|
|
22
|
-
namespace?: string;
|
|
23
|
-
/**
|
|
24
|
-
* Доп. делитель
|
|
25
|
-
*/
|
|
26
|
-
prefix?: string;
|
|
27
|
-
}
|
|
28
|
-
export type SetToStorageWrappedConfig<V, BaseConfig extends StorageConfigBase> = Omit<SetToStorageConfig<V>, Extract<keyof SetToStorageConfig<V>, keyof BaseConfig>> & Partial<Pick<SetToStorageConfig<V>, Extract<keyof SetToStorageConfig<V>, keyof BaseConfig>>> & Pick<BaseConfig, Exclude<keyof BaseConfig, keyof SetToStorageConfig<V>>>;
|
|
29
|
-
export type GetFromStorageWrappedConfig<V, BaseConfig extends StorageConfigBase> = Omit<GetFromStorageConfig<V>, Extract<keyof GetFromStorageConfig<V>, keyof BaseConfig>> & Partial<Pick<GetFromStorageConfig<V>, Extract<keyof GetFromStorageConfig<V>, keyof BaseConfig>>> & Pick<BaseConfig, Exclude<keyof BaseConfig, keyof GetFromStorageConfig<V>>>;
|
|
30
|
-
export type StorageConfigBase = Partial<Pick<GetFromStorageConfig<any>, 'prefix' | 'type'>>;
|
|
31
|
-
export interface StorageApi<BaseConfig extends StorageConfigBase> {
|
|
32
|
-
set<Value>(config: SetToStorageWrappedConfig<Value, BaseConfig>): void;
|
|
33
|
-
get<Value>(config: GetFromStorageWrappedConfig<Value, BaseConfig>): Value | null;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Создает интерфейс для работы с хранилищем (localStorage, sessionStorage)
|
|
37
|
-
*/
|
|
38
|
-
export declare function createStorage<BaseConfig extends StorageConfigBase>(storageConfig: BaseConfig): StorageApi<BaseConfig>;
|
|
39
|
-
//# sourceMappingURL=storage.d.ts.map
|
package/storage.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;AAO9C,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,MAAM,EACd,KAAK,MAAM,EACX,YAAY,MAAM,WACsC,CAAC;AAmB3D,MAAM,WAAW,kBAAkB,CAAC,CAAC,CACnC,SAAQ,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC;IACjD,KAAK,EAAE,CAAC,CAAC;CACV;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC;IAClB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC;IACb;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,yBAAyB,CACnC,CAAC,EACD,UAAU,SAAS,iBAAiB,IAClC,IAAI,CACN,kBAAkB,CAAC,CAAC,CAAC,EACrB,OAAO,CAAC,MAAM,kBAAkB,CAAC,CAAC,CAAC,EAAE,MAAM,UAAU,CAAC,CACvD,GACC,OAAO,CACL,IAAI,CACF,kBAAkB,CAAC,CAAC,CAAC,EACrB,OAAO,CAAC,MAAM,kBAAkB,CAAC,CAAC,CAAC,EAAE,MAAM,UAAU,CAAC,CACvD,CACF,GACD,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,MAAM,UAAU,EAAE,MAAM,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3E,MAAM,MAAM,2BAA2B,CACrC,CAAC,EACD,UAAU,SAAS,iBAAiB,IAClC,IAAI,CACN,oBAAoB,CAAC,CAAC,CAAC,EACvB,OAAO,CAAC,MAAM,oBAAoB,CAAC,CAAC,CAAC,EAAE,MAAM,UAAU,CAAC,CACzD,GACC,OAAO,CACL,IAAI,CACF,oBAAoB,CAAC,CAAC,CAAC,EACvB,OAAO,CAAC,MAAM,oBAAoB,CAAC,CAAC,CAAC,EAAE,MAAM,UAAU,CAAC,CACzD,CACF,GACD,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,MAAM,UAAU,EAAE,MAAM,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE7E,MAAM,MAAM,iBAAiB,GAAG,OAAO,CACrC,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC,CACnD,CAAC;AAEF,MAAM,WAAW,UAAU,CAAC,UAAU,SAAS,iBAAiB;IAC9D,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,yBAAyB,CAAC,KAAK,EAAE,UAAU,CAAC,GAAG,IAAI,CAAC;IACvE,GAAG,CAAC,KAAK,EACP,MAAM,EAAE,2BAA2B,CAAC,KAAK,EAAE,UAAU,CAAC,GACrD,KAAK,GAAG,IAAI,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,UAAU,SAAS,iBAAiB,EAChE,aAAa,EAAE,UAAU,GACxB,UAAU,CAAC,UAAU,CAAC,CAgCxB"}
|
package/storage.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
const storages = {
|
|
2
|
-
session: sessionStorage,
|
|
3
|
-
local: localStorage,
|
|
4
|
-
};
|
|
5
|
-
export const createStorageKey = (prefix, key, namespace) => `${prefix}${namespace ? `/${namespace}` : ''}/${key}`;
|
|
6
|
-
const parseStorageValue = (value) => {
|
|
7
|
-
if (typeof value !== 'string') {
|
|
8
|
-
return value;
|
|
9
|
-
}
|
|
10
|
-
try {
|
|
11
|
-
const parsed = JSON.parse(value);
|
|
12
|
-
return parsed;
|
|
13
|
-
}
|
|
14
|
-
catch {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
const formatValueToStorage = (value) => {
|
|
19
|
-
return JSON.stringify(value);
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Создает интерфейс для работы с хранилищем (localStorage, sessionStorage)
|
|
23
|
-
*/
|
|
24
|
-
export function createStorage(storageConfig) {
|
|
25
|
-
return {
|
|
26
|
-
set: (cfg) => {
|
|
27
|
-
const config = cfg;
|
|
28
|
-
const storageType = (config.type ?? storageConfig.type);
|
|
29
|
-
const storagePrefix = (config.prefix ?? storageConfig.prefix);
|
|
30
|
-
const storage = storages[storageType];
|
|
31
|
-
storage.setItem(createStorageKey(storagePrefix, config.key, config.namespace), formatValueToStorage(config.value));
|
|
32
|
-
},
|
|
33
|
-
get: (cfg) => {
|
|
34
|
-
const config = cfg;
|
|
35
|
-
const storageType = (config.type ?? storageConfig.type);
|
|
36
|
-
const storagePrefix = (config.prefix ?? storageConfig.prefix);
|
|
37
|
-
const storage = storages[storageType];
|
|
38
|
-
return (parseStorageValue(storage.getItem(createStorageKey(storagePrefix, config.key, config.namespace))) ??
|
|
39
|
-
config.fallback ??
|
|
40
|
-
null);
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
}
|
package/text.cjs
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.splitTextByLines = exports.declension = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Склонение слова в зависимости от количества
|
|
6
|
-
* @example
|
|
7
|
-
* declension(1, ['слово', 'слова', 'слов']) // 'слово'
|
|
8
|
-
* @example
|
|
9
|
-
* declension(2, ['слово', 'слова', 'слов']) // 'слова'
|
|
10
|
-
* @example
|
|
11
|
-
* declension(5, ['слово', 'слова', 'слов']) // 'слов'
|
|
12
|
-
*/
|
|
13
|
-
const declension = (count, txt, cases = [2, 0, 1, 1, 1, 2]) => txt[count % 100 > 4 && count % 100 < 20 ? 2 : cases[Math.min(count % 10, 5)]];
|
|
14
|
-
exports.declension = declension;
|
|
15
|
-
/**
|
|
16
|
-
* Разбиение текста на линии
|
|
17
|
-
*/
|
|
18
|
-
const splitTextByLines = (text, lineLingth = 60) => {
|
|
19
|
-
const words = text.split(/\s+/).filter((word) => word !== '');
|
|
20
|
-
const lines = [];
|
|
21
|
-
let currentLine = '';
|
|
22
|
-
for (const word of words) {
|
|
23
|
-
if (word.length > lineLingth) {
|
|
24
|
-
if (currentLine !== '') {
|
|
25
|
-
lines.push(currentLine);
|
|
26
|
-
currentLine = '';
|
|
27
|
-
}
|
|
28
|
-
let start = 0;
|
|
29
|
-
while (start < word.length) {
|
|
30
|
-
const chunk = word.slice(start, start + lineLingth);
|
|
31
|
-
lines.push(chunk);
|
|
32
|
-
start += lineLingth;
|
|
33
|
-
}
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
// Проверка возможности добавления слова в текущую строку
|
|
37
|
-
if (currentLine === '') {
|
|
38
|
-
currentLine = word;
|
|
39
|
-
}
|
|
40
|
-
else if (currentLine.length + 1 + word.length <= lineLingth) {
|
|
41
|
-
currentLine += ` ${word}`;
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
lines.push(currentLine);
|
|
45
|
-
currentLine = word;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (currentLine !== '' || lines.length === 0) {
|
|
49
|
-
lines.push(currentLine);
|
|
50
|
-
}
|
|
51
|
-
return lines;
|
|
52
|
-
};
|
|
53
|
-
exports.splitTextByLines = splitTextByLines;
|
package/text.d.cts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Склонение слова в зависимости от количества
|
|
3
|
-
* @example
|
|
4
|
-
* declension(1, ['слово', 'слова', 'слов']) // 'слово'
|
|
5
|
-
* @example
|
|
6
|
-
* declension(2, ['слово', 'слова', 'слов']) // 'слова'
|
|
7
|
-
* @example
|
|
8
|
-
* declension(5, ['слово', 'слова', 'слов']) // 'слов'
|
|
9
|
-
*/
|
|
10
|
-
export declare const declension: (count: number, txt: readonly [one: string, two: string, five: string], cases?: number[]) => string;
|
|
11
|
-
/**
|
|
12
|
-
* Разбиение текста на линии
|
|
13
|
-
*/
|
|
14
|
-
export declare const splitTextByLines: (text: string, lineLingth?: number) => string[];
|
|
15
|
-
//# sourceMappingURL=text.d.ts.map
|
package/text.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,GACrB,OAAO,MAAM,EACb,KAAK,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,EACtD,gBAA0B,WAEmD,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAC3B,MAAM,MAAM,EACZ,aAAY,MAAW,KACtB,MAAM,EAqCR,CAAC"}
|
package/type-guard/_exports.cjs
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSymbol = exports.isInfinite = exports.isNaN = exports.isElement = exports.isRegExp = exports.isFunction = exports.isBoolean = exports.isNumber = exports.isString = exports.isArray = exports.isObject = exports.isUndefined = exports.isNull = exports.isDefined = void 0;
|
|
4
|
-
var Type;
|
|
5
|
-
(function (Type) {
|
|
6
|
-
Type["Null"] = "null";
|
|
7
|
-
Type["Undefined"] = "undefined";
|
|
8
|
-
Type["NaN"] = "nan";
|
|
9
|
-
Type["Object"] = "[object Object]";
|
|
10
|
-
Type["Array"] = "[object Array]";
|
|
11
|
-
Type["String"] = "[object String]";
|
|
12
|
-
Type["Number"] = "[object Number]";
|
|
13
|
-
Type["Boolean"] = "[object Boolean]";
|
|
14
|
-
Type["Function"] = "[object Function]";
|
|
15
|
-
Type["RegExp"] = "[object RegExp]";
|
|
16
|
-
Type["Symbol"] = "[object Symbol]";
|
|
17
|
-
Type["Infinite"] = "infinite";
|
|
18
|
-
Type["Element"] = "element";
|
|
19
|
-
})(Type || (Type = {}));
|
|
20
|
-
function getType(value) {
|
|
21
|
-
if (value === undefined) {
|
|
22
|
-
return Type.Undefined;
|
|
23
|
-
}
|
|
24
|
-
if (value === null) {
|
|
25
|
-
return Type.Null;
|
|
26
|
-
}
|
|
27
|
-
// handle DOM elements
|
|
28
|
-
// @ts-expect-error
|
|
29
|
-
if (value && (value.nodeType === 1 || value.nodeType === 9)) {
|
|
30
|
-
return Type.Element;
|
|
31
|
-
}
|
|
32
|
-
const stringifiedValue = Object.prototype.toString.call(value);
|
|
33
|
-
// handle NaN and Infinity
|
|
34
|
-
if (stringifiedValue === Type.Number) {
|
|
35
|
-
if (Number.isNaN(value)) {
|
|
36
|
-
return Type.NaN;
|
|
37
|
-
}
|
|
38
|
-
if (!Number.isFinite(value)) {
|
|
39
|
-
return Type.Infinite;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return stringifiedValue;
|
|
43
|
-
}
|
|
44
|
-
const createTypeGuard = (type) => (value) => getType(value) === type;
|
|
45
|
-
/**
|
|
46
|
-
* Check if a value is not null or undefined
|
|
47
|
-
* @param value the value to check
|
|
48
|
-
* @returns boolean
|
|
49
|
-
*/
|
|
50
|
-
const isDefined = (value) => value != null;
|
|
51
|
-
exports.isDefined = isDefined;
|
|
52
|
-
/**
|
|
53
|
-
* Check if a value is null
|
|
54
|
-
* @param value the value to check
|
|
55
|
-
* @returns boolean
|
|
56
|
-
*/
|
|
57
|
-
exports.isNull = createTypeGuard(Type.Null);
|
|
58
|
-
/**
|
|
59
|
-
* Check if a value is undefined
|
|
60
|
-
* @param value the value to check
|
|
61
|
-
* @returns boolean
|
|
62
|
-
*/
|
|
63
|
-
exports.isUndefined = createTypeGuard(Type.Undefined);
|
|
64
|
-
/**
|
|
65
|
-
* Check if a value is an object
|
|
66
|
-
* @param value the value to check
|
|
67
|
-
* @returns boolean
|
|
68
|
-
*/
|
|
69
|
-
exports.isObject = createTypeGuard(Type.Object);
|
|
70
|
-
/**
|
|
71
|
-
* Check if a value is an array
|
|
72
|
-
* @param value the value to check
|
|
73
|
-
* @returns boolean
|
|
74
|
-
*/
|
|
75
|
-
exports.isArray = createTypeGuard(Type.Array);
|
|
76
|
-
/**
|
|
77
|
-
* Check if a value is a string
|
|
78
|
-
* @param value the value to check
|
|
79
|
-
* @returns boolean
|
|
80
|
-
*/
|
|
81
|
-
exports.isString = createTypeGuard(Type.String);
|
|
82
|
-
/**
|
|
83
|
-
* Check if a value is a number
|
|
84
|
-
* @param value the value to check
|
|
85
|
-
* @returns boolean
|
|
86
|
-
*/
|
|
87
|
-
exports.isNumber = createTypeGuard(Type.Number);
|
|
88
|
-
/**
|
|
89
|
-
* Check if a value is a boolean
|
|
90
|
-
* @param value the value to check
|
|
91
|
-
* @returns boolean
|
|
92
|
-
*/
|
|
93
|
-
exports.isBoolean = createTypeGuard(Type.Boolean);
|
|
94
|
-
/**
|
|
95
|
-
* Check if a value is a function
|
|
96
|
-
* @param value the value to check
|
|
97
|
-
* @returns boolean
|
|
98
|
-
*/
|
|
99
|
-
exports.isFunction = createTypeGuard(Type.Function);
|
|
100
|
-
/**
|
|
101
|
-
* Check if a value is a regular expression
|
|
102
|
-
* @param value the value to check
|
|
103
|
-
* @returns boolean
|
|
104
|
-
*/
|
|
105
|
-
exports.isRegExp = createTypeGuard(Type.RegExp);
|
|
106
|
-
/**
|
|
107
|
-
* Check if a value is a DOM element
|
|
108
|
-
* @param value the value to check
|
|
109
|
-
* @returns boolean
|
|
110
|
-
*/
|
|
111
|
-
exports.isElement = createTypeGuard(Type.Element);
|
|
112
|
-
/**
|
|
113
|
-
* Check if a value is NaN
|
|
114
|
-
* @param value the value to check
|
|
115
|
-
* @returns boolean
|
|
116
|
-
*/
|
|
117
|
-
exports.isNaN = createTypeGuard(Type.NaN);
|
|
118
|
-
/**
|
|
119
|
-
* Check if a value is infinity
|
|
120
|
-
* @param value the value to check
|
|
121
|
-
* @returns boolean
|
|
122
|
-
*/
|
|
123
|
-
exports.isInfinite = createTypeGuard(Type.Infinite);
|
|
124
|
-
/**
|
|
125
|
-
* Check if a value is a symbol
|
|
126
|
-
* @param value the value to check
|
|
127
|
-
* @returns boolean
|
|
128
|
-
*/
|
|
129
|
-
exports.isSymbol = createTypeGuard(Type.Symbol);
|