@react-fabric/utilities 1.0.0-beta.8 → 1.0.1
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/dist/cjs/css/boundingBox.js +72 -0
- package/dist/cjs/css/cn.js +39 -0
- package/dist/cjs/css/imageColorset.js +96 -0
- package/dist/cjs/data/countries.js +98 -0
- package/dist/cjs/{_fileType.js → data/fileType.js} +37 -19
- package/dist/cjs/data/format.js +136 -0
- package/dist/cjs/helpers/debounce.js +63 -0
- package/dist/cjs/{useLogger.js → helpers/getLogger.js} +96 -96
- package/dist/cjs/helpers/lonlat.js +99 -0
- package/dist/cjs/index.js +99 -76
- package/dist/cjs/lists/dedupe.js +54 -0
- package/dist/cjs/lists/flatten.js +66 -0
- package/dist/cjs/{_getByPath.js → lists/getByPath.js} +58 -37
- package/dist/cjs/lists/groupBy.js +49 -0
- package/dist/cjs/matchers/compare.js +70 -0
- package/dist/cjs/matchers/isEmpty.js +34 -0
- package/dist/cjs/matchers/isEqual.js +82 -0
- package/dist/cjs/matchers/nullChecks.js +61 -0
- package/dist/cjs/matchers/typeChecks.js +127 -0
- package/dist/cjs/strings/ascii.js +105 -0
- package/dist/cjs/strings/hash.js +75 -0
- package/dist/cjs/strings/interpolate.js +47 -0
- package/dist/cjs/strings/matchString.js +54 -0
- package/dist/cjs/strings/template.js +48 -0
- package/dist/cjs/strings/tokenize.js +83 -0
- package/dist/cjs/utils/mergeRefs.js +56 -0
- package/dist/esm/css/boundingBox.js +71 -0
- package/dist/esm/css/cn.js +39 -0
- package/dist/esm/css/imageColorset.js +96 -0
- package/dist/esm/data/countries.js +98 -0
- package/dist/esm/{_fileType.js → data/fileType.js} +37 -19
- package/dist/esm/data/format.js +138 -0
- package/dist/esm/helpers/debounce.js +63 -0
- package/dist/esm/{useLogger.js → helpers/getLogger.js} +96 -96
- package/dist/esm/helpers/lonlat.js +97 -0
- package/dist/esm/index.js +54 -36
- package/dist/esm/lists/dedupe.js +54 -0
- package/dist/esm/lists/flatten.js +65 -0
- package/dist/esm/{_getByPath.js → lists/getByPath.js} +50 -29
- package/dist/esm/lists/groupBy.js +49 -0
- package/dist/esm/matchers/compare.js +70 -0
- package/dist/esm/matchers/isEmpty.js +34 -0
- package/dist/esm/matchers/isEqual.js +82 -0
- package/dist/esm/matchers/nullChecks.js +58 -0
- package/dist/esm/matchers/typeChecks.js +119 -0
- package/dist/esm/strings/ascii.js +105 -0
- package/dist/esm/strings/hash.js +73 -0
- package/dist/esm/strings/interpolate.js +47 -0
- package/dist/esm/strings/matchString.js +54 -0
- package/dist/esm/strings/template.js +48 -0
- package/dist/esm/strings/tokenize.js +82 -0
- package/dist/esm/utils/mergeRefs.js +56 -0
- package/dist/types/css/boundingBox.d.ts +46 -0
- package/dist/types/css/cn.d.ts +26 -0
- package/dist/types/css/imageColorset.d.ts +37 -0
- package/dist/types/data/countries.d.ts +136 -0
- package/dist/types/{_fileType.d.ts → data/fileType.d.ts} +41 -1
- package/dist/types/data/format.d.ts +122 -0
- package/dist/types/helpers/debounce.d.ts +38 -0
- package/dist/types/helpers/getLogger.d.ts +49 -0
- package/dist/types/helpers/lonlat.d.ts +48 -0
- package/dist/types/index.d.ts +54 -20
- package/dist/types/lists/dedupe.d.ts +36 -0
- package/dist/types/lists/flatten.d.ts +47 -0
- package/dist/types/lists/getByPath.d.ts +45 -0
- package/dist/types/lists/groupBy.d.ts +36 -0
- package/dist/types/matchers/compare.d.ts +38 -0
- package/dist/types/matchers/isEmpty.d.ts +38 -0
- package/dist/types/matchers/isEqual.d.ts +39 -0
- package/dist/types/matchers/nullChecks.d.ts +43 -0
- package/dist/types/matchers/typeChecks.d.ts +107 -0
- package/dist/types/strings/ascii.d.ts +34 -0
- package/dist/types/strings/hash.d.ts +46 -0
- package/dist/types/strings/interpolate.d.ts +34 -0
- package/dist/types/strings/matchString.d.ts +41 -0
- package/dist/types/strings/template.d.ts +35 -0
- package/dist/types/strings/tokenize.d.ts +44 -0
- package/dist/types/utils/mergeRefs.d.ts +36 -0
- package/package.json +13 -11
- package/src/css/boundingBox.ts +80 -0
- package/src/css/cn.ts +32 -0
- package/src/css/imageColorset.ts +97 -0
- package/src/data/countries.ts +126 -0
- package/src/{_fileType.ts → data/fileType.ts} +72 -89
- package/src/data/format.ts +192 -0
- package/src/helpers/debounce.ts +49 -0
- package/src/{useLogger.ts → helpers/getLogger.ts} +52 -101
- package/src/helpers/lonlat.ts +124 -0
- package/src/index.ts +57 -37
- package/src/lists/dedupe.ts +46 -0
- package/src/lists/flatten.ts +56 -0
- package/src/lists/getByPath.ts +122 -0
- package/src/lists/groupBy.ts +47 -0
- package/src/matchers/compare.ts +64 -0
- package/src/matchers/isEmpty.ts +54 -0
- package/src/matchers/isEqual.ts +71 -0
- package/src/matchers/nullChecks.ts +55 -0
- package/src/matchers/typeChecks.ts +146 -0
- package/src/strings/ascii.ts +100 -0
- package/src/strings/hash.ts +68 -0
- package/src/strings/interpolate.ts +42 -0
- package/src/strings/matchString.ts +49 -0
- package/src/strings/template.ts +43 -0
- package/src/strings/tokenize.ts +77 -0
- package/src/utils/mergeRefs.ts +47 -0
- package/src/{yup.ts → utils/yup.ts} +3 -3
- package/dist/cjs/_ascii.js +0 -76
- package/dist/cjs/_boundingBox.js +0 -59
- package/dist/cjs/_countries.js +0 -2805
- package/dist/cjs/_debounce.js +0 -53
- package/dist/cjs/_dedupe.js +0 -63
- package/dist/cjs/_fetch.js +0 -128
- package/dist/cjs/_format.js +0 -118
- package/dist/cjs/_hash.js +0 -67
- package/dist/cjs/_interpolate.js +0 -47
- package/dist/cjs/_isEqual.js +0 -108
- package/dist/cjs/_isType.js +0 -98
- package/dist/cjs/_mergeRefs.js +0 -40
- package/dist/cjs/_tokenize.js +0 -67
- package/dist/cjs/getImageColorset.js +0 -70
- package/dist/esm/_ascii.js +0 -76
- package/dist/esm/_boundingBox.js +0 -58
- package/dist/esm/_countries.js +0 -2805
- package/dist/esm/_debounce.js +0 -53
- package/dist/esm/_dedupe.js +0 -60
- package/dist/esm/_fetch.js +0 -128
- package/dist/esm/_format.js +0 -120
- package/dist/esm/_hash.js +0 -65
- package/dist/esm/_interpolate.js +0 -46
- package/dist/esm/_isEqual.js +0 -106
- package/dist/esm/_isType.js +0 -85
- package/dist/esm/_mergeRefs.js +0 -40
- package/dist/esm/_tokenize.js +0 -66
- package/dist/esm/getImageColorset.js +0 -70
- package/dist/types/_ascii.d.ts +0 -5
- package/dist/types/_boundingBox.d.ts +0 -10
- package/dist/types/_countries.d.ts +0 -85
- package/dist/types/_debounce.d.ts +0 -8
- package/dist/types/_dedupe.d.ts +0 -4
- package/dist/types/_fetch.d.ts +0 -23
- package/dist/types/_format.d.ts +0 -27
- package/dist/types/_getByPath.d.ts +0 -10
- package/dist/types/_hash.d.ts +0 -16
- package/dist/types/_interpolate.d.ts +0 -6
- package/dist/types/_isEqual.d.ts +0 -15
- package/dist/types/_isType.d.ts +0 -14
- package/dist/types/_mergeRefs.d.ts +0 -1
- package/dist/types/_tokenize.d.ts +0 -8
- package/dist/types/getImageColorset.d.ts +0 -1
- package/dist/types/useLogger.d.ts +0 -25
- package/src/_ascii.ts +0 -93
- package/src/_boundingBox.ts +0 -72
- package/src/_countries.ts +0 -3046
- package/src/_debounce.ts +0 -42
- package/src/_dedupe.ts +0 -56
- package/src/_fetch.ts +0 -109
- package/src/_format.ts +0 -141
- package/src/_getByPath.ts +0 -108
- package/src/_hash.ts +0 -62
- package/src/_interpolate.ts +0 -42
- package/src/_isEqual.ts +0 -102
- package/src/_isType.ts +0 -105
- package/src/_mergeRefs.ts +0 -33
- package/src/_tokenize.ts +0 -69
- package/src/getImageColorset.ts +0 -81
- /package/dist/cjs/{yup.js → utils/yup.js} +0 -0
- /package/dist/esm/{yup.js → utils/yup.js} +0 -0
- /package/dist/types/{yup.d.ts → utils/yup.d.ts} +0 -0
package/src/_debounce.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* React Fabric
|
|
3
|
-
* @version: 1.0.0
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* The MIT License (MIT)
|
|
7
|
-
* Copyright (c) 2024 Adarsh Pastakia
|
|
8
|
-
*
|
|
9
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
|
-
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
11
|
-
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
-
* subject to the following conditions:
|
|
14
|
-
*
|
|
15
|
-
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
16
|
-
* portions of the Software.
|
|
17
|
-
*
|
|
18
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
-
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
20
|
-
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/* istanbul ignore file */
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* debounce callback
|
|
28
|
-
* @internal
|
|
29
|
-
*/
|
|
30
|
-
export const debounce = (fn: (...rest: any) => any, timeout = 500) => {
|
|
31
|
-
/** ***************** create debounce timer id using callback hash *******************/
|
|
32
|
-
let _timer: any;
|
|
33
|
-
|
|
34
|
-
/** ***************** return debounced function *******************/
|
|
35
|
-
const cb = (...args: any) => {
|
|
36
|
-
clearTimeout(_timer);
|
|
37
|
-
if (typeof window !== "undefined")
|
|
38
|
-
_timer = window.setTimeout(() => fn?.(...args), timeout);
|
|
39
|
-
};
|
|
40
|
-
cb.cancel = () => clearTimeout(_timer);
|
|
41
|
-
return cb;
|
|
42
|
-
};
|
package/src/_dedupe.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* React Fabric
|
|
3
|
-
* @version: 1.0.0
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* The MIT License (MIT)
|
|
7
|
-
* Copyright (c) 2024 Adarsh Pastakia
|
|
8
|
-
*
|
|
9
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
|
-
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
11
|
-
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
-
* subject to the following conditions:
|
|
14
|
-
*
|
|
15
|
-
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
16
|
-
* portions of the Software.
|
|
17
|
-
*
|
|
18
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
-
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
20
|
-
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
import { isEmpty } from "./_isType";
|
|
25
|
-
|
|
26
|
-
export const dedupe = (list: any[], key?: string) => {
|
|
27
|
-
const filtered = list.filter((i) => !isEmpty(i));
|
|
28
|
-
if (!key) {
|
|
29
|
-
return Array.from(new Set(filtered).values());
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return Array.from(
|
|
33
|
-
new Map(filtered.map((obj) => [obj[key] ?? obj, obj])).values(),
|
|
34
|
-
);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const flatten = (list: any[]) => {
|
|
38
|
-
return list.flat(5).filter((i) => !isEmpty(i));
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const flattenAndDedupe = (list: any[] = [], key?: string) => {
|
|
42
|
-
return dedupe(flatten(list), key);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const groupBy = <T extends KeyValue>(
|
|
46
|
-
list: T[],
|
|
47
|
-
prop: keyof T,
|
|
48
|
-
missingKey?: string,
|
|
49
|
-
): KeyValue<T[]> => {
|
|
50
|
-
return list.reduce((r: AnyObject, i) => {
|
|
51
|
-
const key = i[prop] ?? missingKey;
|
|
52
|
-
if (!r[key]) r[key] = [];
|
|
53
|
-
r[key].push(i);
|
|
54
|
-
return r;
|
|
55
|
-
}, {});
|
|
56
|
-
};
|
package/src/_fetch.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* React Fabric
|
|
3
|
-
* @version: 1.0.0
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* The MIT License (MIT)
|
|
7
|
-
* Copyright (c) 2024 Adarsh Pastakia
|
|
8
|
-
*
|
|
9
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
|
-
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
11
|
-
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
-
* subject to the following conditions:
|
|
14
|
-
*
|
|
15
|
-
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
16
|
-
* portions of the Software.
|
|
17
|
-
*
|
|
18
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
-
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
20
|
-
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/* istanbul ignore file */
|
|
25
|
-
|
|
26
|
-
import { isString } from "./_isType";
|
|
27
|
-
|
|
28
|
-
declare type METHODS = "get" | "post" | "put" | "delete";
|
|
29
|
-
declare interface FetchOptions {
|
|
30
|
-
body?: KeyValue | FormData;
|
|
31
|
-
headers?: KeyValue;
|
|
32
|
-
signal?: string | AbortSignal;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const _signals = new Map<string, AbortController>();
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Fetch helper
|
|
39
|
-
* @param method
|
|
40
|
-
* @param url
|
|
41
|
-
* @param options.headers
|
|
42
|
-
* @param options.body
|
|
43
|
-
* @param options.signal
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
|
-
export const _fetch = async (
|
|
47
|
-
method: METHODS,
|
|
48
|
-
url: string,
|
|
49
|
-
{ headers = {}, body, signal }: FetchOptions,
|
|
50
|
-
) => {
|
|
51
|
-
const options: KeyValue = {
|
|
52
|
-
method,
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
headers.accept = "application/json";
|
|
56
|
-
if (method === "post" || method === "put") {
|
|
57
|
-
options.body = body;
|
|
58
|
-
/** ***************** set body to json when not FormData *******************/
|
|
59
|
-
if (!(body instanceof FormData)) {
|
|
60
|
-
headers["content-type"] = "application/json";
|
|
61
|
-
options.body = JSON.stringify(body);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/** ***************** reset abort signal *******************/
|
|
66
|
-
if (signal && isString(signal)) {
|
|
67
|
-
if (_signals.has(signal)) {
|
|
68
|
-
const _s = _signals.get(signal);
|
|
69
|
-
_s?.abort();
|
|
70
|
-
_signals.delete(signal);
|
|
71
|
-
}
|
|
72
|
-
const ac = new AbortController();
|
|
73
|
-
options.signal = ac.signal;
|
|
74
|
-
_signals.set(signal, ac);
|
|
75
|
-
} else if (signal instanceof AbortSignal) {
|
|
76
|
-
options.signal = signal;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return await fetch(url, { ...options, headers })
|
|
80
|
-
.then(async (resp) => {
|
|
81
|
-
if (resp.status >= 200 && resp.status < 300) {
|
|
82
|
-
return await resp.json();
|
|
83
|
-
}
|
|
84
|
-
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
85
|
-
throw { status: resp.status, code: -1, message: resp.statusText };
|
|
86
|
-
})
|
|
87
|
-
.then((resp) => {
|
|
88
|
-
/** ***************** check for possible error code propeties in response *******************/
|
|
89
|
-
const code = resp.error_code ?? resp.errorCode ?? resp.error;
|
|
90
|
-
const message = resp.error_message ?? resp.errorMessage ?? resp.message;
|
|
91
|
-
if (resp.status === "error" || code) {
|
|
92
|
-
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
93
|
-
throw { status: 500, code, message };
|
|
94
|
-
}
|
|
95
|
-
return resp;
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
/** ***************** attach isAborted helper to fetch method *******************/
|
|
100
|
-
_fetch.isAborted = ({ name }: Error) => name === "AbortError";
|
|
101
|
-
|
|
102
|
-
/** ***************** attach abort helper to fetch method *******************/
|
|
103
|
-
_fetch.abort = (signal: string) => {
|
|
104
|
-
if (_signals.has(signal)) {
|
|
105
|
-
const _s = _signals.get(signal);
|
|
106
|
-
_s?.abort();
|
|
107
|
-
_signals.delete(signal);
|
|
108
|
-
}
|
|
109
|
-
};
|
package/src/_format.ts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* React Fabric
|
|
3
|
-
* @version: 1.0.0
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* The MIT License (MIT)
|
|
7
|
-
* Copyright (c) 2024 Adarsh Pastakia
|
|
8
|
-
*
|
|
9
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
|
-
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
11
|
-
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
-
* subject to the following conditions:
|
|
14
|
-
*
|
|
15
|
-
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
16
|
-
* portions of the Software.
|
|
17
|
-
*
|
|
18
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
-
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
20
|
-
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
import { differenceInDays, format, parseISO } from "date-fns";
|
|
25
|
-
import {
|
|
26
|
-
parsePhoneNumberFromString,
|
|
27
|
-
type CountryCode,
|
|
28
|
-
} from "libphonenumber-js";
|
|
29
|
-
import numeral from "numeral";
|
|
30
|
-
import Countries from "./_countries";
|
|
31
|
-
import { isEmpty, isNil } from "./_isType";
|
|
32
|
-
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
34
|
-
export namespace Format {
|
|
35
|
-
/** ***************** get phone number object using `libphonenumber-js` *******************/
|
|
36
|
-
const getPhone = (value: string, country: string) => {
|
|
37
|
-
const phone =
|
|
38
|
-
value.match(/^[0+]/) != null ? value.replace(/^00/, "+") : `+${value}`;
|
|
39
|
-
const number = parsePhoneNumberFromString(phone, country as CountryCode);
|
|
40
|
-
/* istanbul ignore next */
|
|
41
|
-
return (
|
|
42
|
-
number ?? {
|
|
43
|
-
country: "",
|
|
44
|
-
formatInternational: () => value,
|
|
45
|
-
}
|
|
46
|
-
);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/** ***************** common number format method using `numeral` *******************/
|
|
50
|
-
const numberFormat = (number?: string | number, format = "0,0[.]00a") => {
|
|
51
|
-
if (isNil(number)) {
|
|
52
|
-
return "";
|
|
53
|
-
}
|
|
54
|
-
const prefix = `${number}`.startsWith("+") ? "+" : "";
|
|
55
|
-
return prefix + numeral(number).format(format);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const makeDuration = (value: number, fmt = "HH:mm:ss.SSS") => {
|
|
59
|
-
if (!isNaN(value)) {
|
|
60
|
-
const days = differenceInDays(value, 0);
|
|
61
|
-
const prefix = days > 0 ? `${days}d:` : "";
|
|
62
|
-
let time = format(
|
|
63
|
-
parseISO(new Date(value).toISOString().replace("Z", "")),
|
|
64
|
-
fmt,
|
|
65
|
-
);
|
|
66
|
-
if (!prefix) time = time.replace(/^00:/, "");
|
|
67
|
-
return `${prefix}${time}`;
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
/** ***************** format phone number using `libphonenumber-js` *******************/
|
|
72
|
-
export const phone = (value?: string, country = "AE", useCss = false) => {
|
|
73
|
-
if (isEmpty(value) || value.length < 6 || !/^[\d+\s\-()]+$/.test(value))
|
|
74
|
-
return value;
|
|
75
|
-
const phone = getPhone(value, country);
|
|
76
|
-
/* istanbul ignore next */
|
|
77
|
-
return `${
|
|
78
|
-
useCss
|
|
79
|
-
? `<span class="flag ${phone.country}"></span>`
|
|
80
|
-
: Countries.emoji(phone.country ?? "")
|
|
81
|
-
} ${phone.formatInternational()}`;
|
|
82
|
-
};
|
|
83
|
-
/** ***************** format whole number using `numeral` *******************/
|
|
84
|
-
export const number = (number?: string | number, format?: string) => {
|
|
85
|
-
return numberFormat(number, format);
|
|
86
|
-
};
|
|
87
|
-
/** ***************** format bytes using `numeral` *******************/
|
|
88
|
-
export const bytes = (number?: string | number) => {
|
|
89
|
-
return numberFormat(number, "0,0[.]00b");
|
|
90
|
-
};
|
|
91
|
-
/** ***************** format percentage using `numeral` *******************/
|
|
92
|
-
export const percent = (number?: string | number) => {
|
|
93
|
-
return numberFormat(number, "0,0[.]00%");
|
|
94
|
-
};
|
|
95
|
-
/** ***************** format date using `date-fns` *******************/
|
|
96
|
-
export const date = (date?: Date | string | number, fmt = "d-M-y") => {
|
|
97
|
-
return date ? format(new Date(date), fmt) : "";
|
|
98
|
-
};
|
|
99
|
-
/** ***************** format time duration from total seconds/milliseconds *******************/
|
|
100
|
-
/**
|
|
101
|
-
* Format time duration with milliseconds
|
|
102
|
-
* @param number
|
|
103
|
-
* @param isFraction
|
|
104
|
-
* @returns
|
|
105
|
-
*/
|
|
106
|
-
export const duration = (number?: string | number, isFraction?: boolean) => {
|
|
107
|
-
if (isNil(number)) {
|
|
108
|
-
return "00:00.000";
|
|
109
|
-
}
|
|
110
|
-
if (number === Infinity) {
|
|
111
|
-
return "∞";
|
|
112
|
-
}
|
|
113
|
-
const value = parseFloat(`${number}`) * (isFraction ? 1000 : 1);
|
|
114
|
-
if (!isNaN(value)) {
|
|
115
|
-
return makeDuration(value);
|
|
116
|
-
}
|
|
117
|
-
return "00:00.000";
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* Format time duration without milliseconds
|
|
121
|
-
* @param number
|
|
122
|
-
* @param isFraction
|
|
123
|
-
* @returns
|
|
124
|
-
*/
|
|
125
|
-
export const durationSeconds = (
|
|
126
|
-
number?: string | number,
|
|
127
|
-
isFraction?: boolean,
|
|
128
|
-
) => {
|
|
129
|
-
if (isNil(number)) {
|
|
130
|
-
return "00:00";
|
|
131
|
-
}
|
|
132
|
-
if (number === Infinity) {
|
|
133
|
-
return "∞";
|
|
134
|
-
}
|
|
135
|
-
const value = parseFloat(`${number}`) * (isFraction ? 1000 : 1);
|
|
136
|
-
if (!isNaN(value)) {
|
|
137
|
-
return makeDuration(value, "HH:mm:ss");
|
|
138
|
-
}
|
|
139
|
-
return "00:00";
|
|
140
|
-
};
|
|
141
|
-
}
|
package/src/_getByPath.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* React Fabric
|
|
3
|
-
* @version: 1.0.0
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* The MIT License (MIT)
|
|
7
|
-
* Copyright (c) 2024 Adarsh Pastakia
|
|
8
|
-
*
|
|
9
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
|
-
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
11
|
-
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
-
* subject to the following conditions:
|
|
14
|
-
*
|
|
15
|
-
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
16
|
-
* portions of the Software.
|
|
17
|
-
*
|
|
18
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
-
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
20
|
-
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
import { isArray, isEmpty, isNil, isObject } from "./_isType";
|
|
25
|
-
|
|
26
|
-
const _get = (hit: any, field: string): any => {
|
|
27
|
-
/** ***************** return if object is empty *******************/
|
|
28
|
-
/* istanbul ignore next */
|
|
29
|
-
if (isNil(hit)) {
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
32
|
-
/** ***************** return object if property is empty *******************/
|
|
33
|
-
/* istanbul ignore next */
|
|
34
|
-
if (isNil(field)) {
|
|
35
|
-
return hit;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (isObject(hit)) {
|
|
39
|
-
/** ***************** return value if object.property is not empty *******************/
|
|
40
|
-
if (!isNil(hit[field])) {
|
|
41
|
-
return hit[field];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** ***************** if property name contains `.` separator split to multiple property names *******************/
|
|
45
|
-
if (field.includes(".")) {
|
|
46
|
-
let currentValue: any = hit;
|
|
47
|
-
|
|
48
|
-
const path = field.split(".");
|
|
49
|
-
for (let i = path.length - 1; i >= 0; i--) {
|
|
50
|
-
/** ***************** when property name is `a.b.c` iterate until property found in object. eg. `a`, `a.b` *******************/
|
|
51
|
-
const outerPath = path.slice(0, i as any).join(".");
|
|
52
|
-
|
|
53
|
-
/** ***************** join rest of property list *******************/
|
|
54
|
-
const innerPath = path.slice(i as any).join(".");
|
|
55
|
-
|
|
56
|
-
/** ***************** if current outer path found in object *******************/
|
|
57
|
-
if (outerPath in currentValue) {
|
|
58
|
-
currentValue = currentValue[outerPath];
|
|
59
|
-
|
|
60
|
-
/** ***************** check for type array *******************/
|
|
61
|
-
if (isArray(currentValue)) {
|
|
62
|
-
/** ***************** return value if remaining path found *******************/
|
|
63
|
-
if (currentValue[innerPath as any]) {
|
|
64
|
-
return currentValue[innerPath as any];
|
|
65
|
-
}
|
|
66
|
-
/** ***************** return array map of inner propeties *******************/
|
|
67
|
-
return currentValue
|
|
68
|
-
.map((val) => _get(val, innerPath))
|
|
69
|
-
.filter((val) => !isEmpty(val));
|
|
70
|
-
} else {
|
|
71
|
-
/** ***************** return value of remaining path *******************/
|
|
72
|
-
return _get(currentValue, innerPath);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return undefined;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* get property value by path
|
|
84
|
-
* @internal
|
|
85
|
-
*/
|
|
86
|
-
export const getByPath = <T = any>(
|
|
87
|
-
obj: KeyValue,
|
|
88
|
-
path: string,
|
|
89
|
-
defaultValue: any = undefined,
|
|
90
|
-
): T => {
|
|
91
|
-
/** ***************** if empty object/path return defaultValue *******************/
|
|
92
|
-
if (isEmpty(obj) || isEmpty(path)) {
|
|
93
|
-
return defaultValue;
|
|
94
|
-
}
|
|
95
|
-
const value = _get(obj, path);
|
|
96
|
-
if (!isNil(value)) {
|
|
97
|
-
return value;
|
|
98
|
-
}
|
|
99
|
-
return defaultValue;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* get first available value in list
|
|
104
|
-
* @internal
|
|
105
|
-
*/
|
|
106
|
-
export const getValue = (...args: any[]) => {
|
|
107
|
-
return args.find((a) => !isEmpty(a));
|
|
108
|
-
};
|
package/src/_hash.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* React Fabric
|
|
3
|
-
* @version: 1.0.0
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* The MIT License (MIT)
|
|
7
|
-
* Copyright (c) 2024 Adarsh Pastakia
|
|
8
|
-
*
|
|
9
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
|
-
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
11
|
-
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
-
* subject to the following conditions:
|
|
14
|
-
*
|
|
15
|
-
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
16
|
-
* portions of the Software.
|
|
17
|
-
*
|
|
18
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
-
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
20
|
-
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
import { isEmpty } from "./_isType";
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* calculate hash from string
|
|
28
|
-
* @param str
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
export const hash = (str: string) => {
|
|
32
|
-
let hash = 0;
|
|
33
|
-
let i;
|
|
34
|
-
let chr;
|
|
35
|
-
if (isEmpty(str)) return hash;
|
|
36
|
-
for (i = 0; i < str.length; i++) {
|
|
37
|
-
chr = str.charCodeAt(i);
|
|
38
|
-
hash = (hash << 5) - hash + chr;
|
|
39
|
-
hash |= 0; // Convert to 32bit integer
|
|
40
|
-
}
|
|
41
|
-
return hash;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* generate short hash from current time
|
|
46
|
-
* @internal
|
|
47
|
-
*/
|
|
48
|
-
export const shortHash = () => {
|
|
49
|
-
return (new Date().getTime() + Math.trunc(Math.random() * 1000)).toString(36);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* generate uuid using `crypto.getRandomValues`
|
|
54
|
-
* @internal
|
|
55
|
-
*/
|
|
56
|
-
export const uuid = () => {
|
|
57
|
-
return [1e7, 1e3, 4e3, 8e3, 1e11]
|
|
58
|
-
.join("-")
|
|
59
|
-
.replace(/[018]/g, (c: string) =>
|
|
60
|
-
(+c ^ ((Math.random() * 16) & (15 >> (+c / 4)))).toString(16),
|
|
61
|
-
);
|
|
62
|
-
};
|
package/src/_interpolate.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* React Fabric
|
|
3
|
-
* @version: 1.0.0
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* The MIT License (MIT)
|
|
7
|
-
* Copyright (c) 2024 Adarsh Pastakia
|
|
8
|
-
*
|
|
9
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
|
-
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
11
|
-
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
-
* subject to the following conditions:
|
|
14
|
-
*
|
|
15
|
-
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
16
|
-
* portions of the Software.
|
|
17
|
-
*
|
|
18
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
-
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
20
|
-
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
import { getByPath } from "./_getByPath";
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* interpolate string template using model
|
|
28
|
-
* @internal
|
|
29
|
-
*/
|
|
30
|
-
export const interpolate = (str: string, model: KeyValue) => {
|
|
31
|
-
return str.replace(/\${([^{}]*)}/g, (a: string, b: string): string => {
|
|
32
|
-
const r = getByPath(model, b);
|
|
33
|
-
return typeof r === "string" || typeof r === "number" ? `${r}` : "";
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const renderTemplate = (str: string, model: KeyValue) => {
|
|
38
|
-
return str.replace(/{{([^{}]*)}}/g, (a: string, b: string): string => {
|
|
39
|
-
const r = getByPath(model, b);
|
|
40
|
-
return typeof r === "string" || typeof r === "number" ? `${r}` : "";
|
|
41
|
-
});
|
|
42
|
-
};
|
package/src/_isEqual.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* React Fabric
|
|
3
|
-
* @version: 1.0.0
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* The MIT License (MIT)
|
|
7
|
-
* Copyright (c) 2024 Adarsh Pastakia
|
|
8
|
-
*
|
|
9
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
|
-
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
11
|
-
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
-
* subject to the following conditions:
|
|
14
|
-
*
|
|
15
|
-
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
16
|
-
* portions of the Software.
|
|
17
|
-
*
|
|
18
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
-
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
20
|
-
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
import { ascii } from "./_ascii";
|
|
25
|
-
import { isBoolean, isNumber, isObject, isString } from "./_isType";
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* check equality of objects
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
export const isEqual = (obj: unknown, test: unknown): boolean => {
|
|
32
|
-
if (isString(obj) || isNumber(obj) || isBoolean(obj)) {
|
|
33
|
-
return obj === test;
|
|
34
|
-
} else if (Array.isArray(obj) && Array.isArray(test)) {
|
|
35
|
-
// if length dont match return false
|
|
36
|
-
if (obj.length !== test.length) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
// check if some value is false
|
|
40
|
-
return !obj.some((o, i) => !isEqual(o, test[i]));
|
|
41
|
-
} else if (isObject(obj) && isObject(test)) {
|
|
42
|
-
const okeys = Object.keys(obj);
|
|
43
|
-
const tkeys = Object.keys(test);
|
|
44
|
-
// if keys length dont match return false
|
|
45
|
-
if (okeys.length !== tkeys.length) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
// if keys dont match return false
|
|
49
|
-
if (okeys.some((k) => !tkeys.includes(k))) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
// check if some value is false
|
|
53
|
-
return !Object.keys(obj).some((k) => !isEqual(obj[k], test[k]));
|
|
54
|
-
}
|
|
55
|
-
return false;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* match strings
|
|
60
|
-
* @internal
|
|
61
|
-
*/
|
|
62
|
-
export const matchString = (
|
|
63
|
-
base: string,
|
|
64
|
-
match: string,
|
|
65
|
-
equality: "start" | boolean = false,
|
|
66
|
-
) => {
|
|
67
|
-
const _base = ascii(base).toLowerCase();
|
|
68
|
-
const _match = ascii(match).toLowerCase();
|
|
69
|
-
|
|
70
|
-
return equality === true
|
|
71
|
-
? _base === _match
|
|
72
|
-
: equality === "start"
|
|
73
|
-
? _base.startsWith(_match)
|
|
74
|
-
: _base.includes(_match);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* compare values
|
|
79
|
-
* @internal
|
|
80
|
-
*/
|
|
81
|
-
export const compareValues =
|
|
82
|
-
(order: "asc" | "desc" = "asc", key?: string) =>
|
|
83
|
-
(a: unknown, b: unknown) => {
|
|
84
|
-
const aValue: string = key && isObject(a) ? a[key] : a;
|
|
85
|
-
const bValue: string = key && isObject(b) ? b[key] : b;
|
|
86
|
-
|
|
87
|
-
const bigger = order === "asc" ? 1 : -1;
|
|
88
|
-
const smaller = order === "desc" ? 1 : -1;
|
|
89
|
-
// return 0 when equal, allowing for multiple sorting properties
|
|
90
|
-
if (aValue === bValue) return 0;
|
|
91
|
-
// if numbers check greater
|
|
92
|
-
if (isNumber(aValue) && isNumber(bValue)) {
|
|
93
|
-
return aValue > bValue ? bigger : smaller;
|
|
94
|
-
}
|
|
95
|
-
// if boolean sort true first
|
|
96
|
-
if (isBoolean(aValue) && isBoolean(bValue)) {
|
|
97
|
-
return aValue ? smaller : bigger;
|
|
98
|
-
}
|
|
99
|
-
const _a = ascii(aValue).toLowerCase();
|
|
100
|
-
const _b = ascii(bValue).toLowerCase();
|
|
101
|
-
return _a.localeCompare(_b) === 1 ? bigger : smaller;
|
|
102
|
-
};
|