@cocreate/utils 1.44.2 → 1.44.3
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/package.json +1 -1
- package/src/ObjectId.js +59 -37
- package/src/ast/index.js +404 -0
- package/src/{operators.js → ast/operators.js} +247 -250
- package/src/cloudProviders.js +150 -0
- package/src/createUpdate.js +1 -29
- package/src/dataQuery.js +2 -2
- package/src/getClientInfo.js +357 -0
- package/src/getClockOffset.js +46 -0
- package/src/getCountryLocation.js +278 -0
- package/src/index.js +47 -35
- package/src/ulid.js +72 -0
- package/src/uuid.js +67 -0
- package/src/core.js +0 -6
- package/src/operators copy.js +0 -687
- package/src/operators.ast.js +0 -287
- package/src/operators.v1.js +0 -687
- package/src/safeParse.js +0 -171
- package/src/uid.js +0 -16
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
export const COUNTRY_LOCATIONS = {
|
|
2
|
+
// North America & Caribbean
|
|
3
|
+
AG: { country: "AG", latitude: 17.0608, longitude: -61.7964, continent: "NA" }, // Antigua and Barbuda
|
|
4
|
+
AI: { country: "AI", latitude: 18.2206, longitude: -63.0686, continent: "NA" }, // Anguilla
|
|
5
|
+
AW: { country: "AW", latitude: 12.5211, longitude: -69.9683, continent: "NA" }, // Aruba
|
|
6
|
+
BB: { country: "BB", latitude: 13.1939, longitude: -59.5432, continent: "NA" }, // Barbados
|
|
7
|
+
BL: { country: "BL", latitude: 17.9000, longitude: -62.8333, continent: "NA" }, // Saint Barthélemy
|
|
8
|
+
BM: { country: "BM", latitude: 32.3078, longitude: -64.7505, continent: "NA" }, // Bermuda
|
|
9
|
+
BQ: { country: "BQ", latitude: 12.2019, longitude: -68.2624, continent: "NA" }, // Bonaire, Sint Eustatius and Saba
|
|
10
|
+
BS: { country: "BS", latitude: 25.0343, longitude: -77.3963, continent: "NA" }, // Bahamas
|
|
11
|
+
BZ: { country: "BZ", latitude: 17.1899, longitude: -88.4976, continent: "NA" }, // Belize
|
|
12
|
+
CA: { country: "CA", latitude: 56.1304, longitude: -106.3468, continent: "NA" }, // Canada
|
|
13
|
+
CR: { country: "CR", latitude: 9.7489, longitude: -83.7534, continent: "NA" }, // Costa Rica
|
|
14
|
+
CU: { country: "CU", latitude: 21.5218, longitude: -77.7812, continent: "NA" }, // Cuba
|
|
15
|
+
CW: { country: "CW", latitude: 12.1696, longitude: -68.9900, continent: "NA" }, // Curaçao
|
|
16
|
+
DM: { country: "DM", latitude: 15.4150, longitude: -61.3710, continent: "NA" }, // Dominica
|
|
17
|
+
DO: { country: "DO", latitude: 18.7357, longitude: -70.1627, continent: "NA" }, // Dominican Republic
|
|
18
|
+
GD: { country: "GD", latitude: 12.1165, longitude: -61.6790, continent: "NA" }, // Grenada
|
|
19
|
+
GL: { country: "GL", latitude: 71.7069, longitude: -42.6043, continent: "NA" }, // Greenland
|
|
20
|
+
GP: { country: "GP", latitude: 16.2650, longitude: -61.5510, continent: "NA" }, // Guadeloupe
|
|
21
|
+
GT: { country: "GT", latitude: 15.7835, longitude: -90.2308, continent: "NA" }, // Guatemala
|
|
22
|
+
HN: { country: "HN", latitude: 15.1999, longitude: -86.2419, continent: "NA" }, // Honduras
|
|
23
|
+
HT: { country: "HT", latitude: 18.9712, longitude: -72.2852, continent: "NA" }, // Haiti
|
|
24
|
+
JM: { country: "JM", latitude: 18.1096, longitude: -77.2975, continent: "NA" }, // Jamaica
|
|
25
|
+
KN: { country: "KN", latitude: 17.3578, longitude: -62.7830, continent: "NA" }, // Saint Kitts and Nevis
|
|
26
|
+
KY: { country: "KY", latitude: 19.5135, longitude: -80.5669, continent: "NA" }, // Cayman Islands
|
|
27
|
+
LC: { country: "LC", latitude: 13.9094, longitude: -60.9789, continent: "NA" }, // Saint Lucia
|
|
28
|
+
MF: { country: "MF", latitude: 18.0708, longitude: -63.0501, continent: "NA" }, // Saint Martin
|
|
29
|
+
MQ: { country: "MQ", latitude: 14.6415, longitude: -61.0242, continent: "NA" }, // Martinique
|
|
30
|
+
MS: { country: "MS", latitude: 16.7425, longitude: -62.1874, continent: "NA" }, // Montserrat
|
|
31
|
+
MX: { country: "MX", latitude: 23.6345, longitude: -102.5528, continent: "NA" }, // Mexico
|
|
32
|
+
NI: { country: "NI", latitude: 12.8654, longitude: -85.2072, continent: "NA" }, // Nicaragua
|
|
33
|
+
PA: { country: "PA", latitude: 8.5380, longitude: -80.7821, continent: "NA" }, // Panama
|
|
34
|
+
PM: { country: "PM", latitude: 46.8852, longitude: -56.3159, continent: "NA" }, // Saint Pierre and Miquelon
|
|
35
|
+
PR: { country: "PR", latitude: 18.2208, longitude: -66.5901, continent: "NA" }, // Puerto Rico
|
|
36
|
+
SV: { country: "SV", latitude: 13.7942, longitude: -88.8965, continent: "NA" }, // El Salvador
|
|
37
|
+
SX: { country: "SX", latitude: 18.0425, longitude: -63.0548, continent: "NA" }, // Sint Maarten
|
|
38
|
+
TC: { country: "TC", latitude: 21.6940, longitude: -71.7979, continent: "NA" }, // Turks and Caicos Islands
|
|
39
|
+
TT: { country: "TT", latitude: 10.6918, longitude: -61.2225, continent: "NA" }, // Trinidad and Tobago
|
|
40
|
+
US: { country: "US", latitude: 39.8283, longitude: -98.5795, continent: "NA" }, // United States
|
|
41
|
+
VC: { country: "VC", latitude: 12.9843, longitude: -61.2872, continent: "NA" }, // Saint Vincent and the Grenadines
|
|
42
|
+
VG: { country: "VG", latitude: 18.4207, longitude: -64.6399, continent: "NA" }, // British Virgin Islands
|
|
43
|
+
VI: { country: "VI", latitude: 18.3358, longitude: -64.8963, continent: "NA" }, // U.S. Virgin Islands
|
|
44
|
+
|
|
45
|
+
// South America
|
|
46
|
+
AR: { country: "AR", latitude: -38.4161, longitude: -63.6167, continent: "SA" }, // Argentina
|
|
47
|
+
BO: { country: "BO", latitude: -16.2902, longitude: -63.5887, continent: "SA" }, // Bolivia
|
|
48
|
+
BR: { country: "BR", latitude: -14.2350, longitude: -51.9253, continent: "SA" }, // Brazil
|
|
49
|
+
CL: { country: "CL", latitude: -35.6751, longitude: -71.5430, continent: "SA" }, // Chile
|
|
50
|
+
CO: { country: "CO", latitude: 4.5709, longitude: -74.2973, continent: "SA" }, // Colombia
|
|
51
|
+
EC: { country: "EC", latitude: -1.8312, longitude: -78.1834, continent: "SA" }, // Ecuador
|
|
52
|
+
FK: { country: "FK", latitude: -51.7963, longitude: -59.5236, continent: "SA" }, // Falkland Islands
|
|
53
|
+
GF: { country: "GF", latitude: 3.9339, longitude: -53.1258, continent: "SA" }, // French Guiana
|
|
54
|
+
GY: { country: "GY", latitude: 4.8604, longitude: -58.9302, continent: "SA" }, // Guyana
|
|
55
|
+
PE: { country: "PE", latitude: -9.1900, longitude: -75.0152, continent: "SA" }, // Peru
|
|
56
|
+
PY: { country: "PY", latitude: -23.4425, longitude: -58.4438, continent: "SA" }, // Paraguay
|
|
57
|
+
SR: { country: "SR", latitude: 3.9193, longitude: -56.0278, continent: "SA" }, // Suriname
|
|
58
|
+
UY: { country: "UY", latitude: -32.5228, longitude: -55.7658, continent: "SA" }, // Uruguay
|
|
59
|
+
VE: { country: "VE", latitude: 6.4238, longitude: -66.5897, continent: "SA" }, // Venezuela
|
|
60
|
+
|
|
61
|
+
// Europe
|
|
62
|
+
AD: { country: "AD", latitude: 42.5063, longitude: 1.5218, continent: "EU" }, // Andorra
|
|
63
|
+
AL: { country: "AL", latitude: 41.1533, longitude: 20.1683, continent: "EU" }, // Albania
|
|
64
|
+
AT: { country: "AT", latitude: 47.5162, longitude: 14.5501, continent: "EU" }, // Austria
|
|
65
|
+
AX: { country: "AX", latitude: 60.1785, longitude: 19.9156, continent: "EU" }, // Åland Islands
|
|
66
|
+
BA: { country: "BA", latitude: 43.9159, longitude: 17.6791, continent: "EU" }, // Bosnia and Herzegovina
|
|
67
|
+
BE: { country: "BE", latitude: 50.5039, longitude: 4.4699, continent: "EU" }, // Belgium
|
|
68
|
+
BG: { country: "BG", latitude: 42.7339, longitude: 25.4858, continent: "EU" }, // Bulgaria
|
|
69
|
+
BY: { country: "BY", latitude: 53.7098, longitude: 27.9534, continent: "EU" }, // Belarus
|
|
70
|
+
CH: { country: "CH", latitude: 46.8182, longitude: 8.2275, continent: "EU" }, // Switzerland
|
|
71
|
+
CY: { country: "CY", latitude: 35.1264, longitude: 33.4299, continent: "EU" }, // Cyprus
|
|
72
|
+
CZ: { country: "CZ", latitude: 49.8175, longitude: 15.4730, continent: "EU" }, // Czechia
|
|
73
|
+
DE: { country: "DE", latitude: 51.1657, longitude: 10.4515, continent: "EU" }, // Germany
|
|
74
|
+
DK: { country: "DK", latitude: 56.2639, longitude: 9.5018, continent: "EU" }, // Denmark
|
|
75
|
+
EE: { country: "EE", latitude: 58.5953, longitude: 25.0136, continent: "EU" }, // Estonia
|
|
76
|
+
ES: { country: "ES", latitude: 40.4637, longitude: -3.7492, continent: "EU" }, // Spain
|
|
77
|
+
FI: { country: "FI", latitude: 61.9241, longitude: 25.7482, continent: "EU" }, // Finland
|
|
78
|
+
FO: { country: "FO", latitude: 61.8926, longitude: -6.9118, continent: "EU" }, // Faroe Islands
|
|
79
|
+
FR: { country: "FR", latitude: 46.2276, longitude: 2.2137, continent: "EU" }, // France
|
|
80
|
+
GB: { country: "GB", latitude: 55.3781, longitude: -3.4360, continent: "EU" }, // United Kingdom
|
|
81
|
+
GG: { country: "GG", latitude: 49.4657, longitude: -2.5853, continent: "EU" }, // Guernsey
|
|
82
|
+
GI: { country: "GI", latitude: 36.1377, longitude: -5.3453, continent: "EU" }, // Gibraltar
|
|
83
|
+
GR: { country: "GR", latitude: 39.0742, longitude: 21.8243, continent: "EU" }, // Greece
|
|
84
|
+
HR: { country: "HR", latitude: 45.1000, longitude: 15.2000, continent: "EU" }, // Croatia
|
|
85
|
+
HU: { country: "HU", latitude: 47.1625, longitude: 19.5033, continent: "EU" }, // Hungary
|
|
86
|
+
IE: { country: "IE", latitude: 53.4129, longitude: -8.2439, continent: "EU" }, // Ireland
|
|
87
|
+
IM: { country: "IM", latitude: 54.2361, longitude: -4.5481, continent: "EU" }, // Isle of Man
|
|
88
|
+
IS: { country: "IS", latitude: 64.9631, longitude: -19.0208, continent: "EU" }, // Iceland
|
|
89
|
+
IT: { country: "IT", latitude: 41.8719, longitude: 12.5674, continent: "EU" }, // Italy
|
|
90
|
+
JE: { country: "JE", latitude: 49.2144, longitude: -2.1312, continent: "EU" }, // Jersey
|
|
91
|
+
LI: { country: "LI", latitude: 47.1660, longitude: 9.5554, continent: "EU" }, // Liechtenstein
|
|
92
|
+
LT: { country: "LT", latitude: 55.1694, longitude: 23.8813, continent: "EU" }, // Lithuania
|
|
93
|
+
LU: { country: "LU", latitude: 49.8153, longitude: 6.1296, continent: "EU" }, // Luxembourg
|
|
94
|
+
LV: { country: "LV", latitude: 56.8796, longitude: 24.6032, continent: "EU" }, // Latvia
|
|
95
|
+
MC: { country: "MC", latitude: 43.7384, longitude: 7.4246, continent: "EU" }, // Monaco
|
|
96
|
+
MD: { country: "MD", latitude: 47.4116, longitude: 28.3699, continent: "EU" }, // Moldova
|
|
97
|
+
ME: { country: "ME", latitude: 42.7087, longitude: 19.3744, continent: "EU" }, // Montenegro
|
|
98
|
+
MK: { country: "MK", latitude: 41.6086, longitude: 21.7453, continent: "EU" }, // North Macedonia
|
|
99
|
+
MT: { country: "MT", latitude: 35.9375, longitude: 14.3754, continent: "EU" }, // Malta
|
|
100
|
+
NL: { country: "NL", latitude: 52.1326, longitude: 5.2913, continent: "EU" }, // Netherlands
|
|
101
|
+
NO: { country: "NO", latitude: 60.4720, longitude: 8.4689, continent: "EU" }, // Norway
|
|
102
|
+
PL: { country: "PL", latitude: 51.9194, longitude: 19.1451, continent: "EU" }, // Poland
|
|
103
|
+
PT: { country: "PT", latitude: 39.3999, longitude: -8.2245, continent: "EU" }, // Portugal
|
|
104
|
+
RO: { country: "RO", latitude: 45.9432, longitude: 24.9668, continent: "EU" }, // Romania
|
|
105
|
+
RS: { country: "RS", latitude: 44.0165, longitude: 21.0059, continent: "EU" }, // Serbia
|
|
106
|
+
RU: { country: "RU", latitude: 61.5240, longitude: 105.3188, continent: "EU" }, // Russia
|
|
107
|
+
SE: { country: "SE", latitude: 60.1282, longitude: 18.6435, continent: "EU" }, // Sweden
|
|
108
|
+
SI: { country: "SI", latitude: 46.1512, longitude: 14.9955, continent: "EU" }, // Slovenia
|
|
109
|
+
SJ: { country: "SJ", latitude: 77.5536, longitude: 23.6703, continent: "EU" }, // Svalbard and Jan Mayen
|
|
110
|
+
SK: { country: "SK", latitude: 48.6690, longitude: 19.6990, continent: "EU" }, // Slovakia
|
|
111
|
+
SM: { country: "SM", latitude: 43.9424, longitude: 12.4578, continent: "EU" }, // San Marino
|
|
112
|
+
UA: { country: "UA", latitude: 48.3794, longitude: 31.1656, continent: "EU" }, // Ukraine
|
|
113
|
+
VA: { country: "VA", latitude: 41.9029, longitude: 12.4534, continent: "EU" }, // Vatican City
|
|
114
|
+
|
|
115
|
+
// Asia
|
|
116
|
+
AE: { country: "AE", latitude: 23.4241, longitude: 53.8478, continent: "AS" }, // United Arab Emirates
|
|
117
|
+
AF: { country: "AF", latitude: 33.9391, longitude: 67.7100, continent: "AS" }, // Afghanistan
|
|
118
|
+
AM: { country: "AM", latitude: 40.0691, longitude: 45.0382, continent: "AS" }, // Armenia
|
|
119
|
+
AZ: { country: "AZ", latitude: 40.1431, longitude: 47.5769, continent: "AS" }, // Azerbaijan
|
|
120
|
+
BD: { country: "BD", latitude: 23.6850, longitude: 90.3563, continent: "AS" }, // Bangladesh
|
|
121
|
+
BH: { country: "BH", latitude: 26.0667, longitude: 50.5577, continent: "AS" }, // Bahrain
|
|
122
|
+
BN: { country: "BN", latitude: 4.5353, longitude: 114.7277, continent: "AS" }, // Brunei
|
|
123
|
+
BT: { country: "BT", latitude: 27.5142, longitude: 90.4336, continent: "AS" }, // Bhutan
|
|
124
|
+
CN: { country: "CN", latitude: 35.8617, longitude: 104.1954, continent: "AS" }, // China
|
|
125
|
+
GE: { country: "GE", latitude: 42.3154, longitude: 43.3569, continent: "AS" }, // Georgia
|
|
126
|
+
HK: { country: "HK", latitude: 22.3193, longitude: 114.1694, continent: "AS" }, // Hong Kong
|
|
127
|
+
ID: { country: "ID", latitude: -0.7893, longitude: 113.9213, continent: "AS" }, // Indonesia
|
|
128
|
+
IL: { country: "IL", latitude: 31.0461, longitude: 34.8516, continent: "AS" }, // Israel
|
|
129
|
+
IN: { country: "IN", latitude: 20.5937, longitude: 78.9629, continent: "AS" }, // India
|
|
130
|
+
IQ: { country: "IQ", latitude: 33.2232, longitude: 43.6793, continent: "AS" }, // Iraq
|
|
131
|
+
IR: { country: "IR", latitude: 32.4279, longitude: 53.6880, continent: "AS" }, // Iran
|
|
132
|
+
JO: { country: "JO", latitude: 30.5852, longitude: 36.2384, continent: "AS" }, // Jordan
|
|
133
|
+
JP: { country: "JP", latitude: 36.2048, longitude: 138.2529, continent: "AS" }, // Japan
|
|
134
|
+
KG: { country: "KG", latitude: 41.2044, longitude: 74.7661, continent: "AS" }, // Kyrgyzstan
|
|
135
|
+
KH: { country: "KH", latitude: 12.5657, longitude: 104.9910, continent: "AS" }, // Cambodia
|
|
136
|
+
KP: { country: "KP", latitude: 40.3399, longitude: 127.5101, continent: "AS" }, // North Korea
|
|
137
|
+
KR: { country: "KR", latitude: 35.9078, longitude: 127.7669, continent: "AS" }, // South Korea
|
|
138
|
+
KW: { country: "KW", latitude: 29.3117, longitude: 47.4818, continent: "AS" }, // Kuwait
|
|
139
|
+
KZ: { country: "KZ", latitude: 48.0196, longitude: 66.9237, continent: "AS" }, // Kazakhstan
|
|
140
|
+
LA: { country: "LA", latitude: 19.8563, longitude: 102.4955, continent: "AS" }, // Laos
|
|
141
|
+
LB: { country: "LB", latitude: 33.8547, longitude: 35.8623, continent: "AS" }, // Lebanon
|
|
142
|
+
LK: { country: "LK", latitude: 7.8731, longitude: 80.7718, continent: "AS" }, // Sri Lanka
|
|
143
|
+
MM: { country: "MM", latitude: 21.9162, longitude: 95.9560, continent: "AS" }, // Myanmar (Burma)
|
|
144
|
+
MN: { country: "MN", latitude: 46.8625, longitude: 103.8467, continent: "AS" }, // Mongolia
|
|
145
|
+
MO: { country: "MO", latitude: 22.1987, longitude: 113.5439, continent: "AS" }, // Macao
|
|
146
|
+
MV: { country: "MV", latitude: 3.2028, longitude: 73.2207, continent: "AS" }, // Maldives
|
|
147
|
+
MY: { country: "MY", latitude: 4.2105, longitude: 101.9758, continent: "AS" }, // Malaysia
|
|
148
|
+
NP: { country: "NP", latitude: 28.3949, longitude: 84.1240, continent: "AS" }, // Nepal
|
|
149
|
+
OM: { country: "OM", latitude: 21.5126, longitude: 55.9233, continent: "AS" }, // Oman
|
|
150
|
+
PH: { country: "PH", latitude: 12.8797, longitude: 121.7740, continent: "AS" }, // Philippines
|
|
151
|
+
PK: { country: "PK", latitude: 30.3753, longitude: 69.3451, continent: "AS" }, // Pakistan
|
|
152
|
+
PS: { country: "PS", latitude: 31.9522, longitude: 35.2332, continent: "AS" }, // Palestine
|
|
153
|
+
QA: { country: "QA", latitude: 25.3548, longitude: 51.1839, continent: "AS" }, // Qatar
|
|
154
|
+
SA: { country: "SA", latitude: 23.8859, longitude: 45.0792, continent: "AS" }, // Saudi Arabia
|
|
155
|
+
SG: { country: "SG", latitude: 1.3521, longitude: 103.8198, continent: "AS" }, // Singapore
|
|
156
|
+
SY: { country: "SY", latitude: 34.8021, longitude: 38.9968, continent: "AS" }, // Syria
|
|
157
|
+
TH: { country: "TH", latitude: 15.8700, longitude: 100.9925, continent: "AS" }, // Thailand
|
|
158
|
+
TJ: { country: "TJ", latitude: 38.8610, longitude: 71.2761, continent: "AS" }, // Tajikistan
|
|
159
|
+
TL: { country: "TL", latitude: -8.8742, longitude: 125.7275, continent: "AS" }, // Timor-Leste
|
|
160
|
+
TM: { country: "TM", latitude: 38.9697, longitude: 59.5563, continent: "AS" }, // Turkmenistan
|
|
161
|
+
TR: { country: "TR", latitude: 38.9637, longitude: 35.2433, continent: "AS" }, // Turkey
|
|
162
|
+
TW: { country: "TW", latitude: 23.6978, longitude: 120.9605, continent: "AS" }, // Taiwan
|
|
163
|
+
UZ: { country: "UZ", latitude: 41.3775, longitude: 64.5853, continent: "AS" }, // Uzbekistan
|
|
164
|
+
VN: { country: "VN", latitude: 14.0583, longitude: 108.2772, continent: "AS" }, // Vietnam
|
|
165
|
+
YE: { country: "YE", latitude: 15.5527, longitude: 48.5164, continent: "AS" }, // Yemen
|
|
166
|
+
|
|
167
|
+
// Africa
|
|
168
|
+
AO: { country: "AO", latitude: -11.2027, longitude: 17.8739, continent: "AF" }, // Angola
|
|
169
|
+
BF: { country: "BF", latitude: 12.2383, longitude: -1.5616, continent: "AF" }, // Burkina Faso
|
|
170
|
+
BI: { country: "BI", latitude: -3.3731, longitude: 29.9189, continent: "AF" }, // Burundi
|
|
171
|
+
BJ: { country: "BJ", latitude: 9.3077, longitude: 2.3158, continent: "AF" }, // Benin
|
|
172
|
+
BW: { country: "BW", latitude: -22.3285, longitude: 24.6849, continent: "AF" }, // Botswana
|
|
173
|
+
CD: { country: "CD", latitude: -4.0383, longitude: 21.7587, continent: "AF" }, // Democratic Republic of the Congo
|
|
174
|
+
CF: { country: "CF", latitude: 6.6111, longitude: 20.9394, continent: "AF" }, // Central African Republic
|
|
175
|
+
CG: { country: "CG", latitude: -0.2280, longitude: 15.8277, continent: "AF" }, // Republic of the Congo
|
|
176
|
+
CI: { country: "CI", latitude: 7.5400, longitude: -5.5471, continent: "AF" }, // Côte d'Ivoire
|
|
177
|
+
CM: { country: "CM", latitude: 7.3697, longitude: 12.3547, continent: "AF" }, // Cameroon
|
|
178
|
+
CV: { country: "CV", latitude: 16.0022, longitude: -24.0132, continent: "AF" }, // Cape Verde
|
|
179
|
+
DJ: { country: "DJ", latitude: 11.8251, longitude: 42.5903, continent: "AF" }, // Djibouti
|
|
180
|
+
DZ: { country: "DZ", latitude: 28.0339, longitude: 1.6596, continent: "AF" }, // Algeria
|
|
181
|
+
EG: { country: "EG", latitude: 26.8206, longitude: 30.8025, continent: "AF" }, // Egypt
|
|
182
|
+
EH: { country: "EH", latitude: 24.2155, longitude: -12.8858, continent: "AF" }, // Western Sahara
|
|
183
|
+
ER: { country: "ER", latitude: 15.1794, longitude: 39.7823, continent: "AF" }, // Eritrea
|
|
184
|
+
ET: { country: "ET", latitude: 9.1450, longitude: 40.4897, continent: "AF" }, // Ethiopia
|
|
185
|
+
GA: { country: "GA", latitude: -0.8037, longitude: 11.6094, continent: "AF" }, // Gabon
|
|
186
|
+
GH: { country: "GH", latitude: 7.9465, longitude: -1.0232, continent: "AF" }, // Ghana
|
|
187
|
+
GM: { country: "GM", latitude: 13.4432, longitude: -15.3101, continent: "AF" }, // Gambia
|
|
188
|
+
GN: { country: "GN", latitude: 9.9456, longitude: -9.6966, continent: "AF" }, // Guinea
|
|
189
|
+
GQ: { country: "GQ", latitude: 1.6508, longitude: 10.2679, continent: "AF" }, // Equatorial Guinea
|
|
190
|
+
GW: { country: "GW", latitude: 11.8037, longitude: -15.1804, continent: "AF" }, // Guinea-Bissau
|
|
191
|
+
KE: { country: "KE", latitude: -0.0236, longitude: 37.9062, continent: "AF" }, // Kenya
|
|
192
|
+
KM: { country: "KM", latitude: -11.8750, longitude: 43.8722, continent: "AF" }, // Comoros
|
|
193
|
+
LR: { country: "LR", latitude: 6.4281, longitude: -9.4295, continent: "AF" }, // Liberia
|
|
194
|
+
LS: { country: "LS", latitude: -29.6100, longitude: 28.2336, continent: "AF" }, // Lesotho
|
|
195
|
+
LY: { country: "LY", latitude: 26.3351, longitude: 17.2283, continent: "AF" }, // Libya
|
|
196
|
+
MA: { country: "MA", latitude: 31.7917, longitude: -7.0926, continent: "AF" }, // Morocco
|
|
197
|
+
MG: { country: "MG", latitude: -18.7669, longitude: 46.8691, continent: "AF" }, // Madagascar
|
|
198
|
+
ML: { country: "ML", latitude: 17.5707, longitude: -3.9962, continent: "AF" }, // Mali
|
|
199
|
+
MR: { country: "MR", latitude: 21.0079, longitude: -10.9408, continent: "AF" }, // Mauritania
|
|
200
|
+
MU: { country: "MU", latitude: -20.3484, longitude: 57.5522, continent: "AF" }, // Mauritius
|
|
201
|
+
MW: { country: "MW", latitude: -13.2543, longitude: 34.3015, continent: "AF" }, // Malawi
|
|
202
|
+
MZ: { country: "MZ", latitude: -18.6657, longitude: 35.5296, continent: "AF" }, // Mozambique
|
|
203
|
+
NA: { country: "NA", latitude: -22.9576, longitude: 18.4904, continent: "AF" }, // Namibia
|
|
204
|
+
NE: { country: "NE", latitude: 17.6078, longitude: 8.0817, continent: "AF" }, // Niger
|
|
205
|
+
NG: { country: "NG", latitude: 9.0820, longitude: 8.6753, continent: "AF" }, // Nigeria
|
|
206
|
+
RE: { country: "RE", latitude: -21.1151, longitude: 55.5364, continent: "AF" }, // Réunion
|
|
207
|
+
RW: { country: "RW", latitude: -1.9403, longitude: 29.8739, continent: "AF" }, // Rwanda
|
|
208
|
+
SC: { country: "SC", latitude: -4.6796, longitude: 55.4920, continent: "AF" }, // Seychelles
|
|
209
|
+
SD: { country: "SD", latitude: 12.8628, longitude: 30.2176, continent: "AF" }, // Sudan
|
|
210
|
+
SL: { country: "SL", latitude: 8.4606, longitude: -11.7799, continent: "AF" }, // Sierra Leone
|
|
211
|
+
SN: { country: "SN", latitude: 14.4974, longitude: -14.4524, continent: "AF" }, // Senegal
|
|
212
|
+
SO: { country: "SO", latitude: 5.1521, longitude: 46.1996, continent: "AF" }, // Somalia
|
|
213
|
+
SS: { country: "SS", latitude: 6.8770, longitude: 31.3070, continent: "AF" }, // South Sudan
|
|
214
|
+
ST: { country: "ST", latitude: 0.1864, longitude: 6.6131, continent: "AF" }, // São Tomé and Príncipe
|
|
215
|
+
SZ: { country: "SZ", latitude: -26.5225, longitude: 31.4659, continent: "AF" }, // Eswatini
|
|
216
|
+
TD: { country: "TD", latitude: 15.4542, longitude: 18.7322, continent: "AF" }, // Chad
|
|
217
|
+
TG: { country: "TG", latitude: 8.6195, longitude: 0.8248, continent: "AF" }, // Togo
|
|
218
|
+
TN: { country: "TN", latitude: 33.8869, longitude: 9.5375, continent: "AF" }, // Tunisia
|
|
219
|
+
TZ: { country: "TZ", latitude: -6.3690, longitude: 34.8888, continent: "AF" }, // Tanzania
|
|
220
|
+
UG: { country: "UG", latitude: 1.3733, longitude: 32.2903, continent: "AF" }, // Uganda
|
|
221
|
+
YT: { country: "YT", latitude: -12.8275, longitude: 45.1662, continent: "AF" }, // Mayotte
|
|
222
|
+
ZA: { country: "ZA", latitude: -30.5595, longitude: 22.9375, continent: "AF" }, // South Africa
|
|
223
|
+
ZM: { country: "ZM", latitude: -13.1339, longitude: 27.8493, continent: "AF" }, // Zambia
|
|
224
|
+
ZW: { country: "ZW", latitude: -19.0154, longitude: 29.1549, continent: "AF" }, // Zimbabwe
|
|
225
|
+
|
|
226
|
+
// Oceania
|
|
227
|
+
AS: { country: "AS", latitude: -14.2710, longitude: -170.1322, continent: "OC" }, // American Samoa
|
|
228
|
+
AU: { country: "AU", latitude: -25.2744, longitude: 133.7751, continent: "OC" }, // Australia
|
|
229
|
+
CK: { country: "CK", latitude: -21.2367, longitude: -159.7777, continent: "OC" }, // Cook Islands
|
|
230
|
+
CX: { country: "CX", latitude: -10.4475, longitude: 105.6904, continent: "OC" }, // Christmas Island
|
|
231
|
+
FJ: { country: "FJ", latitude: -17.7134, longitude: 178.0650, continent: "OC" }, // Fiji
|
|
232
|
+
FM: { country: "FM", latitude: 7.4256, longitude: 150.5508, continent: "OC" }, // Micronesia
|
|
233
|
+
GU: { country: "GU", latitude: 13.4443, longitude: 144.7937, continent: "OC" }, // Guam
|
|
234
|
+
KI: { country: "KI", latitude: -3.3704, longitude: -168.7340, continent: "OC" }, // Kiribati
|
|
235
|
+
MH: { country: "MH", latitude: 7.1315, longitude: 171.1845, continent: "OC" }, // Marshall Islands
|
|
236
|
+
MP: { country: "MP", latitude: 17.3308, longitude: 145.3847, continent: "OC" }, // Northern Mariana Islands
|
|
237
|
+
NC: { country: "NC", latitude: -20.9043, longitude: 165.6180, continent: "OC" }, // New Caledonia
|
|
238
|
+
NF: { country: "NF", latitude: -29.0408, longitude: 167.9547, continent: "OC" }, // Norfolk Island
|
|
239
|
+
NR: { country: "NR", latitude: -0.5228, longitude: 166.9315, continent: "OC" }, // Nauru
|
|
240
|
+
NU: { country: "NU", latitude: -19.0544, longitude: -169.8672, continent: "OC" }, // Niue
|
|
241
|
+
NZ: { country: "NZ", latitude: -40.9006, longitude: 174.8860, continent: "OC" }, // New Zealand
|
|
242
|
+
PF: { country: "PF", latitude: -17.6797, longitude: -149.4068, continent: "OC" }, // French Polynesia
|
|
243
|
+
PG: { country: "PG", latitude: -6.314993, longitude: 143.95555, continent: "OC" }, // Papua New Guinea
|
|
244
|
+
PN: { country: "PN", latitude: -24.7036, longitude: -127.4393, continent: "OC" }, // Pitcairn Islands
|
|
245
|
+
PW: { country: "PW", latitude: 7.5150, longitude: 134.5825, continent: "OC" }, // Palau
|
|
246
|
+
SB: { country: "SB", latitude: -9.6457, longitude: 160.1562, continent: "OC" }, // Solomon Islands
|
|
247
|
+
TK: { country: "TK", latitude: -8.9673, longitude: -171.8559, continent: "OC" }, // Tokelau
|
|
248
|
+
TO: { country: "TO", latitude: -21.1789, longitude: -175.1982, continent: "OC" }, // Tonga
|
|
249
|
+
TV: { country: "TV", latitude: -7.1095, longitude: 177.6493, continent: "OC" }, // Tuvalu
|
|
250
|
+
VU: { country: "VU", latitude: -15.3767, longitude: 166.9592, continent: "OC" }, // Vanuatu
|
|
251
|
+
WF: { country: "WF", latitude: -13.7687, longitude: -177.1561, continent: "OC" }, // Wallis and Futuna
|
|
252
|
+
WS: { country: "WS", latitude: -13.7590, longitude: -172.1046, continent: "OC" }, // Samoa
|
|
253
|
+
|
|
254
|
+
// Antarctica & Remote Islands
|
|
255
|
+
AQ: { country: "AQ", latitude: -75.2509, longitude: -0.0713, continent: "AN" }, // Antarctica
|
|
256
|
+
BV: { country: "BV", latitude: -54.4208, longitude: 3.3464, continent: "AN" }, // Bouvet Island
|
|
257
|
+
CC: { country: "CC", latitude: -12.1642, longitude: 96.8710, continent: "AS" }, // Cocos (Keeling) Islands
|
|
258
|
+
GS: { country: "GS", latitude: -54.4296, longitude: -36.5879, continent: "AN" }, // South Georgia
|
|
259
|
+
HM: { country: "HM", latitude: -53.0818, longitude: 73.5042, continent: "AN" }, // Heard Island and McDonald Islands
|
|
260
|
+
IO: { country: "IO", latitude: -6.3432, longitude: 71.8765, continent: "AS" }, // British Indian Ocean Territory
|
|
261
|
+
TF: { country: "TF", latitude: -49.2804, longitude: 69.3485, continent: "AN" }, // French Southern Territories
|
|
262
|
+
UM: { country: "UM", latitude: 19.2823, longitude: 166.6470, continent: "OC" }, // U.S. Outlying Islands
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Helper function to retrieve country location object (country code, latitude, longitude, continent)
|
|
267
|
+
* by ISO 2-letter country code. Case-insensitive lookup.
|
|
268
|
+
*
|
|
269
|
+
* @param {string} countryCode - ISO 3166-1 alpha-2 code (e.g. "US", "de", "JP")
|
|
270
|
+
* @returns {{country: string, latitude: number, longitude: number, continent: string}|null} Location object or null
|
|
271
|
+
*/
|
|
272
|
+
export function getCountryLocation(countryCode) {
|
|
273
|
+
if (!countryCode) return null;
|
|
274
|
+
const cleanCode = String(countryCode).trim().toUpperCase();
|
|
275
|
+
return COUNTRY_LOCATIONS[cleanCode] || null;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export default getCountryLocation;
|
package/src/index.js
CHANGED
|
@@ -16,9 +16,13 @@
|
|
|
16
16
|
*
|
|
17
17
|
********************************************************************************/
|
|
18
18
|
|
|
19
|
+
export { cloudProviders } from "./cloudProviders.js";
|
|
20
|
+
export { getClientInfo } from "./getClientInfo.js";
|
|
19
21
|
export { getRelativePath } from "./getRelativePath.js";
|
|
22
|
+
export { getClockOffset } from "./getClockOffset.js";
|
|
20
23
|
export { ObjectId } from "./ObjectId.js";
|
|
21
|
-
export {
|
|
24
|
+
export { uuid } from "./uuid.js";
|
|
25
|
+
export { ulid, ulidDecode } from "./ulid.js";
|
|
22
26
|
export { checkValue } from "./checkValue.js";
|
|
23
27
|
export { isValidDate } from "./isValidDate.js";
|
|
24
28
|
export { objectToSearchParams } from "./objectToSearchParams.js";
|
|
@@ -31,14 +35,18 @@ export { parseTextToHtml } from "./parseTextToHtml.js";
|
|
|
31
35
|
export { escapeHtml } from "./escapeHtml.js";
|
|
32
36
|
export { cssPath } from "./cssPath.js";
|
|
33
37
|
export { queryElements, checkMediaQueries } from "./queryElements.js";
|
|
34
|
-
export { queryData, searchData, sortData } from "./dataQuery.js";
|
|
38
|
+
export { queryData, searchData, sortData, isEqualArray, isEqualObject } from "./dataQuery.js";
|
|
35
39
|
export { getAttributes, getAttributeNames, setAttributeNames } from "./attributes.js";
|
|
36
40
|
export { clickedElement } from "./clickedElement.js";
|
|
37
|
-
export {
|
|
41
|
+
export { astSync, astAsync } from "./ast/index.js";
|
|
38
42
|
|
|
43
|
+
import { cloudProviders } from "./cloudProviders.js";
|
|
44
|
+
import { getClientInfo } from "./getClientInfo.js";
|
|
39
45
|
import { getRelativePath } from "./getRelativePath.js";
|
|
46
|
+
import { getClockOffset } from "./getClockOffset.js";
|
|
40
47
|
import { ObjectId } from "./ObjectId.js";
|
|
41
|
-
import {
|
|
48
|
+
import { uuid } from "./uuid.js";
|
|
49
|
+
import { ulid, ulidDecode } from "./ulid.js";
|
|
42
50
|
import { checkValue } from "./checkValue.js";
|
|
43
51
|
import { isValidDate } from "./isValidDate.js";
|
|
44
52
|
import { objectToSearchParams } from "./objectToSearchParams.js";
|
|
@@ -51,40 +59,44 @@ import { parseTextToHtml } from "./parseTextToHtml.js";
|
|
|
51
59
|
import { escapeHtml } from "./escapeHtml.js";
|
|
52
60
|
import { cssPath } from "./cssPath.js";
|
|
53
61
|
import { queryElements, checkMediaQueries } from "./queryElements.js";
|
|
54
|
-
import { queryData, searchData, sortData } from "./dataQuery.js";
|
|
62
|
+
import { queryData, searchData, sortData, isEqualArray, isEqualObject } from "./dataQuery.js";
|
|
55
63
|
import { getAttributes, getAttributeNames, setAttributeNames } from "./attributes.js";
|
|
56
64
|
import { clickedElement } from "./clickedElement.js";
|
|
57
|
-
import {
|
|
65
|
+
import { astSync, astAsync } from "./ast/index.js";
|
|
58
66
|
|
|
59
67
|
const utils = {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
68
|
+
cloudProviders,
|
|
69
|
+
getClientInfo,
|
|
70
|
+
getRelativePath,
|
|
71
|
+
getClockOffset,
|
|
72
|
+
ObjectId,
|
|
73
|
+
uuid,
|
|
74
|
+
ulid,
|
|
75
|
+
ulidDecode,
|
|
76
|
+
checkValue,
|
|
77
|
+
isValidDate,
|
|
78
|
+
dotNotationToObject,
|
|
79
|
+
objectToDotNotation,
|
|
80
|
+
getValueFromObject,
|
|
81
|
+
objectToSearchParams,
|
|
82
|
+
domParser,
|
|
83
|
+
parseTextToHtml,
|
|
84
|
+
escapeHtml,
|
|
85
|
+
cssPath,
|
|
86
|
+
queryElements,
|
|
87
|
+
checkMediaQueries,
|
|
88
|
+
queryData,
|
|
89
|
+
searchData,
|
|
90
|
+
sortData,
|
|
91
|
+
isEqualArray,
|
|
92
|
+
isEqualObject,
|
|
93
|
+
createUpdate,
|
|
94
|
+
getAttributes,
|
|
95
|
+
setAttributeNames,
|
|
96
|
+
getAttributeNames,
|
|
97
|
+
clickedElement,
|
|
98
|
+
astSync,
|
|
99
|
+
astAsync
|
|
88
100
|
};
|
|
89
101
|
|
|
90
|
-
export default utils;
|
|
102
|
+
export default utils;
|
package/src/ulid.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (C) 2026 CoCreate and Contributors.
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify
|
|
5
|
+
* it under the terms of the GNU Affero General Public License as published
|
|
6
|
+
* by the Free Software Foundation, either version 3 of the License, or
|
|
7
|
+
* (at your option) any later version.
|
|
8
|
+
*
|
|
9
|
+
* This program is distributed in the hope that it will be useful,
|
|
10
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
* GNU Affero General Public License for more details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
*
|
|
17
|
+
********************************************************************************/
|
|
18
|
+
|
|
19
|
+
import { getClockOffset } from "./getClockOffset.js";
|
|
20
|
+
|
|
21
|
+
const ENCODING = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
|
|
22
|
+
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
23
|
+
|
|
24
|
+
function encodeTime(now, len) {
|
|
25
|
+
let str = '';
|
|
26
|
+
for (let i = len; i > 0; i--) {
|
|
27
|
+
str = ENCODING[now % 32] + str;
|
|
28
|
+
now = Math.floor(now / 32);
|
|
29
|
+
}
|
|
30
|
+
return str;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function encodeRandom(len) {
|
|
34
|
+
let str = '';
|
|
35
|
+
const bytes = new Uint8Array(len);
|
|
36
|
+
const cryptoObj = isBrowser ? (window.crypto || window.msCrypto) : globalThis.crypto;
|
|
37
|
+
cryptoObj.getRandomValues(bytes);
|
|
38
|
+
|
|
39
|
+
for (let i = 0; i < len; i++) {
|
|
40
|
+
str += ENCODING[bytes[i] % 32];
|
|
41
|
+
}
|
|
42
|
+
return str;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function ulid() {
|
|
46
|
+
const now = Date.now() + getClockOffset();
|
|
47
|
+
return encodeTime(now, 10) + encodeRandom(16);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Decodes the timestamp from a ULID string.
|
|
52
|
+
*
|
|
53
|
+
* @param {string} ulidStr - The 26-character ULID string.
|
|
54
|
+
* @returns {number} The extracted Unix timestamp in milliseconds.
|
|
55
|
+
*/
|
|
56
|
+
export function ulidDecode(ulidStr) {
|
|
57
|
+
if (ulidStr.length !== 26) throw new Error("Invalid ULID length");
|
|
58
|
+
|
|
59
|
+
const ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
60
|
+
const timeChars = ulidStr.substring(0, 10).toUpperCase();
|
|
61
|
+
|
|
62
|
+
let time = 0;
|
|
63
|
+
for (let i = 0; i < 10; i++) {
|
|
64
|
+
const charValue = ENCODING.indexOf(timeChars[i]);
|
|
65
|
+
if (charValue === -1) throw new Error("Invalid ULID character");
|
|
66
|
+
time = (time * 32) + charValue;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return time;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default ulid;
|
package/src/uuid.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (C) 2026 CoCreate and Contributors.
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify
|
|
5
|
+
* it under the terms of the GNU Affero General Public License as published
|
|
6
|
+
* by the Free Software Foundation, either version 3 of the License, or
|
|
7
|
+
* (at your option) any later version.
|
|
8
|
+
*
|
|
9
|
+
* This program is distributed in the hope that it will be useful,
|
|
10
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
* GNU Affero General Public License for more details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
*
|
|
17
|
+
********************************************************************************/
|
|
18
|
+
|
|
19
|
+
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Generates an RFC 4122 compliant UUID Version 4 (Universally Unique Identifier).
|
|
23
|
+
*
|
|
24
|
+
* By default, this returns a standard 36-character string. If a custom length
|
|
25
|
+
* less than 36 is provided, it returns a truncated unique identifier (UID).
|
|
26
|
+
*
|
|
27
|
+
* @param {number} [length=36] - The desired length of the returned identifier (maximum 36).
|
|
28
|
+
* @returns {string} A standard UUIDv4 or a truncated custom-length unique identifier.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* // Returns standard UUIDv4: "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"
|
|
32
|
+
* uuid();
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Returns truncated unique identifier: "f81d4fae"
|
|
36
|
+
* uuid(8);
|
|
37
|
+
*/
|
|
38
|
+
export function uuid(length = 36) {
|
|
39
|
+
const pattern = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";
|
|
40
|
+
|
|
41
|
+
// Cap the length to the maximum standard UUID size (36 characters)
|
|
42
|
+
const targetLength = Math.min(length, 36);
|
|
43
|
+
|
|
44
|
+
// Cryptographically secure random byte generation across Browser and Node environments
|
|
45
|
+
const randomBytes = new Uint8Array(36);
|
|
46
|
+
const cryptoObj = isBrowser ? (window.crypto || window.msCrypto) : globalThis.crypto;
|
|
47
|
+
|
|
48
|
+
if (cryptoObj && cryptoObj.getRandomValues) {
|
|
49
|
+
cryptoObj.getRandomValues(randomBytes);
|
|
50
|
+
} else {
|
|
51
|
+
// Fallback if environment crypto API is unavailable
|
|
52
|
+
for (let i = 0; i < 36; i++) {
|
|
53
|
+
randomBytes[i] = Math.floor(Math.random() * 256);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
let byteIndex = 0;
|
|
58
|
+
const fullUuid = pattern.replace(/[xy]/g, (char) => {
|
|
59
|
+
const randomValue = randomBytes[byteIndex++] % 16;
|
|
60
|
+
const mappedValue = char === "x" ? randomValue : (randomValue & 0x3) | 0x8;
|
|
61
|
+
return mappedValue.toString(16);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return fullUuid.substring(0, targetLength);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export default uuid;
|
package/src/core.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { getRelativePath } from "./getRelativePath.js";
|
|
2
|
-
export { ObjectId } from "./ObjectId.js";
|
|
3
|
-
export { uid } from "./uid.js";
|
|
4
|
-
export { checkValue } from "./checkValue.js";
|
|
5
|
-
export { isValidDate } from "./isValidDate.js";
|
|
6
|
-
export { objectToSearchParams } from "./objectToSearchParams.js";
|