@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
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Fabric
|
|
3
|
+
* @version 1.0.0
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2024 Adarsh Pastakia
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { isNil } from "./nullChecks";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Check if a value is an object.
|
|
30
|
+
* An object is considered valid if it is:
|
|
31
|
+
* - not null or undefined
|
|
32
|
+
* - not a Date instance
|
|
33
|
+
* - of type 'object'
|
|
34
|
+
* - not an array
|
|
35
|
+
* @param val - The value to check.
|
|
36
|
+
* @returns true if the value is an object, false otherwise.
|
|
37
|
+
*/
|
|
38
|
+
export function isObject<T = KeyValue>(val: AnyObject): val is T {
|
|
39
|
+
return !isNil(val) && !(val instanceof Date) && typeof val === "object" && !Array.isArray(val);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Check if a value is an array.
|
|
44
|
+
* An array is considered valid if it is:
|
|
45
|
+
* - not null or undefined
|
|
46
|
+
* - an instance of Array
|
|
47
|
+
* @param val - The value to check.
|
|
48
|
+
* @returns true if the value is an array, false otherwise.
|
|
49
|
+
*/
|
|
50
|
+
export function isArray<T = AnyObject>(val: AnyObject): val is T[] {
|
|
51
|
+
return Array.isArray(val);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Check if a value is a string.
|
|
56
|
+
* A string is considered valid if it is:
|
|
57
|
+
* - not null or undefined
|
|
58
|
+
* - of type 'string'
|
|
59
|
+
* @param value - The value to check.
|
|
60
|
+
* @returns true if the value is a string, false otherwise.
|
|
61
|
+
*/
|
|
62
|
+
export function isString(value: AnyObject): value is string {
|
|
63
|
+
return typeof value === "string";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Check if a value is a number.
|
|
68
|
+
* A number is considered valid if it is:
|
|
69
|
+
* - not null or undefined
|
|
70
|
+
* - of type 'number'
|
|
71
|
+
* @param value - The value to check.
|
|
72
|
+
* @returns true if the value is a number, false otherwise.
|
|
73
|
+
*/
|
|
74
|
+
export function isNumber(value: AnyObject): value is number {
|
|
75
|
+
return typeof value === "number";
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Check if a value is a boolean.
|
|
80
|
+
* A boolean is considered valid if it is:
|
|
81
|
+
* - not null or undefined
|
|
82
|
+
* - of type 'boolean'
|
|
83
|
+
*/
|
|
84
|
+
export function isBoolean(value: AnyObject): value is boolean {
|
|
85
|
+
return typeof value === "boolean";
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Check if a value is a true.
|
|
90
|
+
* A value is considered true if it is:
|
|
91
|
+
* - strictly equal to true
|
|
92
|
+
* - equal to 1
|
|
93
|
+
* - a string that is "yes" or "true" (case insensitive)
|
|
94
|
+
*/
|
|
95
|
+
export function isTrue(value: unknown = ""): value is true {
|
|
96
|
+
return (
|
|
97
|
+
value === true || value === 1 || value?.toString().toLowerCase() === "yes" || value?.toString().toLowerCase() === "true"
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Check if a value is false.
|
|
103
|
+
* A value is considered false if it is:
|
|
104
|
+
* - strictly equal to false
|
|
105
|
+
* - equal to 0
|
|
106
|
+
* - a string that is "no" or "false" (case insensitive)
|
|
107
|
+
*/
|
|
108
|
+
export function isFalse(value: unknown = ""): value is false {
|
|
109
|
+
return (
|
|
110
|
+
value === false || value === 0 || value?.toString().toLowerCase() === "no" || value?.toString().toLowerCase() === "false"
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Check if a value is a valid color.
|
|
116
|
+
* A color is considered valid if it:
|
|
117
|
+
* - starts with a '#' (hex color)
|
|
118
|
+
* - starts with 'rgb' (RGB color)
|
|
119
|
+
* - starts with 'hsl' (HSL color)
|
|
120
|
+
* - starts with 'lab' (Lab color)
|
|
121
|
+
* - is equal to 'transparent'
|
|
122
|
+
* @param color - The value to check.
|
|
123
|
+
* @returns true if the value is a valid color, false otherwise.
|
|
124
|
+
*/
|
|
125
|
+
export function isColor(color: string) {
|
|
126
|
+
return (
|
|
127
|
+
color.startsWith?.("#") ||
|
|
128
|
+
color.startsWith?.("rgb") ||
|
|
129
|
+
color.startsWith?.("hsl") ||
|
|
130
|
+
color.startsWith?.("lab") ||
|
|
131
|
+
color === "transparent"
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Check if a value is a valid SVG path.
|
|
137
|
+
* A valid SVG path is a string that:
|
|
138
|
+
* - starts with 'M' or 'm' (move to command)
|
|
139
|
+
* - contains at least one digit or decimal point
|
|
140
|
+
* - ends with 'Z' or 'z' (close path command)
|
|
141
|
+
* @param value - The value to check.
|
|
142
|
+
* @returns true if the value is a valid SVG path, false otherwise.
|
|
143
|
+
*/
|
|
144
|
+
export function isSvgPath(value: AnyObject): boolean {
|
|
145
|
+
return typeof value === "string" && value.match(/^[Mm][\d.].*[\dzZ]$/) !== null;
|
|
146
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Fabric
|
|
3
|
+
* @version 1.0.0
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2024 Adarsh Pastakia
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { isEmpty } from "../matchers/isEmpty";
|
|
27
|
+
|
|
28
|
+
/* istanbul ignore file */
|
|
29
|
+
|
|
30
|
+
/** ***************** latin-ascii conversions *******************/
|
|
31
|
+
const conversions = {
|
|
32
|
+
AE: "Æ|Ǽ",
|
|
33
|
+
Ae: "Ä",
|
|
34
|
+
ae: "ä|æ|ǽ",
|
|
35
|
+
OE: "Œ",
|
|
36
|
+
Oe: "Ö",
|
|
37
|
+
oe: "ö|œ",
|
|
38
|
+
Ue: "Ü",
|
|
39
|
+
ue: "ü",
|
|
40
|
+
IJ: "IJ",
|
|
41
|
+
ij: "ij",
|
|
42
|
+
ss: "ß",
|
|
43
|
+
A: "À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ",
|
|
44
|
+
a: "à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª",
|
|
45
|
+
C: "Ç|Ć|Ĉ|Ċ|Č",
|
|
46
|
+
c: "ç|ć|ĉ|ċ|č",
|
|
47
|
+
D: "Ð|Ď|Đ",
|
|
48
|
+
d: "ð|ď|đ",
|
|
49
|
+
E: "È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě",
|
|
50
|
+
e: "è|é|ê|ë|ē|ĕ|ė|ę|ě",
|
|
51
|
+
G: "Ĝ|Ğ|Ġ|Ģ",
|
|
52
|
+
g: "ĝ|ğ|ġ|ģ",
|
|
53
|
+
H: "Ĥ|Ħ",
|
|
54
|
+
h: "ĥ|ħ",
|
|
55
|
+
I: "Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ",
|
|
56
|
+
i: "ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı",
|
|
57
|
+
J: "Ĵ",
|
|
58
|
+
j: "ĵ",
|
|
59
|
+
K: "Ķ",
|
|
60
|
+
k: "ķ",
|
|
61
|
+
L: "Ĺ|Ļ|Ľ|Ŀ|Ł",
|
|
62
|
+
l: "ĺ|ļ|ľ|ŀ|ł",
|
|
63
|
+
N: "Ñ|Ń|Ņ|Ň",
|
|
64
|
+
n: "ñ|ń|ņ|ň|ʼn",
|
|
65
|
+
O: "Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ",
|
|
66
|
+
o: "ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º",
|
|
67
|
+
R: "Ŕ|Ŗ|Ř",
|
|
68
|
+
r: "ŕ|ŗ|ř",
|
|
69
|
+
S: "Ś|Ŝ|Ş|Š",
|
|
70
|
+
s: "ś|ŝ|ş|š|ſ",
|
|
71
|
+
T: "Ţ|Ť|Ŧ",
|
|
72
|
+
t: "ţ|ť|ŧ",
|
|
73
|
+
U: "Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ",
|
|
74
|
+
u: "ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ",
|
|
75
|
+
Y: "Ý|Ÿ|Ŷ",
|
|
76
|
+
y: "ý|ÿ|ŷ",
|
|
77
|
+
W: "Ŵ",
|
|
78
|
+
w: "ŵ",
|
|
79
|
+
Z: "Ź|Ż|Ž",
|
|
80
|
+
z: "ź|ż|ž",
|
|
81
|
+
f: "ƒ",
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Converts a string to its ASCII representation by replacing
|
|
86
|
+
* special characters with their ASCII equivalents.
|
|
87
|
+
* This function is useful for normalizing strings for search or display purposes.
|
|
88
|
+
* It replaces characters like "Ä" with "Ae", "ß" with "ss", etc.
|
|
89
|
+
*
|
|
90
|
+
* @param {string} str - The input string to be converted.
|
|
91
|
+
* @returns {string} - The ASCII representation of the input string.
|
|
92
|
+
*/
|
|
93
|
+
export function ascii(str: string) {
|
|
94
|
+
if (isEmpty(str)) return "";
|
|
95
|
+
Object.entries(conversions).forEach((entry) => {
|
|
96
|
+
const re = new RegExp(entry[1], "g");
|
|
97
|
+
str = `${str}`.replace(re, entry[0]);
|
|
98
|
+
});
|
|
99
|
+
return str;
|
|
100
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Fabric
|
|
3
|
+
* @version 1.0.0
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2024 Adarsh Pastakia
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { isEmpty } from "../matchers/isEmpty";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Generate a hash from a string.
|
|
30
|
+
* This function computes a simple hash by iterating over each character in the string,
|
|
31
|
+
* performing bitwise operations to produce a 32-bit integer hash.
|
|
32
|
+
* @param str
|
|
33
|
+
* @returns {number} A 32-bit integer hash of the input string.
|
|
34
|
+
*/
|
|
35
|
+
export function hash(str: string) {
|
|
36
|
+
let hash = 0;
|
|
37
|
+
let i;
|
|
38
|
+
let chr;
|
|
39
|
+
if (isEmpty(str)) return hash;
|
|
40
|
+
for (i = 0; i < str.length; i++) {
|
|
41
|
+
chr = str.charCodeAt(i);
|
|
42
|
+
hash = (hash << 5) - hash + chr;
|
|
43
|
+
hash |= 0; // Convert to 32bit integer
|
|
44
|
+
}
|
|
45
|
+
return hash;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Generate a short hash using the current timestamp and a random number.
|
|
50
|
+
* This function creates a unique identifier by combining the current time in milliseconds
|
|
51
|
+
* with a random number, and then converting it to a base-36 string.
|
|
52
|
+
* @returns {string} A short hash string.
|
|
53
|
+
*/
|
|
54
|
+
export function shortHash() {
|
|
55
|
+
return (new Date().getTime() * Math.random()).toString(36);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Generate a UUID (Universally Unique Identifier).
|
|
60
|
+
* This function creates a version 4 UUID by generating random numbers
|
|
61
|
+
* and formatting them according to the UUID standard.
|
|
62
|
+
* @returns {string} A UUID string in the format xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx.
|
|
63
|
+
*/
|
|
64
|
+
export function uuid() {
|
|
65
|
+
return [1e7, 1e3, 4e3, 8e3, 1e11]
|
|
66
|
+
.join("-")
|
|
67
|
+
.replace(/[018]/g, (c: string) => (+c ^ ((Math.random() * 16) & (15 >> (+c / 4)))).toString(16));
|
|
68
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Fabric
|
|
3
|
+
* @version 1.0.0
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2024 Adarsh Pastakia
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { getByPath } from "../lists/getByPath";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Interpolate a string with values from a model.
|
|
30
|
+
* This function replaces placeholders in the format ${key} with corresponding values from the model object.
|
|
31
|
+
* If the value is not a string or number, it returns an empty string.
|
|
32
|
+
*
|
|
33
|
+
* @param {string} str - The string to interpolate.
|
|
34
|
+
* @param {KeyValue} model - The model object containing key-value pairs for interpolation.
|
|
35
|
+
* @returns {string} The interpolated string with placeholders replaced by values from the model.
|
|
36
|
+
*/
|
|
37
|
+
export function interpolate(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
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Fabric
|
|
3
|
+
* @version 1.0.0
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2024 Adarsh Pastakia
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { ascii } from "./ascii";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Match a string against another string with options for equality.
|
|
30
|
+
* This function checks if the base string starts with, includes, or is equal to the match string,
|
|
31
|
+
* based on the specified equality condition.
|
|
32
|
+
* It normalizes both strings to lowercase and ASCII format before comparison.
|
|
33
|
+
* This is useful for case-insensitive and ASCII-only comparisons,
|
|
34
|
+
* such as when filtering or searching through text data.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} base - The base string to match against.
|
|
37
|
+
* @param {string} match - The string to match with the base string.
|
|
38
|
+
* @param {("start" | boolean)} equality - The type of match to perform:
|
|
39
|
+
* - "start": checks if the base string starts with the match string.
|
|
40
|
+
* - true: checks for exact equality.
|
|
41
|
+
* - false (default): checks if the base string includes the match string.
|
|
42
|
+
* @returns {boolean} - Returns true if the base string matches the conditions specified by the match string and equality.
|
|
43
|
+
*/
|
|
44
|
+
export function matchString(base: string, match: string, equality: "start" | boolean = false) {
|
|
45
|
+
const _base = ascii(base).toLowerCase();
|
|
46
|
+
const _match = ascii(match).toLowerCase();
|
|
47
|
+
|
|
48
|
+
return equality === true ? _base === _match : equality === "start" ? _base.startsWith(_match) : _base.includes(_match);
|
|
49
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Fabric
|
|
3
|
+
* @version 1.0.0
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2024 Adarsh Pastakia
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { getByPath } from "../lists/getByPath";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Render a template string with values from a model.
|
|
30
|
+
* This function replaces placeholders in the format {{key}} with corresponding values from the model object.
|
|
31
|
+
* If the value is not a string or number, it returns an empty string.
|
|
32
|
+
* This is similar to the interpolate function but for handlebar templates.
|
|
33
|
+
*
|
|
34
|
+
* @param {string} str - The template string to render.
|
|
35
|
+
* @param {KeyValue} model - The model object containing key-value pairs for rendering the template.
|
|
36
|
+
* @returns {string} The rendered template string with placeholders replaced by values from the model.
|
|
37
|
+
*/
|
|
38
|
+
export function renderTemplate(str: string, model: KeyValue) {
|
|
39
|
+
return str.replace(/{{([^{}]*)}}/g, (a: string, b: string): string => {
|
|
40
|
+
const r = getByPath(model, b);
|
|
41
|
+
return typeof r === "string" || typeof r === "number" ? `${r}` : "";
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Fabric
|
|
3
|
+
* @version 1.0.0
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2024 Adarsh Pastakia
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { isEmpty } from "../matchers/isEmpty";
|
|
27
|
+
import { isArray } from "../matchers/typeChecks";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Tokenize a string based on provided keywords.
|
|
31
|
+
* This function splits the input string into tokens, where each token is an array containing
|
|
32
|
+
* the substring before the keyword and the keyword itself.
|
|
33
|
+
* If no keywords are provided, it returns the entire string as a single token.
|
|
34
|
+
*
|
|
35
|
+
* @param {string} str - The string to tokenize.
|
|
36
|
+
* @param {string | string[]} keywords - A string or an array of strings to use as keywords for tokenization.
|
|
37
|
+
* @returns {Array<[string, string]>} An array of tokens, where each token is an array of [substring, keyword].
|
|
38
|
+
*/
|
|
39
|
+
export function tokenize(str: string, keywords?: string | string[]) {
|
|
40
|
+
if (isEmpty(keywords)) {
|
|
41
|
+
return [[str, ""]];
|
|
42
|
+
}
|
|
43
|
+
const keys = isArray(keywords) ? keywords : [keywords];
|
|
44
|
+
const keyMap = keys.map((key) => {
|
|
45
|
+
// escape regex control characters
|
|
46
|
+
let escapedKey = key.replace(/([+*.?^$()[\]\\!&|\-=])/gm, "\\$1");
|
|
47
|
+
// place token within word boundaries if start/end with alpha-numeric
|
|
48
|
+
if (key.match(/^[a-z0-9]/i) != null) escapedKey = `\\b${escapedKey}`;
|
|
49
|
+
if (key.match(/[a-z0-9]$/i) != null) escapedKey = `${escapedKey}\\b`;
|
|
50
|
+
return escapedKey;
|
|
51
|
+
});
|
|
52
|
+
const regx = new RegExp(`(${keyMap.join("|")})`, "img");
|
|
53
|
+
let match;
|
|
54
|
+
let lastIndex = 0;
|
|
55
|
+
const tokens = [];
|
|
56
|
+
while ((match = regx.exec(str)) !== null) {
|
|
57
|
+
tokens.push([str.substring(lastIndex, match.index), str.substring(match.index, regx.lastIndex)]);
|
|
58
|
+
lastIndex = regx.lastIndex;
|
|
59
|
+
}
|
|
60
|
+
tokens.push([str.substring(lastIndex), ""]);
|
|
61
|
+
return tokens;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Generate a token from a string.
|
|
66
|
+
* This function creates a token by taking the first letter of the first word and the first letter of the last word,
|
|
67
|
+
* or the first two letters of the first word if there is no last word.
|
|
68
|
+
*
|
|
69
|
+
* @param {string} str - The string to tokenize.
|
|
70
|
+
* @returns {string} A string token consisting of the first letters of the first and last words, or the first two letters of the first word.
|
|
71
|
+
*/
|
|
72
|
+
export function iconToken(str: string) {
|
|
73
|
+
const split = str.trim().split(" ");
|
|
74
|
+
const first = split[0];
|
|
75
|
+
const last = split.length > 1 && split.pop();
|
|
76
|
+
return (first && last ? `${first.charAt(0)}${last.charAt(0)}` : `${first.substring(0, 2)}`).toUpperCase();
|
|
77
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Fabric
|
|
3
|
+
* @version 1.0.0
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @copyright 2024 Adarsh Pastakia
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/* istanbul ignore file */
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Merge multiple refs into a single ref callback.
|
|
30
|
+
* This function allows you to combine multiple refs (either callback refs or React refs)
|
|
31
|
+
* into a single ref callback that can be used in React components.
|
|
32
|
+
* This is particularly useful when you want to assign a single element to multiple refs,
|
|
33
|
+
* such as when using third-party libraries that require refs or when you want to share refs between components.
|
|
34
|
+
* The function iterates over the provided refs and assigns the element to each ref.
|
|
35
|
+
*
|
|
36
|
+
* @param {AnyObject[]} refs - An array of refs to merge.
|
|
37
|
+
* @returns {function} A function that takes an element and assigns it to all provided refs.
|
|
38
|
+
*/
|
|
39
|
+
export function mergeRefs(...refs: unknown[]) {
|
|
40
|
+
return (el: unknown) => {
|
|
41
|
+
refs.forEach((ref) => {
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
43
|
+
if (typeof ref === "function") ref(el);
|
|
44
|
+
if (ref && typeof ref === "object" && "current" in ref) ref.current = el;
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -27,15 +27,15 @@ import * as _yup from "yup";
|
|
|
27
27
|
|
|
28
28
|
_yup.setLocale({
|
|
29
29
|
mixed: {
|
|
30
|
-
default: ({ path, label }) => ({
|
|
30
|
+
default: ({ path, label }: KeyValue<string>) => ({
|
|
31
31
|
key: "form:yup.invalid",
|
|
32
32
|
values: { path, label },
|
|
33
33
|
}),
|
|
34
|
-
required: ({ path, label }) => ({
|
|
34
|
+
required: ({ path, label }: KeyValue<string>) => ({
|
|
35
35
|
key: "form:yup.required",
|
|
36
36
|
values: { path, label },
|
|
37
37
|
}),
|
|
38
|
-
notType: ({ type, path, label }) => ({
|
|
38
|
+
notType: ({ type, path, label }: KeyValue<string>) => ({
|
|
39
39
|
key: "form:yup.invalidType",
|
|
40
40
|
values: { type, path, label },
|
|
41
41
|
}),
|
package/dist/cjs/_ascii.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
4
|
-
var _isType = require('./_isType.js');
|
|
5
|
-
|
|
6
|
-
/** ***************** latin-ascii conversions *******************/
|
|
7
|
-
var conversions = {
|
|
8
|
-
AE: "Æ|Ǽ",
|
|
9
|
-
Ae: "Ä",
|
|
10
|
-
ae: "ä|æ|ǽ",
|
|
11
|
-
OE: "Œ",
|
|
12
|
-
Oe: "Ö",
|
|
13
|
-
oe: "ö|œ",
|
|
14
|
-
Ue: "Ü",
|
|
15
|
-
ue: "ü",
|
|
16
|
-
IJ: "IJ",
|
|
17
|
-
ij: "ij",
|
|
18
|
-
ss: "ß",
|
|
19
|
-
A: "À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ",
|
|
20
|
-
a: "à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª",
|
|
21
|
-
C: "Ç|Ć|Ĉ|Ċ|Č",
|
|
22
|
-
c: "ç|ć|ĉ|ċ|č",
|
|
23
|
-
D: "Ð|Ď|Đ",
|
|
24
|
-
d: "ð|ď|đ",
|
|
25
|
-
E: "È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě",
|
|
26
|
-
e: "è|é|ê|ë|ē|ĕ|ė|ę|ě",
|
|
27
|
-
G: "Ĝ|Ğ|Ġ|Ģ",
|
|
28
|
-
g: "ĝ|ğ|ġ|ģ",
|
|
29
|
-
H: "Ĥ|Ħ",
|
|
30
|
-
h: "ĥ|ħ",
|
|
31
|
-
I: "Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ",
|
|
32
|
-
i: "ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı",
|
|
33
|
-
J: "Ĵ",
|
|
34
|
-
j: "ĵ",
|
|
35
|
-
K: "Ķ",
|
|
36
|
-
k: "ķ",
|
|
37
|
-
L: "Ĺ|Ļ|Ľ|Ŀ|Ł",
|
|
38
|
-
l: "ĺ|ļ|ľ|ŀ|ł",
|
|
39
|
-
N: "Ñ|Ń|Ņ|Ň",
|
|
40
|
-
n: "ñ|ń|ņ|ň|ʼn",
|
|
41
|
-
O: "Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ",
|
|
42
|
-
o: "ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º",
|
|
43
|
-
R: "Ŕ|Ŗ|Ř",
|
|
44
|
-
r: "ŕ|ŗ|ř",
|
|
45
|
-
S: "Ś|Ŝ|Ş|Š",
|
|
46
|
-
s: "ś|ŝ|ş|š|ſ",
|
|
47
|
-
T: "Ţ|Ť|Ŧ",
|
|
48
|
-
t: "ţ|ť|ŧ",
|
|
49
|
-
U: "Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ",
|
|
50
|
-
u: "ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ",
|
|
51
|
-
Y: "Ý|Ÿ|Ŷ",
|
|
52
|
-
y: "ý|ÿ|ŷ",
|
|
53
|
-
W: "Ŵ",
|
|
54
|
-
w: "ŵ",
|
|
55
|
-
Z: "Ź|Ż|Ž",
|
|
56
|
-
z: "ź|ż|ž",
|
|
57
|
-
f: "ƒ"
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* latin to ascii converter for convenient searching
|
|
62
|
-
* @internal
|
|
63
|
-
*/
|
|
64
|
-
var ascii = function ascii(str) {
|
|
65
|
-
if (_isType.isEmpty(str)) return "";
|
|
66
|
-
Object.entries(conversions).forEach(function (_ref) {
|
|
67
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
68
|
-
a = _ref2[0],
|
|
69
|
-
l = _ref2[1];
|
|
70
|
-
var re = new RegExp(l, "g");
|
|
71
|
-
str = "".concat(str).replace(re, a);
|
|
72
|
-
});
|
|
73
|
-
return str;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
exports.ascii = ascii;
|