@design-edito/tools 0.0.33 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- package/agnostic/arrays/index.d.ts +11 -0
- package/{utils/agnostic → agnostic/arrays}/is-array-of/index.d.ts +2 -2
- package/agnostic/arrays/is-array-of/index.js +23 -0
- package/agnostic/async/index.d.ts +8 -0
- package/agnostic/async/index.js +20 -0
- package/agnostic/async/timeout-call/index.d.ts +1 -0
- package/agnostic/async/timeout-call/index.js +6 -0
- package/agnostic/async/transitions/index.d.ts +41 -0
- package/agnostic/async/transitions/index.js +7 -0
- package/agnostic/async/wait/index.d.ts +1 -0
- package/agnostic/async/wait/index.js +6 -0
- package/agnostic/booleans/index.d.ts +8 -0
- package/agnostic/booleans/index.js +17 -0
- package/{utils/agnostic → agnostic/booleans}/is-falsy/index.d.ts +1 -2
- package/agnostic/booleans/is-falsy/index.js +11 -0
- package/agnostic/css/bem/index.d.ts +7 -0
- package/agnostic/css/bem/index.js +9 -0
- package/{utils/agnostic → agnostic/css}/generate-nice-color/index.d.ts +0 -1
- package/agnostic/css/generate-nice-color/index.js +8 -0
- package/agnostic/css/index.d.ts +14 -0
- package/agnostic/css/index.js +177 -0
- package/agnostic/css/is-valid-css-class-name/index.d.ts +2 -0
- package/agnostic/css/is-valid-css-class-name/index.js +8 -0
- package/agnostic/css/styles-set/index.d.ts +37 -0
- package/agnostic/errors/index.d.ts +30 -0
- package/agnostic/errors/index.js +6 -0
- package/agnostic/html/get-node-ancestors/index.d.ts +1 -0
- package/agnostic/html/get-node-ancestors/index.js +6 -0
- package/agnostic/html/get-position-inside-parent/index.d.ts +1 -0
- package/agnostic/html/get-position-inside-parent/index.js +6 -0
- package/agnostic/html/index.d.ts +17 -0
- package/agnostic/html/index.js +39 -0
- package/agnostic/html/insert-node/index.d.ts +2 -0
- package/agnostic/html/insert-node/index.js +6 -0
- package/agnostic/html/placeholders/index.d.ts +9 -0
- package/agnostic/html/placeholders/index.js +6 -0
- package/agnostic/html/sanitize/index.d.ts +24 -0
- package/agnostic/html/sanitize/index.js +9 -0
- package/agnostic/html/selector-to-element/index.d.ts +1 -0
- package/agnostic/html/selector-to-element/index.js +9 -0
- package/agnostic/html/string-to-nodes/index.d.ts +7 -0
- package/agnostic/html/string-to-nodes/index.js +10 -0
- package/agnostic/index.d.ts +26 -0
- package/agnostic/misc/assert/index.d.ts +5 -0
- package/agnostic/misc/assert/index.js +6 -0
- package/agnostic/misc/cast/index.d.ts +9 -0
- package/agnostic/misc/cast/index.js +8 -0
- package/agnostic/misc/crossenv/index.d.ts +13 -0
- package/agnostic/misc/crossenv/index.js +6 -0
- package/agnostic/misc/get-current-downlink/index.d.ts +1 -0
- package/agnostic/misc/get-current-downlink/index.js +6 -0
- package/agnostic/misc/index.d.ts +22 -0
- package/agnostic/misc/index.js +45 -0
- package/{utils/agnostic → agnostic/misc}/is-constructor-function/index.d.ts +1 -1
- package/agnostic/misc/is-constructor-function/index.js +6 -0
- package/{utils/agnostic → agnostic/misc}/is-nullish/index.d.ts +0 -1
- package/agnostic/misc/is-nullish/index.js +10 -0
- package/agnostic/misc/logs/index.d.ts +55 -0
- package/agnostic/misc/logs/index.js +6 -0
- package/agnostic/misc/random/index.d.ts +10 -0
- package/agnostic/misc/random/index.js +6 -0
- package/agnostic/numbers/absolute-modulo/index.d.ts +1 -0
- package/agnostic/numbers/absolute-modulo/index.js +6 -0
- package/agnostic/numbers/clamp/index.d.ts +1 -0
- package/agnostic/numbers/clamp/index.js +6 -0
- package/agnostic/numbers/index.d.ts +13 -0
- package/agnostic/numbers/index.js +30 -0
- package/agnostic/numbers/interpolate/index.d.ts +1 -0
- package/agnostic/numbers/interpolate/index.js +6 -0
- package/agnostic/numbers/responsive-harmonics/index.js +9 -0
- package/agnostic/numbers/round/index.d.ts +1 -0
- package/agnostic/numbers/round/index.js +6 -0
- package/agnostic/objects/enums/index.d.ts +4 -0
- package/agnostic/objects/enums/index.js +7 -0
- package/{utils/agnostic → agnostic/objects/enums}/is-in-enum/index.d.ts +1 -1
- package/agnostic/objects/enums/is-in-enum/index.js +6 -0
- package/agnostic/objects/flatten-getters/index.d.ts +1 -0
- package/agnostic/objects/flatten-getters/index.js +9 -0
- package/agnostic/objects/index.d.ts +12 -0
- package/agnostic/objects/index.js +32 -0
- package/agnostic/objects/is-object/index.d.ts +1 -0
- package/agnostic/objects/is-object/index.js +6 -0
- package/agnostic/objects/is-record/index.d.ts +1 -0
- package/agnostic/objects/is-record/index.js +6 -0
- package/agnostic/objects/record-format/index.js +16 -0
- package/agnostic/objects/validation/index.d.ts +3 -0
- package/agnostic/objects/validation/index.js +6 -0
- package/agnostic/optim/index.d.ts +7 -0
- package/agnostic/optim/index.js +18 -0
- package/{utils/agnostic → agnostic/optim}/memoize/index.d.ts +1 -1
- package/agnostic/optim/memoize/index.js +6 -0
- package/agnostic/optim/throttle-debounce/index.js +8 -0
- package/{utils/agnostic → agnostic/optim}/throttle-debounce/types.d.ts +0 -1
- package/agnostic/regexps/index.d.ts +23 -0
- package/agnostic/regexps/index.js +89 -0
- package/agnostic/strings/char-codes/index.d.ts +17 -0
- package/agnostic/strings/char-codes/index.js +6 -0
- package/agnostic/strings/index.d.ts +14 -0
- package/agnostic/strings/index.js +32 -0
- package/agnostic/strings/matches/index.d.ts +3 -0
- package/agnostic/strings/matches/index.js +10 -0
- package/agnostic/strings/normalize-indent/index.d.ts +1 -0
- package/agnostic/strings/normalize-indent/index.js +6 -0
- package/{utils/agnostic → agnostic/strings}/replace-all/index.d.ts +1 -1
- package/agnostic/strings/replace-all/index.js +6 -0
- package/agnostic/strings/to-alphanum/index.d.ts +1 -0
- package/agnostic/strings/to-alphanum/index.js +6 -0
- package/chunks/chunk-32IRF4OP.js +9 -0
- package/chunks/chunk-34U4HX4V.js +73 -0
- package/chunks/chunk-4GDNHUCZ.js +162 -0
- package/chunks/chunk-4QQBKBYH.js +59 -0
- package/chunks/chunk-4VC5PT5T.js +13 -0
- package/chunks/chunk-5LNUCDQ6.js +132 -0
- package/chunks/chunk-7AWTHZLY.js +12 -0
- package/chunks/chunk-7DBNMU6N.js +14 -0
- package/chunks/chunk-COVPTTAD.js +10 -0
- package/chunks/chunk-DNIOWD7K.js +8 -0
- package/chunks/chunk-DQNJQBC6.js +10 -0
- package/chunks/chunk-E6MSDKON.js +13 -0
- package/chunks/chunk-EDVNAV3G.js +72 -0
- package/chunks/chunk-EW46EXFB.js +8 -0
- package/chunks/chunk-FPEW3A27.js +14 -0
- package/chunks/chunk-GJOU3UAL.js +36 -0
- package/chunks/chunk-HC6ZOHCS.js +14 -0
- package/chunks/chunk-HGCG2J77.js +122 -0
- package/chunks/chunk-IFD7GSGK.js +130 -0
- package/chunks/chunk-JQXNEJAP.js +18 -0
- package/chunks/chunk-JWBDZPQG.js +18 -0
- package/chunks/chunk-K37RALUX.js +8 -0
- package/chunks/chunk-KIONYWA7.js +168 -0
- package/chunks/chunk-KQT5CTGF.js +21 -0
- package/chunks/chunk-LEXQ6E6L.js +31 -0
- package/chunks/chunk-LQFKUNVQ.js +19 -0
- package/chunks/chunk-MF56TTC5.js +15 -0
- package/chunks/chunk-MT74WIQR.js +41 -0
- package/chunks/chunk-NRITRUZW.js +10 -0
- package/chunks/chunk-NRJQKVQV.js +31 -0
- package/chunks/chunk-OSAXBA7G.js +10 -0
- package/chunks/chunk-PO3V3I57.js +23 -0
- package/chunks/chunk-QXAJXTXV.js +19 -0
- package/chunks/chunk-RCO57B6F.js +9 -0
- package/chunks/chunk-SQZGZ3VT.js +15 -0
- package/chunks/chunk-UYTXXUU7.js +54 -0
- package/chunks/chunk-VTPRO4NJ.js +10 -0
- package/chunks/chunk-VYW4IADX.js +35 -0
- package/chunks/chunk-VZDUZTW6.js +113 -0
- package/chunks/chunk-W5A2TON3.js +10 -0
- package/chunks/chunk-W7YBGJ4H.js +28 -0
- package/chunks/chunk-WLL3FNVL.js +40 -0
- package/chunks/chunk-WOAYU6LB.js +13 -0
- package/chunks/chunk-XA4HVHJ4.js +18 -0
- package/chunks/chunk-XN3PZIVL.js +38 -0
- package/chunks/chunk-YDIBNEGA.js +9 -0
- package/components/index.d.ts +4 -0
- package/index.d.ts +3 -0
- package/node/files/index.d.ts +9 -0
- package/node/files/index.js +21 -0
- package/node/files/is-in-directory/index.d.ts +1 -0
- package/node/files/is-in-directory/index.js +6 -0
- package/node/files/read-write/index.d.ts +9 -0
- package/node/files/read-write/index.js +6 -0
- package/node/files/subpaths/index.d.ts +34 -0
- package/node/files/subpaths/index.js +7 -0
- package/node/index.d.ts +6 -0
- package/node/process/index.d.ts +8 -0
- package/node/process/index.js +20 -0
- package/{utils/node/process-exit → node/process/on-exit}/index.d.ts +1 -1
- package/node/process/on-exit/index.js +14 -0
- package/package.json +12 -12
- package/shared/errors/index.d.ts +14 -0
- package/shared/index.d.ts +0 -0
- package/chunks/chunk-BEZTX3QU.js +0 -1
- package/chunks/chunk-BW5CY5YB.js +0 -1
- package/chunks/chunk-DIPJ73JH.js +0 -1
- package/chunks/chunk-EFFU6KXJ.js +0 -1
- package/chunks/chunk-KNE7WIIW.js +0 -1
- package/chunks/chunk-LCLAV6Q2.js +0 -1
- package/chunks/chunk-PCAKH6ZJ.js +0 -1
- package/chunks/chunk-QQRJPDR7.js +0 -1
- package/chunks/chunk-WZBNXYN3.js +0 -1
- package/chunks/chunk-XCKXCF4A.js +0 -1
- package/chunks/chunk-ZVJO36JU.js +0 -1
- package/components/Comp/index.js +0 -1
- package/index.js +0 -96
- package/utils/agnostic/absolute-modulo/index.d.ts +0 -1
- package/utils/agnostic/absolute-modulo/index.js +0 -1
- package/utils/agnostic/array/index.d.ts +0 -7
- package/utils/agnostic/array/index.js +0 -1
- package/utils/agnostic/assert/index.d.ts +0 -3
- package/utils/agnostic/assert/index.js +0 -1
- package/utils/agnostic/await-timeout/index.d.ts +0 -2
- package/utils/agnostic/await-timeout/index.js +0 -1
- package/utils/agnostic/bem/index.d.ts +0 -5
- package/utils/agnostic/bem/index.js +0 -1
- package/utils/agnostic/cast/index.d.ts +0 -7
- package/utils/agnostic/cast/index.js +0 -1
- package/utils/agnostic/charcode-string/index.d.ts +0 -2
- package/utils/agnostic/charcode-string/index.js +0 -1
- package/utils/agnostic/clamp/index.d.ts +0 -1
- package/utils/agnostic/clamp/index.js +0 -1
- package/utils/agnostic/clientside-html-sanitizer/index.d.ts +0 -22
- package/utils/agnostic/clientside-html-sanitizer/index.js +0 -1
- package/utils/agnostic/crossenv/index.d.ts +0 -11
- package/utils/agnostic/crossenv/index.js +0 -1
- package/utils/agnostic/flatten-getters/index.d.ts +0 -1
- package/utils/agnostic/flatten-getters/index.js +0 -1
- package/utils/agnostic/generate-html-placeholders/index.d.ts +0 -7
- package/utils/agnostic/generate-html-placeholders/index.js +0 -5
- package/utils/agnostic/generate-nice-color/index.js +0 -1
- package/utils/agnostic/insert-node/index.d.ts +0 -2
- package/utils/agnostic/insert-node/index.js +0 -1
- package/utils/agnostic/interpolate/index.d.ts +0 -3
- package/utils/agnostic/interpolate/index.js +0 -1
- package/utils/agnostic/is-array-of/index.js +0 -1
- package/utils/agnostic/is-constructor-function/index.js +0 -1
- package/utils/agnostic/is-falsy/index.js +0 -1
- package/utils/agnostic/is-in-enum/index.js +0 -1
- package/utils/agnostic/is-nullish/index.js +0 -1
- package/utils/agnostic/is-object/index.d.ts +0 -1
- package/utils/agnostic/is-object/index.js +0 -1
- package/utils/agnostic/is-record/index.d.ts +0 -1
- package/utils/agnostic/is-record/index.js +0 -1
- package/utils/agnostic/is-valid-css-class-name/index.d.ts +0 -2
- package/utils/agnostic/is-valid-css-class-name/index.js +0 -1
- package/utils/agnostic/memoize/index.js +0 -1
- package/utils/agnostic/object-validate-from-partial/index.d.ts +0 -1
- package/utils/agnostic/object-validate-from-partial/index.js +0 -1
- package/utils/agnostic/random/index.d.ts +0 -9
- package/utils/agnostic/random/index.js +0 -1
- package/utils/agnostic/record-format/index.js +0 -1
- package/utils/agnostic/regexp/index.d.ts +0 -21
- package/utils/agnostic/regexp/index.js +0 -1
- package/utils/agnostic/replace-all/index.js +0 -1
- package/utils/agnostic/responsive-harmonics/index.js +0 -1
- package/utils/agnostic/round-numbers/index.d.ts +0 -1
- package/utils/agnostic/round-numbers/index.js +0 -1
- package/utils/agnostic/selector-to-element/index.d.ts +0 -1
- package/utils/agnostic/selector-to-element/index.js +0 -1
- package/utils/agnostic/silent-log/index.d.ts +0 -53
- package/utils/agnostic/silent-log/index.js +0 -9
- package/utils/agnostic/str-to-nodes/index.d.ts +0 -7
- package/utils/agnostic/str-to-nodes/index.js +0 -1
- package/utils/agnostic/string-matches/index.d.ts +0 -4
- package/utils/agnostic/string-matches/index.js +0 -1
- package/utils/agnostic/string-normalize-indent/index.d.ts +0 -1
- package/utils/agnostic/string-normalize-indent/index.js +0 -3
- package/utils/agnostic/throttle-debounce/index.js +0 -1
- package/utils/agnostic/to-alphanum/index.d.ts +0 -1
- package/utils/agnostic/to-alphanum/index.js +0 -1
- package/utils/agnostic/transition/index.d.ts +0 -39
- package/utils/agnostic/transition/index.js +0 -1
- package/utils/agnostic/wait/index.d.ts +0 -1
- package/utils/agnostic/wait/index.js +0 -1
- package/utils/browser/dynamic-css/index.d.ts +0 -4
- package/utils/browser/dynamic-css/index.js +0 -2
- package/utils/browser/get-current-downlink/index.d.ts +0 -1
- package/utils/browser/get-current-downlink/index.js +0 -1
- package/utils/browser/get-node-ancestors/index.d.ts +0 -1
- package/utils/browser/get-node-ancestors/index.js +0 -1
- package/utils/node/is-in-directory/index.d.ts +0 -1
- package/utils/node/is-in-directory/index.js +0 -1
- package/utils/node/list-subpaths/index.d.ts +0 -33
- package/utils/node/list-subpaths/index.js +0 -1
- package/utils/node/process-exit/index.js +0 -1
- package/utils/node/read-write-file/index.d.ts +0 -12
- package/utils/node/read-write-file/index.js +0 -1
- /package/{utils/agnostic → agnostic/css}/bem/BEM.d.ts +0 -0
- /package/{utils/agnostic → agnostic/css}/bem/getNamesArr.d.ts +0 -0
- /package/{utils/agnostic → agnostic/numbers}/responsive-harmonics/index.d.ts +0 -0
- /package/{utils/agnostic → agnostic/objects}/record-format/index.d.ts +0 -0
- /package/{utils/agnostic → agnostic/optim}/throttle-debounce/index.d.ts +0 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
export declare namespace Regexps {
|
2
|
+
function mergeFlags(...flagStrs: string[]): string;
|
3
|
+
function setFlags(regexp: RegExp, _flags: string): RegExp;
|
4
|
+
function fromStart(regexp: RegExp, _flags?: string): RegExp;
|
5
|
+
function toEnd(regexp: RegExp, _flags?: string): RegExp;
|
6
|
+
function fromStartToEnd(regexp: RegExp, _flags?: string): RegExp;
|
7
|
+
function stringStartsWith(string: string, _regexp: RegExp): boolean;
|
8
|
+
function stringStartsWith(string: string, _regexp: RegExp, returnMatches: true): RegExpMatchArray | null;
|
9
|
+
function stringStartsWith(string: string, _regexp: RegExp, returnMatches: false): boolean;
|
10
|
+
function stringStartsWith(string: string, _regexp: RegExp, returnMatches: false, _flags: string): boolean;
|
11
|
+
function stringStartsWith(string: string, _regexp: RegExp, returnMatches: true, _flags: string): RegExpMatchArray | null;
|
12
|
+
function stringEndsWith(string: string, _regexp: RegExp): boolean;
|
13
|
+
function stringEndsWith(string: string, _regexp: RegExp, returnMatches: true): RegExpMatchArray | null;
|
14
|
+
function stringEndsWith(string: string, _regexp: RegExp, returnMatches: false): boolean;
|
15
|
+
function stringEndsWith(string: string, _regexp: RegExp, returnMatches: false, _flags: string): boolean;
|
16
|
+
function stringEndsWith(string: string, _regexp: RegExp, returnMatches: true, _flags: string): RegExpMatchArray | null;
|
17
|
+
function stringIs(string: string, _regexp: RegExp): boolean;
|
18
|
+
function stringIs(string: string, _regexp: RegExp, returnMatches: true): RegExpMatchArray | null;
|
19
|
+
function stringIs(string: string, _regexp: RegExp, returnMatches: false): boolean;
|
20
|
+
function stringIs(string: string, _regexp: RegExp, returnMatches: false, _flags: string): boolean;
|
21
|
+
function stringIs(string: string, _regexp: RegExp, returnMatches: true, _flags: string): RegExpMatchArray | null;
|
22
|
+
function fromStrings(strings: string[]): RegExp;
|
23
|
+
}
|
@@ -0,0 +1,89 @@
|
|
1
|
+
// src/agnostic/regexps/index.ts
|
2
|
+
var Regexps;
|
3
|
+
((Regexps2) => {
|
4
|
+
function mergeFlags(...flagStrs) {
|
5
|
+
const flagsSet = /* @__PURE__ */ new Set();
|
6
|
+
flagStrs.forEach(
|
7
|
+
(flagStr) => flagStr.split("").forEach((char) => flagsSet.add(char))
|
8
|
+
);
|
9
|
+
return Array.from(flagsSet.values()).join("");
|
10
|
+
}
|
11
|
+
Regexps2.mergeFlags = mergeFlags;
|
12
|
+
function setFlags(regexp, _flags) {
|
13
|
+
const flags = mergeFlags(regexp.flags, _flags);
|
14
|
+
return new RegExp(`${regexp.source}`, flags);
|
15
|
+
}
|
16
|
+
Regexps2.setFlags = setFlags;
|
17
|
+
function fromStart(regexp, _flags = "g") {
|
18
|
+
const flags = mergeFlags(regexp.flags, _flags);
|
19
|
+
return new RegExp(`^(${regexp.source})`, flags);
|
20
|
+
}
|
21
|
+
Regexps2.fromStart = fromStart;
|
22
|
+
function toEnd(regexp, _flags = "g") {
|
23
|
+
const flags = mergeFlags(regexp.flags, _flags);
|
24
|
+
return new RegExp(`(${regexp.source})$`, flags);
|
25
|
+
}
|
26
|
+
Regexps2.toEnd = toEnd;
|
27
|
+
function fromStartToEnd(regexp, _flags = "g") {
|
28
|
+
const flags = mergeFlags(regexp.flags, _flags);
|
29
|
+
return fromStart(toEnd(regexp, flags), flags);
|
30
|
+
}
|
31
|
+
Regexps2.fromStartToEnd = fromStartToEnd;
|
32
|
+
function stringStartsWith(string, _regexp, returnMatches = true, _flags = "g") {
|
33
|
+
const regexp = fromStart(_regexp, _flags);
|
34
|
+
return returnMatches ? string.match(regexp) : regexp.test(string);
|
35
|
+
}
|
36
|
+
Regexps2.stringStartsWith = stringStartsWith;
|
37
|
+
function stringEndsWith(string, _regexp, returnMatches = true, _flags = "g") {
|
38
|
+
const regexp = toEnd(_regexp, _flags);
|
39
|
+
return returnMatches ? string.match(regexp) : regexp.test(string);
|
40
|
+
}
|
41
|
+
Regexps2.stringEndsWith = stringEndsWith;
|
42
|
+
function stringIs(string, _regexp, returnMatches = false, _flags = "g") {
|
43
|
+
const regexp = fromStartToEnd(_regexp, _flags);
|
44
|
+
return returnMatches ? string.match(regexp) : regexp.test(string);
|
45
|
+
}
|
46
|
+
Regexps2.stringIs = stringIs;
|
47
|
+
function fromStrings(strings) {
|
48
|
+
const rootsMap = stringsToRootsMap(strings);
|
49
|
+
const source = sourceFromRootsMap(rootsMap, false);
|
50
|
+
const regexp = new RegExp(source);
|
51
|
+
return regexp;
|
52
|
+
}
|
53
|
+
Regexps2.fromStrings = fromStrings;
|
54
|
+
function escape(string) {
|
55
|
+
return string.replace(/\s/igm, "\\s").replace(/\n/igm, "\\n").replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
56
|
+
}
|
57
|
+
function stringsToRootsMap(strings, rootsMap = /* @__PURE__ */ new Map()) {
|
58
|
+
const lengthSorted = strings.sort((strA, strB) => strA.length - strB.length);
|
59
|
+
lengthSorted.forEach((string) => {
|
60
|
+
const [firstChar, ...lastChars] = string.split("");
|
61
|
+
const isWordEnd = lastChars.length === 0;
|
62
|
+
if (firstChar === void 0) return;
|
63
|
+
const roots = Array.from(rootsMap.keys());
|
64
|
+
const foundRoot = roots.find((root) => new RegExp(`^(${escape(root)})`).test(string));
|
65
|
+
const subRootsMap = foundRoot !== void 0 ? rootsMap.get(foundRoot)?.subRootsMap : void 0;
|
66
|
+
if (foundRoot === void 0 || subRootsMap === void 0) {
|
67
|
+
const subRootsMap2 = /* @__PURE__ */ new Map();
|
68
|
+
stringsToRootsMap([lastChars.join("")], subRootsMap2);
|
69
|
+
return rootsMap.set(firstChar, { subRootsMap: subRootsMap2, isWordEnd });
|
70
|
+
}
|
71
|
+
stringsToRootsMap([lastChars.join("")], subRootsMap);
|
72
|
+
});
|
73
|
+
return rootsMap;
|
74
|
+
}
|
75
|
+
function sourceFromRootsMap(rootsMap, isOptional) {
|
76
|
+
const rootsMapEntries = Array.from(rootsMap.entries());
|
77
|
+
if (rootsMapEntries.length === 0) return "";
|
78
|
+
const regexpBody = rootsMapEntries.map(([root, rootData]) => {
|
79
|
+
return `${escape(root)}${sourceFromRootsMap(
|
80
|
+
rootData.subRootsMap,
|
81
|
+
rootData.isWordEnd
|
82
|
+
)}`;
|
83
|
+
}).join("|");
|
84
|
+
return isOptional ? `(${regexpBody})?` : `(${regexpBody})`;
|
85
|
+
}
|
86
|
+
})(Regexps || (Regexps = {}));
|
87
|
+
export {
|
88
|
+
Regexps
|
89
|
+
};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
export declare namespace CharCodes {
|
2
|
+
type CharCode = number;
|
3
|
+
type B36CharCode = string;
|
4
|
+
function charCodeToB36(charCode: CharCode): B36CharCode;
|
5
|
+
function b36CharCodeToCharCode(b36CharCode: B36CharCode): CharCode;
|
6
|
+
function charToCharCode(char: string): CharCode;
|
7
|
+
function charToB36CharCode(char: string): B36CharCode;
|
8
|
+
function charFromCharCode(charCode: CharCode): string;
|
9
|
+
function charFromB36CharCode(b36CharCode: B36CharCode): string;
|
10
|
+
function toCharCodes(string: string): Array<CharCode>;
|
11
|
+
function toB36CharCodes(string: string): Array<B36CharCode>;
|
12
|
+
function fromCharCodes(charCodes: Array<CharCode>): string;
|
13
|
+
function fromB36CharCodes(b36CharCodes: Array<B36CharCode>): string;
|
14
|
+
function serialize(charCodes: Array<CharCode | B36CharCode>): string;
|
15
|
+
function deserialize(serializedCharCodes: string): Array<CharCode>;
|
16
|
+
function fromSerialized(serializedCharCodes: string): string;
|
17
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { CharCodes as CharCodesNamespace } from './char-codes';
|
2
|
+
import { matches as matchesFunc, matchesSome as matchesSomeFunc, matchesEvery as matchesEveryFunc } from './matches';
|
3
|
+
import { replaceAll as replaceAllFunc } from './replace-all';
|
4
|
+
import { normalizeIndent as normalizeIndentFunc } from './normalize-indent';
|
5
|
+
import { toAlphanum as toAlphanumFunc } from './to-alphanum';
|
6
|
+
export declare namespace Strings {
|
7
|
+
export import CharCodes = CharCodesNamespace;
|
8
|
+
const matches: typeof matchesFunc;
|
9
|
+
const matchesSome: typeof matchesSomeFunc;
|
10
|
+
const matchesEvery: typeof matchesEveryFunc;
|
11
|
+
const normalizeIndent: typeof normalizeIndentFunc;
|
12
|
+
const replaceAll: typeof replaceAllFunc;
|
13
|
+
const toAlphanum: typeof toAlphanumFunc;
|
14
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import {
|
2
|
+
CharCodes
|
3
|
+
} from "../../chunks/chunk-34U4HX4V.js";
|
4
|
+
import {
|
5
|
+
normalizeIndent
|
6
|
+
} from "../../chunks/chunk-JQXNEJAP.js";
|
7
|
+
import {
|
8
|
+
replaceAll
|
9
|
+
} from "../../chunks/chunk-MF56TTC5.js";
|
10
|
+
import {
|
11
|
+
matches,
|
12
|
+
matchesEvery,
|
13
|
+
matchesSome
|
14
|
+
} from "../../chunks/chunk-LQFKUNVQ.js";
|
15
|
+
import {
|
16
|
+
toAlphanum
|
17
|
+
} from "../../chunks/chunk-COVPTTAD.js";
|
18
|
+
|
19
|
+
// src/agnostic/strings/index.ts
|
20
|
+
var Strings;
|
21
|
+
((Strings2) => {
|
22
|
+
Strings2.CharCodes = CharCodes;
|
23
|
+
Strings2.matches = matches;
|
24
|
+
Strings2.matchesSome = matchesSome;
|
25
|
+
Strings2.matchesEvery = matchesEvery;
|
26
|
+
Strings2.normalizeIndent = normalizeIndent;
|
27
|
+
Strings2.replaceAll = replaceAll;
|
28
|
+
Strings2.toAlphanum = toAlphanum;
|
29
|
+
})(Strings || (Strings = {}));
|
30
|
+
export {
|
31
|
+
Strings
|
32
|
+
};
|
@@ -0,0 +1,3 @@
|
|
1
|
+
export declare function matches(input: string, matcher: string | RegExp): boolean;
|
2
|
+
export declare function matchesSome(input: string, matchers: string | RegExp | Array<string | RegExp>): boolean;
|
3
|
+
export declare function matchesEvery(input: string, matchers: string | RegExp | Array<string | RegExp>): boolean;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function normalizeIndent(input: string, indentLevel?: number): string;
|
@@ -1 +1 @@
|
|
1
|
-
export
|
1
|
+
export declare function replaceAll(input: string, pattern: string | RegExp, replacer: string | ((substring: string, ...args: any[]) => string), maxOps?: number): string;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function toAlphanum(string: string, replacer?: string): string;
|
@@ -0,0 +1,73 @@
|
|
1
|
+
// src/agnostic/strings/char-codes/index.ts
|
2
|
+
var CharCodes;
|
3
|
+
((CharCodes2) => {
|
4
|
+
function charCodeToB36(charCode) {
|
5
|
+
if (charCode === null) return "\0";
|
6
|
+
return charCode.toString(36);
|
7
|
+
}
|
8
|
+
CharCodes2.charCodeToB36 = charCodeToB36;
|
9
|
+
function b36CharCodeToCharCode(b36CharCode) {
|
10
|
+
if (b36CharCode === null) return 0;
|
11
|
+
const charCode = parseInt(b36CharCode, 36);
|
12
|
+
if (!Number.isInteger(charCode)) return 0;
|
13
|
+
return charCode;
|
14
|
+
}
|
15
|
+
CharCodes2.b36CharCodeToCharCode = b36CharCodeToCharCode;
|
16
|
+
function charToCharCode(char) {
|
17
|
+
const charCode = char.charCodeAt(0);
|
18
|
+
if (!Number.isInteger(charCode)) return 0;
|
19
|
+
return charCode;
|
20
|
+
}
|
21
|
+
CharCodes2.charToCharCode = charToCharCode;
|
22
|
+
function charToB36CharCode(char) {
|
23
|
+
const charCode = charToCharCode(char);
|
24
|
+
return charCodeToB36(charCode);
|
25
|
+
}
|
26
|
+
CharCodes2.charToB36CharCode = charToB36CharCode;
|
27
|
+
function charFromCharCode(charCode) {
|
28
|
+
return String.fromCharCode(charCode);
|
29
|
+
}
|
30
|
+
CharCodes2.charFromCharCode = charFromCharCode;
|
31
|
+
function charFromB36CharCode(b36CharCode) {
|
32
|
+
const charCode = parseInt(b36CharCode, 36);
|
33
|
+
if (!Number.isInteger(charCode)) return "\0";
|
34
|
+
return charFromCharCode(charCode);
|
35
|
+
}
|
36
|
+
CharCodes2.charFromB36CharCode = charFromB36CharCode;
|
37
|
+
function toCharCodes(string) {
|
38
|
+
const chars = string.split("");
|
39
|
+
return chars.map(charToCharCode);
|
40
|
+
}
|
41
|
+
CharCodes2.toCharCodes = toCharCodes;
|
42
|
+
function toB36CharCodes(string) {
|
43
|
+
const chars = string.split("");
|
44
|
+
return chars.map(charToB36CharCode);
|
45
|
+
}
|
46
|
+
CharCodes2.toB36CharCodes = toB36CharCodes;
|
47
|
+
function fromCharCodes(charCodes) {
|
48
|
+
return charCodes.map(charFromCharCode).map((char) => char === null ? "\0" : char).join("");
|
49
|
+
}
|
50
|
+
CharCodes2.fromCharCodes = fromCharCodes;
|
51
|
+
function fromB36CharCodes(b36CharCodes) {
|
52
|
+
return b36CharCodes.map(charFromB36CharCode).map((char) => char === null ? "\0" : char).join("");
|
53
|
+
}
|
54
|
+
CharCodes2.fromB36CharCodes = fromB36CharCodes;
|
55
|
+
function serialize(charCodes) {
|
56
|
+
return charCodes.map((c) => typeof c === "string" ? c : charCodeToB36(c)).join(",");
|
57
|
+
}
|
58
|
+
CharCodes2.serialize = serialize;
|
59
|
+
function deserialize(serializedCharCodes) {
|
60
|
+
const b36CharCodes = serializedCharCodes.split("");
|
61
|
+
return b36CharCodes.map(b36CharCodeToCharCode);
|
62
|
+
}
|
63
|
+
CharCodes2.deserialize = deserialize;
|
64
|
+
function fromSerialized(serializedCharCodes) {
|
65
|
+
const charCodes = deserialize(serializedCharCodes);
|
66
|
+
return fromCharCodes(charCodes);
|
67
|
+
}
|
68
|
+
CharCodes2.fromSerialized = fromSerialized;
|
69
|
+
})(CharCodes || (CharCodes = {}));
|
70
|
+
|
71
|
+
export {
|
72
|
+
CharCodes
|
73
|
+
};
|
@@ -0,0 +1,162 @@
|
|
1
|
+
import {
|
2
|
+
wait
|
3
|
+
} from "./chunk-DQNJQBC6.js";
|
4
|
+
|
5
|
+
// src/agnostic/async/transitions/index.ts
|
6
|
+
var Transitions;
|
7
|
+
((Transitions2) => {
|
8
|
+
let Ease;
|
9
|
+
((Ease2) => {
|
10
|
+
Ease2["LINEAR"] = "linear";
|
11
|
+
Ease2["EASE_IN_QUAD"] = "ease-in-quad";
|
12
|
+
Ease2["EASE_OUT_QUAD"] = "ease-out-quad";
|
13
|
+
Ease2["EASE_IN_OUT_QUAD"] = "ease-in-out-quad";
|
14
|
+
Ease2["EASE_IN_CUBIC"] = "ease-in-cubic";
|
15
|
+
Ease2["EASE_OUT_CUBIC"] = "ease-out-cubic";
|
16
|
+
Ease2["EASE_IN_OUT_CUBIC"] = "ease-in-out-cubic";
|
17
|
+
Ease2["EASE_IN_QUART"] = "ease-in-quart";
|
18
|
+
Ease2["EASE_OUT_QUART"] = "ease-out-quart";
|
19
|
+
Ease2["EASE_IN_OUT_QUART"] = "ease-in-out-quart";
|
20
|
+
Ease2["EASE_IN_QUINT"] = "ease-in-quint";
|
21
|
+
Ease2["EASE_OUT_QUINT"] = "ease-out-quint";
|
22
|
+
Ease2["EASE_IN_OUT_QUINT"] = "ease-in-out-quint";
|
23
|
+
Ease2["EASE_IN_SINE"] = "ease-in-sine";
|
24
|
+
Ease2["EASE_OUT_SINE"] = "ease-out-sine";
|
25
|
+
Ease2["EASE_IN_OUT_SINE"] = "ease-in-out-sine";
|
26
|
+
Ease2["EASE_IN_EXPO"] = "ease-in-expo";
|
27
|
+
Ease2["EASE_OUT_EXPO"] = "ease-out-expo";
|
28
|
+
Ease2["EASE_IN_OUT_EXPO"] = "ease-in-out-expo";
|
29
|
+
Ease2["EASE_IN_CIRC"] = "ease-in-circ";
|
30
|
+
Ease2["EASE_OUT_CIRC"] = "ease-out-circ";
|
31
|
+
Ease2["EASE_IN_OUT_CIRC"] = "ease-in-out-circ";
|
32
|
+
Ease2["EASE_IN_BACK"] = "ease-in-back";
|
33
|
+
Ease2["EASE_OUT_BACK"] = "ease-out-back";
|
34
|
+
Ease2["EASE_IN_OUT_BACK"] = "ease-in-out-back";
|
35
|
+
Ease2["EASE_IN_ELASTIC"] = "ease-in-elastic";
|
36
|
+
Ease2["EASE_OUT_ELASTIC"] = "ease-out-elastic";
|
37
|
+
Ease2["EASE_IN_OUT_ELASTIC"] = "ease-in-out-elastic";
|
38
|
+
Ease2["EASE_IN_BOUNCE"] = "ease-in-bounce";
|
39
|
+
Ease2["EASE_OUT_BOUNCE"] = "ease-out-bounce";
|
40
|
+
Ease2["EASE_IN_OUT_BOUNCE"] = "ease-in-out-bounce";
|
41
|
+
})(Ease = Transitions2.Ease || (Transitions2.Ease = {}));
|
42
|
+
async function transition(to, durationMs, callbackOrEase, callback) {
|
43
|
+
const ease = typeof callbackOrEase === "string" ? callbackOrEase : "linear" /* LINEAR */;
|
44
|
+
const easing = Transitions2.easings[ease];
|
45
|
+
if (easing === void 0) return;
|
46
|
+
const actualCallback = callback ?? (typeof callbackOrEase === "function" ? callbackOrEase : void 0);
|
47
|
+
if (actualCallback === void 0) return;
|
48
|
+
const start = Date.now();
|
49
|
+
const timeTable = new Array(to).fill(null).map((_, step) => {
|
50
|
+
const progression = (step + 1) / to;
|
51
|
+
const eased = easing(progression);
|
52
|
+
const time = start + eased * durationMs;
|
53
|
+
return { time, step: eased * to };
|
54
|
+
});
|
55
|
+
for (const { time, step } of timeTable) {
|
56
|
+
const now = Date.now();
|
57
|
+
const delay = time - now;
|
58
|
+
if (delay <= 0) actualCallback(step, time);
|
59
|
+
else {
|
60
|
+
await wait(delay);
|
61
|
+
actualCallback(step, time);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
65
|
+
Transitions2.transition = transition;
|
66
|
+
const pow = Math.pow;
|
67
|
+
const sqrt = Math.sqrt;
|
68
|
+
const sin = Math.sin;
|
69
|
+
const cos = Math.cos;
|
70
|
+
const PI = Math.PI;
|
71
|
+
const c1 = 1.70158;
|
72
|
+
const c2 = c1 * 1.525;
|
73
|
+
const c3 = c1 + 1;
|
74
|
+
const c4 = 2 * PI / 3;
|
75
|
+
const c5 = 2 * PI / 4.5;
|
76
|
+
const bounceOut = function(x) {
|
77
|
+
const n1 = 7.5625;
|
78
|
+
const d1 = 2.75;
|
79
|
+
if (x < 1 / d1) return n1 * x * x;
|
80
|
+
if (x < 2 / d1) return n1 * (x -= 1.5 / d1) * x + 0.75;
|
81
|
+
if (x < 2.5 / d1) return n1 * (x -= 2.25 / d1) * x + 0.9375;
|
82
|
+
return n1 * (x -= 2.625 / d1) * x + 0.984375;
|
83
|
+
};
|
84
|
+
Transitions2.easingFunctions = {
|
85
|
+
linear: (x) => x,
|
86
|
+
easeInQuad: (x) => x * x,
|
87
|
+
easeOutQuad: (x) => 1 - (1 - x) * (1 - x),
|
88
|
+
easeInOutQuad: (x) => x < 0.5 ? 2 * x * x : 1 - pow(-2 * x + 2, 2) / 2,
|
89
|
+
easeInCubic: (x) => x * x * x,
|
90
|
+
easeOutCubic: (x) => 1 - pow(1 - x, 3),
|
91
|
+
easeInOutCubic: (x) => x < 0.5 ? 4 * x * x * x : 1 - pow(-2 * x + 2, 3) / 2,
|
92
|
+
easeInQuart: (x) => x * x * x * x,
|
93
|
+
easeOutQuart: (x) => 1 - pow(1 - x, 4),
|
94
|
+
easeInOutQuart: (x) => x < 0.5 ? 8 * x * x * x * x : 1 - pow(-2 * x + 2, 4) / 2,
|
95
|
+
easeInQuint: (x) => x * x * x * x * x,
|
96
|
+
easeOutQuint: (x) => 1 - pow(1 - x, 5),
|
97
|
+
easeInOutQuint: (x) => x < 0.5 ? 16 * x * x * x * x * x : 1 - pow(-2 * x + 2, 5) / 2,
|
98
|
+
easeInSine: (x) => 1 - cos(x * PI / 2),
|
99
|
+
easeOutSine: (x) => sin(x * PI / 2),
|
100
|
+
easeInOutSine: (x) => -(cos(PI * x) - 1) / 2,
|
101
|
+
easeInExpo: (x) => x === 0 ? 0 : pow(2, 10 * x - 10),
|
102
|
+
easeOutExpo: (x) => x === 1 ? 1 : 1 - pow(2, -10 * x),
|
103
|
+
easeInOutExpo: (x) => {
|
104
|
+
return x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? pow(2, 20 * x - 10) / 2 : (2 - pow(2, -20 * x + 10)) / 2;
|
105
|
+
},
|
106
|
+
easeInCirc: (x) => 1 - sqrt(1 - pow(x, 2)),
|
107
|
+
easeOutCirc: (x) => sqrt(1 - pow(x - 1, 2)),
|
108
|
+
easeInOutCirc: (x) => x < 0.5 ? (1 - sqrt(1 - pow(2 * x, 2))) / 2 : (sqrt(1 - pow(-2 * x + 2, 2)) + 1) / 2,
|
109
|
+
easeInBack: (x) => c3 * x * x * x - c1 * x * x,
|
110
|
+
easeOutBack: (x) => 1 + c3 * pow(x - 1, 3) + c1 * pow(x - 1, 2),
|
111
|
+
easeInOutBack: (x) => x < 0.5 ? pow(2 * x, 2) * ((c2 + 1) * 2 * x - c2) / 2 : (pow(2 * x - 2, 2) * ((c2 + 1) * (x * 2 - 2) + c2) + 2) / 2,
|
112
|
+
easeInElastic: (x) => {
|
113
|
+
return x === 0 ? 0 : x === 1 ? 1 : -pow(2, 10 * x - 10) * sin((x * 10 - 10.75) * c4);
|
114
|
+
},
|
115
|
+
easeOutElastic: (x) => {
|
116
|
+
return x === 0 ? 0 : x === 1 ? 1 : pow(2, -10 * x) * sin((x * 10 - 0.75) * c4) + 1;
|
117
|
+
},
|
118
|
+
easeInOutElastic: (x) => {
|
119
|
+
return x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? -(pow(2, 20 * x - 10) * sin((20 * x - 11.125) * c5)) / 2 : pow(2, -20 * x + 10) * sin((20 * x - 11.125) * c5) / 2 + 1;
|
120
|
+
},
|
121
|
+
easeInBounce: (x) => 1 - bounceOut(1 - x),
|
122
|
+
easeOutBounce: bounceOut,
|
123
|
+
easeInOutBounce: (x) => x < 0.5 ? (1 - bounceOut(1 - 2 * x)) / 2 : (1 + bounceOut(2 * x - 1)) / 2
|
124
|
+
};
|
125
|
+
Transitions2.easings = {
|
126
|
+
["linear" /* LINEAR */]: Transitions2.easingFunctions.linear,
|
127
|
+
["ease-in-quad" /* EASE_IN_QUAD */]: Transitions2.easingFunctions.easeInQuad,
|
128
|
+
["ease-out-quad" /* EASE_OUT_QUAD */]: Transitions2.easingFunctions.easeOutQuad,
|
129
|
+
["ease-in-out-quad" /* EASE_IN_OUT_QUAD */]: Transitions2.easingFunctions.easeInOutQuad,
|
130
|
+
["ease-in-cubic" /* EASE_IN_CUBIC */]: Transitions2.easingFunctions.easeInCubic,
|
131
|
+
["ease-out-cubic" /* EASE_OUT_CUBIC */]: Transitions2.easingFunctions.easeOutCubic,
|
132
|
+
["ease-in-out-cubic" /* EASE_IN_OUT_CUBIC */]: Transitions2.easingFunctions.easeInOutCubic,
|
133
|
+
["ease-in-quart" /* EASE_IN_QUART */]: Transitions2.easingFunctions.easeInQuart,
|
134
|
+
["ease-out-quart" /* EASE_OUT_QUART */]: Transitions2.easingFunctions.easeOutQuart,
|
135
|
+
["ease-in-out-quart" /* EASE_IN_OUT_QUART */]: Transitions2.easingFunctions.easeInOutQuart,
|
136
|
+
["ease-in-quint" /* EASE_IN_QUINT */]: Transitions2.easingFunctions.easeInQuint,
|
137
|
+
["ease-out-quint" /* EASE_OUT_QUINT */]: Transitions2.easingFunctions.easeOutQuint,
|
138
|
+
["ease-in-out-quint" /* EASE_IN_OUT_QUINT */]: Transitions2.easingFunctions.easeInOutQuint,
|
139
|
+
["ease-in-sine" /* EASE_IN_SINE */]: Transitions2.easingFunctions.easeInSine,
|
140
|
+
["ease-out-sine" /* EASE_OUT_SINE */]: Transitions2.easingFunctions.easeOutSine,
|
141
|
+
["ease-in-out-sine" /* EASE_IN_OUT_SINE */]: Transitions2.easingFunctions.easeInOutSine,
|
142
|
+
["ease-in-expo" /* EASE_IN_EXPO */]: Transitions2.easingFunctions.easeInExpo,
|
143
|
+
["ease-out-expo" /* EASE_OUT_EXPO */]: Transitions2.easingFunctions.easeOutExpo,
|
144
|
+
["ease-in-out-expo" /* EASE_IN_OUT_EXPO */]: Transitions2.easingFunctions.easeInOutExpo,
|
145
|
+
["ease-in-circ" /* EASE_IN_CIRC */]: Transitions2.easingFunctions.easeInCirc,
|
146
|
+
["ease-out-circ" /* EASE_OUT_CIRC */]: Transitions2.easingFunctions.easeOutCirc,
|
147
|
+
["ease-in-out-circ" /* EASE_IN_OUT_CIRC */]: Transitions2.easingFunctions.easeInOutCirc,
|
148
|
+
["ease-in-back" /* EASE_IN_BACK */]: Transitions2.easingFunctions.easeInBack,
|
149
|
+
["ease-out-back" /* EASE_OUT_BACK */]: Transitions2.easingFunctions.easeOutBack,
|
150
|
+
["ease-in-out-back" /* EASE_IN_OUT_BACK */]: Transitions2.easingFunctions.easeInOutBack,
|
151
|
+
["ease-in-elastic" /* EASE_IN_ELASTIC */]: Transitions2.easingFunctions.easeInElastic,
|
152
|
+
["ease-out-elastic" /* EASE_OUT_ELASTIC */]: Transitions2.easingFunctions.easeOutElastic,
|
153
|
+
["ease-in-out-elastic" /* EASE_IN_OUT_ELASTIC */]: Transitions2.easingFunctions.easeInOutElastic,
|
154
|
+
["ease-in-bounce" /* EASE_IN_BOUNCE */]: Transitions2.easingFunctions.easeInBounce,
|
155
|
+
["ease-out-bounce" /* EASE_OUT_BOUNCE */]: Transitions2.easingFunctions.easeOutBounce,
|
156
|
+
["ease-in-out-bounce" /* EASE_IN_OUT_BOUNCE */]: Transitions2.easingFunctions.easeInOutBounce
|
157
|
+
};
|
158
|
+
})(Transitions || (Transitions = {}));
|
159
|
+
|
160
|
+
export {
|
161
|
+
Transitions
|
162
|
+
};
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import {
|
2
|
+
isFalsy
|
3
|
+
} from "./chunk-QXAJXTXV.js";
|
4
|
+
|
5
|
+
// src/agnostic/misc/cast/index.ts
|
6
|
+
var Cast;
|
7
|
+
((Cast2) => {
|
8
|
+
function toBoolean(value) {
|
9
|
+
if (typeof value === "boolean") return value;
|
10
|
+
if (typeof value === "string") {
|
11
|
+
if (value.toLowerCase().trim() === "true") return true;
|
12
|
+
return false;
|
13
|
+
}
|
14
|
+
return !isFalsy(value);
|
15
|
+
}
|
16
|
+
Cast2.toBoolean = toBoolean;
|
17
|
+
function toNumber(value) {
|
18
|
+
if (typeof value === "number") return value;
|
19
|
+
if (typeof value === "string") return parseFloat(value);
|
20
|
+
return 0;
|
21
|
+
}
|
22
|
+
Cast2.toNumber = toNumber;
|
23
|
+
function toString(value) {
|
24
|
+
if (typeof value === "string") return value;
|
25
|
+
return String(value);
|
26
|
+
}
|
27
|
+
Cast2.toString = toString;
|
28
|
+
function toNull(_value) {
|
29
|
+
return null;
|
30
|
+
}
|
31
|
+
Cast2.toNull = toNull;
|
32
|
+
function toArray(value) {
|
33
|
+
if (Array.isArray(value)) return value;
|
34
|
+
if (typeof value === "object" && value !== null) return Object.entries(value).map((key, value2) => ({ key, value: value2 }));
|
35
|
+
return [value];
|
36
|
+
}
|
37
|
+
Cast2.toArray = toArray;
|
38
|
+
function toNumberArr(value) {
|
39
|
+
const arrValue = toArray(value);
|
40
|
+
return arrValue.map((val) => toNumber(val));
|
41
|
+
}
|
42
|
+
Cast2.toNumberArr = toNumberArr;
|
43
|
+
function toRecord(value) {
|
44
|
+
const record = {};
|
45
|
+
try {
|
46
|
+
Object.keys(value).forEach((key) => {
|
47
|
+
record[key] = value[key];
|
48
|
+
});
|
49
|
+
} catch (err) {
|
50
|
+
return record;
|
51
|
+
}
|
52
|
+
return record;
|
53
|
+
}
|
54
|
+
Cast2.toRecord = toRecord;
|
55
|
+
})(Cast || (Cast = {}));
|
56
|
+
|
57
|
+
export {
|
58
|
+
Cast
|
59
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// src/agnostic/async/timeout-call/index.ts
|
2
|
+
function timeoutCall(callback, timeoutMs) {
|
3
|
+
return new Promise(async (resolve, reject) => {
|
4
|
+
const rejectTimeout = setTimeout(() => reject(false), timeoutMs);
|
5
|
+
const callbackResult = await callback();
|
6
|
+
clearTimeout(rejectTimeout);
|
7
|
+
return resolve(callbackResult);
|
8
|
+
});
|
9
|
+
}
|
10
|
+
|
11
|
+
export {
|
12
|
+
timeoutCall
|
13
|
+
};
|