yummies 5.4.6 → 5.4.7
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.d.ts +28 -0
- package/async.d.ts.map +1 -0
- package/async.js +62 -0
- package/{src/common.ts → common.d.ts} +3 -14
- package/common.d.ts.map +1 -0
- package/common.js +14 -0
- package/complex/counter.d.ts +15 -0
- package/complex/counter.d.ts.map +1 -0
- package/complex/counter.js +17 -0
- package/complex/global-config.d.ts +11 -0
- package/complex/global-config.d.ts.map +1 -0
- package/complex/global-config.js +41 -0
- package/complex/index.d.ts +4 -0
- package/complex/index.d.ts.map +1 -0
- package/complex/modules-factory.d.ts +49 -0
- package/complex/modules-factory.d.ts.map +1 -0
- package/complex/modules-factory.js +46 -0
- package/cookie.d.ts +3 -0
- package/cookie.d.ts.map +1 -0
- package/cookie.js +9 -0
- package/css.d.ts +36 -0
- package/css.d.ts.map +1 -0
- package/css.js +20 -0
- package/data.d.ts +4 -0
- package/data.d.ts.map +1 -0
- package/data.js +52 -0
- package/date-time.d.ts +28 -0
- package/date-time.d.ts.map +1 -0
- package/date-time.js +160 -0
- package/device.d.ts +8 -0
- package/device.d.ts.map +1 -0
- package/device.js +21 -0
- package/encodings.d.ts +2 -0
- package/encodings.d.ts.map +1 -0
- package/encodings.js +267 -0
- package/errors.d.ts +19 -0
- package/errors.d.ts.map +1 -0
- package/errors.js +30 -0
- package/file.d.ts +3 -0
- package/file.d.ts.map +1 -0
- package/file.js +24 -0
- package/format/_exports.d.ts +5 -0
- package/format/_exports.d.ts.map +1 -0
- package/format/constants.d.ts +4 -0
- package/format/constants.d.ts.map +1 -0
- package/{src/format/constants.ts → format/constants.js} +0 -2
- package/format/index.d.ts +3 -0
- package/format/index.d.ts.map +1 -0
- package/{src/format/index.ts → format/index.js} +0 -1
- package/format/number.d.ts +36 -0
- package/format/number.d.ts.map +1 -0
- package/format/number.js +44 -0
- package/format/percent.d.ts +15 -0
- package/format/percent.d.ts.map +1 -0
- package/format/percent.js +23 -0
- package/format/skip-spaces.d.ts +5 -0
- package/format/skip-spaces.d.ts.map +1 -0
- package/format/skip-spaces.js +4 -0
- package/html.d.ts +44 -0
- package/html.d.ts.map +1 -0
- package/html.js +182 -0
- package/id.d.ts +63 -0
- package/id.d.ts.map +1 -0
- package/{src/id.ts → id.js} +6 -16
- package/imports.d.ts +15 -0
- package/imports.d.ts.map +1 -0
- package/imports.js +40 -0
- package/math.d.ts +13 -0
- package/math.d.ts.map +1 -0
- package/math.js +17 -0
- package/media.d.ts +20 -0
- package/media.d.ts.map +1 -0
- package/media.js +103 -0
- package/mobx/apply-observable.d.ts +4 -0
- package/mobx/apply-observable.d.ts.map +1 -0
- package/mobx/apply-observable.js +12 -0
- package/mobx/create-enhanced-atom.d.ts +11 -0
- package/mobx/create-enhanced-atom.d.ts.map +1 -0
- package/mobx/create-enhanced-atom.js +12 -0
- package/mobx/deep-observable-struct.d.ts +7 -0
- package/mobx/deep-observable-struct.d.ts.map +1 -0
- package/mobx/deep-observable-struct.js +57 -0
- package/mobx/get-mobx-administration.d.ts +6 -0
- package/mobx/get-mobx-administration.d.ts.map +1 -0
- package/mobx/get-mobx-administration.js +2 -0
- package/mobx/index.d.ts +6 -0
- package/mobx/index.d.ts.map +1 -0
- package/mobx/lazy-observe.d.ts +8 -0
- package/mobx/lazy-observe.d.ts.map +1 -0
- package/mobx/lazy-observe.js +43 -0
- package/ms.d.ts +19 -0
- package/ms.d.ts.map +1 -0
- package/ms.js +18 -0
- package/number.d.ts +8 -0
- package/number.d.ts.map +1 -0
- package/number.js +13 -0
- package/package.json +399 -3
- package/parser/_exports.d.ts +4 -0
- package/parser/_exports.d.ts.map +1 -0
- package/parser/index.d.ts +3 -0
- package/parser/index.d.ts.map +1 -0
- package/{src/parser/index.ts → parser/index.js} +0 -1
- package/parser/number.d.ts +21 -0
- package/parser/number.d.ts.map +1 -0
- package/parser/number.js +44 -0
- package/parser/percent.d.ts +4 -0
- package/parser/percent.d.ts.map +1 -0
- package/parser/percent.js +4 -0
- package/parser/string.d.ts +7 -0
- package/parser/string.d.ts.map +1 -0
- package/parser/string.js +14 -0
- package/price.d.ts +6 -0
- package/price.d.ts.map +1 -0
- package/price.js +17 -0
- package/random.d.ts +9 -0
- package/random.d.ts.map +1 -0
- package/random.js +14 -0
- package/react/hooks/index.d.ts +22 -0
- package/react/hooks/index.d.ts.map +1 -0
- package/react/hooks/use-abort-controller.d.ts +2 -0
- package/react/hooks/use-abort-controller.d.ts.map +1 -0
- package/react/hooks/use-abort-controller.js +11 -0
- package/react/hooks/use-abort-signal.d.ts +2 -0
- package/react/hooks/use-abort-signal.d.ts.map +1 -0
- package/{src/react/hooks/use-abort-signal.ts → react/hooks/use-abort-signal.js} +1 -2
- package/react/hooks/use-click-outside.d.ts +9 -0
- package/react/hooks/use-click-outside.d.ts.map +1 -0
- package/react/hooks/use-click-outside.js +13 -0
- package/react/hooks/use-constant.d.ts +9 -0
- package/react/hooks/use-constant.d.ts.map +1 -0
- package/{src/react/hooks/use-constant.ts → react/hooks/use-constant.js} +6 -9
- package/react/hooks/use-define-ref.d.ts +10 -0
- package/react/hooks/use-define-ref.d.ts.map +1 -0
- package/{src/react/hooks/use-define-ref.ts → react/hooks/use-define-ref.js} +7 -10
- package/react/hooks/use-element-ref.d.ts +2 -0
- package/react/hooks/use-element-ref.d.ts.map +1 -0
- package/react/hooks/use-element-ref.js +8 -0
- package/react/hooks/use-event-listener.d.ts +8 -0
- package/react/hooks/use-event-listener.d.ts.map +1 -0
- package/react/hooks/use-event-listener.js +13 -0
- package/react/hooks/use-event.d.ts +3 -0
- package/react/hooks/use-event.d.ts.map +1 -0
- package/react/hooks/use-event.js +19 -0
- package/react/hooks/use-flag.d.ts +8 -0
- package/react/hooks/use-flag.d.ts.map +1 -0
- package/react/hooks/use-flag.js +15 -0
- package/react/hooks/use-force-update.d.ts +2 -0
- package/react/hooks/use-force-update.d.ts.map +1 -0
- package/react/hooks/use-force-update.js +7 -0
- package/react/hooks/use-initial-height.d.ts +5 -0
- package/react/hooks/use-initial-height.d.ts.map +1 -0
- package/react/hooks/use-initial-height.js +11 -0
- package/react/hooks/use-instance.d.ts +27 -0
- package/react/hooks/use-instance.d.ts.map +1 -0
- package/{src/react/hooks/use-instance.ts → react/hooks/use-instance.js} +7 -29
- package/react/hooks/use-intersection-observer.d.ts +2 -0
- package/react/hooks/use-intersection-observer.d.ts.map +1 -0
- package/react/hooks/use-intersection-observer.js +10 -0
- package/react/hooks/use-last-defined-value.d.ts +2 -0
- package/react/hooks/use-last-defined-value.d.ts.map +1 -0
- package/react/hooks/use-last-defined-value.js +8 -0
- package/react/hooks/use-last-value-ref.d.ts +2 -0
- package/react/hooks/use-last-value-ref.d.ts.map +1 -0
- package/react/hooks/use-last-value-ref.js +8 -0
- package/react/hooks/use-life-cycle.d.ts +5 -0
- package/react/hooks/use-life-cycle.d.ts.map +1 -0
- package/react/hooks/use-life-cycle.js +10 -0
- package/react/hooks/use-resize-observer.d.ts +2 -0
- package/react/hooks/use-resize-observer.d.ts.map +1 -0
- package/react/hooks/use-resize-observer.js +11 -0
- package/react/hooks/use-sync-ref.d.ts +2 -0
- package/react/hooks/use-sync-ref.d.ts.map +1 -0
- package/react/hooks/use-sync-ref.js +6 -0
- package/react/hooks/use-toggle.d.ts +2 -0
- package/react/hooks/use-toggle.d.ts.map +1 -0
- package/react/hooks/use-toggle.js +6 -0
- package/react/hooks/use-value.d.ts +5 -0
- package/react/hooks/use-value.d.ts.map +1 -0
- package/react/hooks/use-value.js +8 -0
- package/react/hooks/use-visibility-state.d.ts +2 -0
- package/react/hooks/use-visibility-state.d.ts.map +1 -0
- package/react/hooks/use-visibility-state.js +14 -0
- package/react/index.d.ts +2 -0
- package/react/index.d.ts.map +1 -0
- package/sound.d.ts +7 -0
- package/sound.d.ts.map +1 -0
- package/sound.js +12 -0
- package/storage.d.ts +39 -0
- package/storage.d.ts.map +1 -0
- package/storage.js +43 -0
- package/text.d.ts +15 -0
- package/text.d.ts.map +1 -0
- package/text.js +48 -0
- package/type-guard/_exports.d.ts +86 -0
- package/type-guard/_exports.d.ts.map +1 -0
- package/type-guard/_exports.js +125 -0
- package/type-guard/index.d.ts +3 -0
- package/type-guard/index.d.ts.map +1 -0
- package/{src/type-guard/index.ts → type-guard/index.js} +0 -1
- package/utility-types.d.ts +395 -0
- package/utils/types.d.ts +395 -0
- package/utils/types.d.ts.map +1 -0
- package/utils/types.js +1 -0
- package/vibrate.d.ts +5 -0
- package/vibrate.d.ts.map +1 -0
- package/vibrate.js +8 -0
- package/.changeset/README.md +0 -8
- package/.changeset/config.json +0 -11
- package/.github/FUNDING.yml +0 -1
- package/.github/workflows/main.yml +0 -34
- package/.github/workflows/version-or-publish.yml +0 -45
- package/.nvmrc +0 -1
- package/.vscode/settings.json +0 -19
- package/CHANGELOG.md +0 -215
- package/CONTRIBUTING.md +0 -8
- package/Makefile +0 -7
- package/biome.json +0 -3
- package/commitfmt.toml +0 -18
- package/lefthook.yml +0 -14
- package/scripts/post-build.ts +0 -71
- package/src/async.ts +0 -86
- package/src/complex/counter.test.ts +0 -41
- package/src/complex/counter.ts +0 -40
- package/src/complex/global-config.ts +0 -55
- package/src/complex/modules-factory.ts +0 -65
- package/src/cookie.ts +0 -11
- package/src/css.ts +0 -60
- package/src/data.test.ts +0 -99
- package/src/data.ts +0 -65
- package/src/date-time.test.ts +0 -119
- package/src/date-time.ts +0 -236
- package/src/device.ts +0 -42
- package/src/encodings.ts +0 -270
- package/src/errors.ts +0 -40
- package/src/file.ts +0 -25
- package/src/format/number.test.ts +0 -16
- package/src/format/number.ts +0 -96
- package/src/format/percent.ts +0 -40
- package/src/format/skip-spaces.ts +0 -4
- package/src/html.ts +0 -238
- package/src/imports.ts +0 -52
- package/src/math.ts +0 -20
- package/src/media.ts +0 -134
- package/src/mobx/apply-observable.ts +0 -20
- package/src/mobx/create-enhanced-atom.ts +0 -28
- package/src/mobx/deep-observable-struct.test.ts +0 -69
- package/src/mobx/deep-observable-struct.ts +0 -69
- package/src/mobx/get-mobx-administration.ts +0 -10
- package/src/mobx/lazy-observe.ts +0 -59
- package/src/ms.ts +0 -20
- package/src/number.ts +0 -14
- package/src/parser/number.test.ts +0 -38
- package/src/parser/number.ts +0 -73
- package/src/parser/percent.ts +0 -11
- package/src/parser/string.ts +0 -29
- package/src/price.ts +0 -33
- package/src/random.ts +0 -27
- package/src/react/hooks/use-abort-controller.ts +0 -15
- package/src/react/hooks/use-click-outside.ts +0 -27
- package/src/react/hooks/use-element-ref.ts +0 -11
- package/src/react/hooks/use-event-listener.ts +0 -29
- package/src/react/hooks/use-event.ts +0 -23
- package/src/react/hooks/use-flag.ts +0 -27
- package/src/react/hooks/use-force-update.ts +0 -9
- package/src/react/hooks/use-initial-height.ts +0 -16
- package/src/react/hooks/use-intersection-observer.ts +0 -18
- package/src/react/hooks/use-last-defined-value.ts +0 -9
- package/src/react/hooks/use-last-value-ref.ts +0 -11
- package/src/react/hooks/use-life-cycle.ts +0 -17
- package/src/react/hooks/use-resize-observer.ts +0 -14
- package/src/react/hooks/use-sync-ref.ts +0 -7
- package/src/react/hooks/use-toggle.ts +0 -9
- package/src/react/hooks/use-value.ts +0 -10
- package/src/react/hooks/use-visibility-state.ts +0 -19
- package/src/sound.ts +0 -15
- package/src/storage.ts +0 -137
- package/src/text.test.ts +0 -91
- package/src/text.ts +0 -60
- package/src/type-guard/_exports.ts +0 -154
- package/src/type-guard/index.test.ts +0 -127
- package/src/vibrate.ts +0 -8
- package/tsconfig.json +0 -26
- package/tsconfig.test.json +0 -33
- package/vitest.config.ts +0 -20
- /package/{src/complex/index.ts → complex/index.js} +0 -0
- /package/{src/format/_exports.ts → format/_exports.js} +0 -0
- /package/{src/mobx/index.ts → mobx/index.js} +0 -0
- /package/{src/parser/_exports.ts → parser/_exports.js} +0 -0
- /package/{src/react/hooks/index.ts → react/hooks/index.js} +0 -0
- /package/{src/react/index.ts → react/index.js} +0 -0
package/storage.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
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.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
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.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
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/text.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Склонение слова в зависимости от количества
|
|
3
|
+
* @example
|
|
4
|
+
* declension(1, ['слово', 'слова', 'слов']) // 'слово'
|
|
5
|
+
* @example
|
|
6
|
+
* declension(2, ['слово', 'слова', 'слов']) // 'слова'
|
|
7
|
+
* @example
|
|
8
|
+
* declension(5, ['слово', 'слова', 'слов']) // 'слов'
|
|
9
|
+
*/
|
|
10
|
+
export 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)]];
|
|
11
|
+
/**
|
|
12
|
+
* Разбиение текста на линии
|
|
13
|
+
*/
|
|
14
|
+
export const splitTextByLines = (text, lineLingth = 60) => {
|
|
15
|
+
const words = text.split(/\s+/).filter((word) => word !== '');
|
|
16
|
+
const lines = [];
|
|
17
|
+
let currentLine = '';
|
|
18
|
+
for (const word of words) {
|
|
19
|
+
if (word.length > lineLingth) {
|
|
20
|
+
if (currentLine !== '') {
|
|
21
|
+
lines.push(currentLine);
|
|
22
|
+
currentLine = '';
|
|
23
|
+
}
|
|
24
|
+
let start = 0;
|
|
25
|
+
while (start < word.length) {
|
|
26
|
+
const chunk = word.slice(start, start + lineLingth);
|
|
27
|
+
lines.push(chunk);
|
|
28
|
+
start += lineLingth;
|
|
29
|
+
}
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
// Проверка возможности добавления слова в текущую строку
|
|
33
|
+
if (currentLine === '') {
|
|
34
|
+
currentLine = word;
|
|
35
|
+
}
|
|
36
|
+
else if (currentLine.length + 1 + word.length <= lineLingth) {
|
|
37
|
+
currentLine += ` ${word}`;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
lines.push(currentLine);
|
|
41
|
+
currentLine = word;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (currentLine !== '' || lines.length === 0) {
|
|
45
|
+
lines.push(currentLine);
|
|
46
|
+
}
|
|
47
|
+
return lines;
|
|
48
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { AnyFunction, AnyObject } from '../utils/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Check if a value is not null or undefined
|
|
4
|
+
* @param value the value to check
|
|
5
|
+
* @returns boolean
|
|
6
|
+
*/
|
|
7
|
+
export declare const isDefined: <T>(value: T | undefined | null) => value is T;
|
|
8
|
+
/**
|
|
9
|
+
* Check if a value is null
|
|
10
|
+
* @param value the value to check
|
|
11
|
+
* @returns boolean
|
|
12
|
+
*/
|
|
13
|
+
export declare const isNull: (value: unknown) => value is null;
|
|
14
|
+
/**
|
|
15
|
+
* Check if a value is undefined
|
|
16
|
+
* @param value the value to check
|
|
17
|
+
* @returns boolean
|
|
18
|
+
*/
|
|
19
|
+
export declare const isUndefined: (value: unknown) => value is undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Check if a value is an object
|
|
22
|
+
* @param value the value to check
|
|
23
|
+
* @returns boolean
|
|
24
|
+
*/
|
|
25
|
+
export declare const isObject: (value: unknown) => value is AnyObject;
|
|
26
|
+
/**
|
|
27
|
+
* Check if a value is an array
|
|
28
|
+
* @param value the value to check
|
|
29
|
+
* @returns boolean
|
|
30
|
+
*/
|
|
31
|
+
export declare const isArray: (value: unknown) => value is unknown[];
|
|
32
|
+
/**
|
|
33
|
+
* Check if a value is a string
|
|
34
|
+
* @param value the value to check
|
|
35
|
+
* @returns boolean
|
|
36
|
+
*/
|
|
37
|
+
export declare const isString: (value: unknown) => value is string;
|
|
38
|
+
/**
|
|
39
|
+
* Check if a value is a number
|
|
40
|
+
* @param value the value to check
|
|
41
|
+
* @returns boolean
|
|
42
|
+
*/
|
|
43
|
+
export declare const isNumber: (value: unknown) => value is number;
|
|
44
|
+
/**
|
|
45
|
+
* Check if a value is a boolean
|
|
46
|
+
* @param value the value to check
|
|
47
|
+
* @returns boolean
|
|
48
|
+
*/
|
|
49
|
+
export declare const isBoolean: (value: unknown) => value is boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Check if a value is a function
|
|
52
|
+
* @param value the value to check
|
|
53
|
+
* @returns boolean
|
|
54
|
+
*/
|
|
55
|
+
export declare const isFunction: (value: unknown) => value is AnyFunction;
|
|
56
|
+
/**
|
|
57
|
+
* Check if a value is a regular expression
|
|
58
|
+
* @param value the value to check
|
|
59
|
+
* @returns boolean
|
|
60
|
+
*/
|
|
61
|
+
export declare const isRegExp: (value: unknown) => value is RegExp;
|
|
62
|
+
/**
|
|
63
|
+
* Check if a value is a DOM element
|
|
64
|
+
* @param value the value to check
|
|
65
|
+
* @returns boolean
|
|
66
|
+
*/
|
|
67
|
+
export declare const isElement: (value: unknown) => value is HTMLElement;
|
|
68
|
+
/**
|
|
69
|
+
* Check if a value is NaN
|
|
70
|
+
* @param value the value to check
|
|
71
|
+
* @returns boolean
|
|
72
|
+
*/
|
|
73
|
+
export declare const isNaN: (value: unknown) => boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Check if a value is infinity
|
|
76
|
+
* @param value the value to check
|
|
77
|
+
* @returns boolean
|
|
78
|
+
*/
|
|
79
|
+
export declare const isInfinite: (value: unknown) => boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Check if a value is a symbol
|
|
82
|
+
* @param value the value to check
|
|
83
|
+
* @returns boolean
|
|
84
|
+
*/
|
|
85
|
+
export declare const isSymbol: (value: unknown) => value is symbol;
|
|
86
|
+
//# sourceMappingURL=_exports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_exports.d.ts","sourceRoot":"","sources":["../../src/type-guard/_exports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAoDhE;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,IAAI,KAAG,KAAK,IAAI,CACrD,CAAC;AAEhB;;;;GAIG;AACH,eAAO,MAAM,MAAM,UAhBT,OAAO,KAAG,KAAK,QAgB6B,CAAC;AAEvD;;;;GAIG;AACH,eAAO,MAAM,WAAW,UAvBd,OAAO,KAAG,KAAK,aAuB4C,CAAC;AAEtE;;;;GAIG;AACH,eAAO,MAAM,QAAQ,UA9BX,OAAO,KAAG,KAAK,aA8BsC,CAAC;AAEhE;;;;GAIG;AACH,eAAO,MAAM,OAAO,UArCV,OAAO,KAAG,KAAK,aAqCoC,CAAC;AAE9D;;;;GAIG;AACH,eAAO,MAAM,QAAQ,UA5CX,OAAO,KAAG,KAAK,UA4CmC,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,QAAQ,UAnDX,OAAO,KAAG,KAAK,UAmDmC,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,SAAS,UA1DZ,OAAO,KAAG,KAAK,WA0DsC,CAAC;AAEhE;;;;GAIG;AACH,eAAO,MAAM,UAAU,UAjEb,OAAO,KAAG,KAAK,eAiE4C,CAAC;AAEtE;;;;GAIG;AACH,eAAO,MAAM,QAAQ,UAxEX,OAAO,KAAG,KAAK,UAwEmC,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,SAAS,UA/EZ,OAAO,KAAG,KAAK,eA+E0C,CAAC;AAEpE;;;;GAIG;AACH,eAAO,MAAM,KAAK,EAAwC,CACxD,KAAK,EAAE,OAAO,KACX,OAAO,CAAC;AAEb;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAA6C,CAClE,KAAK,EAAE,OAAO,KACX,OAAO,CAAC;AAEb;;;;GAIG;AACH,eAAO,MAAM,QAAQ,UAxGX,OAAO,KAAG,KAAK,UAwGmC,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
var Type;
|
|
2
|
+
(function (Type) {
|
|
3
|
+
Type["Null"] = "null";
|
|
4
|
+
Type["Undefined"] = "undefined";
|
|
5
|
+
Type["NaN"] = "nan";
|
|
6
|
+
Type["Object"] = "[object Object]";
|
|
7
|
+
Type["Array"] = "[object Array]";
|
|
8
|
+
Type["String"] = "[object String]";
|
|
9
|
+
Type["Number"] = "[object Number]";
|
|
10
|
+
Type["Boolean"] = "[object Boolean]";
|
|
11
|
+
Type["Function"] = "[object Function]";
|
|
12
|
+
Type["RegExp"] = "[object RegExp]";
|
|
13
|
+
Type["Symbol"] = "[object Symbol]";
|
|
14
|
+
Type["Infinite"] = "infinite";
|
|
15
|
+
Type["Element"] = "element";
|
|
16
|
+
})(Type || (Type = {}));
|
|
17
|
+
function getType(value) {
|
|
18
|
+
if (value === undefined) {
|
|
19
|
+
return Type.Undefined;
|
|
20
|
+
}
|
|
21
|
+
if (value === null) {
|
|
22
|
+
return Type.Null;
|
|
23
|
+
}
|
|
24
|
+
// handle DOM elements
|
|
25
|
+
// @ts-expect-error
|
|
26
|
+
if (value && (value.nodeType === 1 || value.nodeType === 9)) {
|
|
27
|
+
return Type.Element;
|
|
28
|
+
}
|
|
29
|
+
const stringifiedValue = Object.prototype.toString.call(value);
|
|
30
|
+
// handle NaN and Infinity
|
|
31
|
+
if (stringifiedValue === Type.Number) {
|
|
32
|
+
if (Number.isNaN(value)) {
|
|
33
|
+
return Type.NaN;
|
|
34
|
+
}
|
|
35
|
+
if (!Number.isFinite(value)) {
|
|
36
|
+
return Type.Infinite;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return stringifiedValue;
|
|
40
|
+
}
|
|
41
|
+
const createTypeGuard = (type) => (value) => getType(value) === type;
|
|
42
|
+
/**
|
|
43
|
+
* Check if a value is not null or undefined
|
|
44
|
+
* @param value the value to check
|
|
45
|
+
* @returns boolean
|
|
46
|
+
*/
|
|
47
|
+
export const isDefined = (value) => value != null;
|
|
48
|
+
/**
|
|
49
|
+
* Check if a value is null
|
|
50
|
+
* @param value the value to check
|
|
51
|
+
* @returns boolean
|
|
52
|
+
*/
|
|
53
|
+
export const isNull = createTypeGuard(Type.Null);
|
|
54
|
+
/**
|
|
55
|
+
* Check if a value is undefined
|
|
56
|
+
* @param value the value to check
|
|
57
|
+
* @returns boolean
|
|
58
|
+
*/
|
|
59
|
+
export const isUndefined = createTypeGuard(Type.Undefined);
|
|
60
|
+
/**
|
|
61
|
+
* Check if a value is an object
|
|
62
|
+
* @param value the value to check
|
|
63
|
+
* @returns boolean
|
|
64
|
+
*/
|
|
65
|
+
export const isObject = createTypeGuard(Type.Object);
|
|
66
|
+
/**
|
|
67
|
+
* Check if a value is an array
|
|
68
|
+
* @param value the value to check
|
|
69
|
+
* @returns boolean
|
|
70
|
+
*/
|
|
71
|
+
export const isArray = createTypeGuard(Type.Array);
|
|
72
|
+
/**
|
|
73
|
+
* Check if a value is a string
|
|
74
|
+
* @param value the value to check
|
|
75
|
+
* @returns boolean
|
|
76
|
+
*/
|
|
77
|
+
export const isString = createTypeGuard(Type.String);
|
|
78
|
+
/**
|
|
79
|
+
* Check if a value is a number
|
|
80
|
+
* @param value the value to check
|
|
81
|
+
* @returns boolean
|
|
82
|
+
*/
|
|
83
|
+
export const isNumber = createTypeGuard(Type.Number);
|
|
84
|
+
/**
|
|
85
|
+
* Check if a value is a boolean
|
|
86
|
+
* @param value the value to check
|
|
87
|
+
* @returns boolean
|
|
88
|
+
*/
|
|
89
|
+
export const isBoolean = createTypeGuard(Type.Boolean);
|
|
90
|
+
/**
|
|
91
|
+
* Check if a value is a function
|
|
92
|
+
* @param value the value to check
|
|
93
|
+
* @returns boolean
|
|
94
|
+
*/
|
|
95
|
+
export const isFunction = createTypeGuard(Type.Function);
|
|
96
|
+
/**
|
|
97
|
+
* Check if a value is a regular expression
|
|
98
|
+
* @param value the value to check
|
|
99
|
+
* @returns boolean
|
|
100
|
+
*/
|
|
101
|
+
export const isRegExp = createTypeGuard(Type.RegExp);
|
|
102
|
+
/**
|
|
103
|
+
* Check if a value is a DOM element
|
|
104
|
+
* @param value the value to check
|
|
105
|
+
* @returns boolean
|
|
106
|
+
*/
|
|
107
|
+
export const isElement = createTypeGuard(Type.Element);
|
|
108
|
+
/**
|
|
109
|
+
* Check if a value is NaN
|
|
110
|
+
* @param value the value to check
|
|
111
|
+
* @returns boolean
|
|
112
|
+
*/
|
|
113
|
+
export const isNaN = createTypeGuard(Type.NaN);
|
|
114
|
+
/**
|
|
115
|
+
* Check if a value is infinity
|
|
116
|
+
* @param value the value to check
|
|
117
|
+
* @returns boolean
|
|
118
|
+
*/
|
|
119
|
+
export const isInfinite = createTypeGuard(Type.Infinite);
|
|
120
|
+
/**
|
|
121
|
+
* Check if a value is a symbol
|
|
122
|
+
* @param value the value to check
|
|
123
|
+
* @returns boolean
|
|
124
|
+
*/
|
|
125
|
+
export const isSymbol = createTypeGuard(Type.Symbol);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/type-guard/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,SAAS,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,CAAC"}
|