corebasic 1.0.225 → 1.0.227
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/libs/mobilecodes.js +5 -4
- package/dist/libs/utils.js +102 -44
- package/libs/mobilecodes.ts +5 -4
- package/package.json +1 -1
package/dist/libs/mobilecodes.js
CHANGED
|
@@ -50,7 +50,8 @@ export const codes = {
|
|
|
50
50
|
label: 'Alland Islands',
|
|
51
51
|
phone: '358',
|
|
52
52
|
min: 7,
|
|
53
|
-
max: 10
|
|
53
|
+
max: 10,
|
|
54
|
+
phoneLength: [7, 8, 9, 10], // Custom added by me
|
|
54
55
|
},
|
|
55
56
|
AZ: { code: 'AZ', label: 'Azerbaijan', phone: '994', phoneLength: 9 },
|
|
56
57
|
BA: {
|
|
@@ -162,7 +163,7 @@ export const codes = {
|
|
|
162
163
|
ER: { code: 'ER', label: 'Eritrea', phone: '291', phoneLength: 7 },
|
|
163
164
|
ES: { code: 'ES', label: 'Spain', phone: '34', phoneLength: 9 },
|
|
164
165
|
ET: { code: 'ET', label: 'Ethiopia', phone: '251', phoneLength: 9 },
|
|
165
|
-
FI: { code: 'FI', label: 'Finland', phone: '358', min: 9, max: 11 },
|
|
166
|
+
FI: { code: 'FI', label: 'Finland', phone: '358', min: 9, max: 11, phoneLength: [9, 10, 11] }, // Custom added by me
|
|
166
167
|
FJ: { code: 'FJ', label: 'Fiji', phone: '679', phoneLength: 7 },
|
|
167
168
|
FK: {
|
|
168
169
|
code: 'FK',
|
|
@@ -247,7 +248,7 @@ export const codes = {
|
|
|
247
248
|
JE: { code: 'JE', label: 'Jersey', phone: '44', phoneLength: 10 },
|
|
248
249
|
JM: { code: 'JM', label: 'Jamaica', phone: '1-876', phoneLength: 10 },
|
|
249
250
|
JO: { code: 'JO', label: 'Jordan', phone: '962', phoneLength: [8, 9] },
|
|
250
|
-
JP: { code: 'JP', label: 'Japan', phone: '81', suggested: true },
|
|
251
|
+
JP: { code: 'JP', label: 'Japan', phone: '81', suggested: true, phoneLength: 11 }, // Custom added by me
|
|
251
252
|
KE: { code: 'KE', label: 'Kenya', phone: '254', phoneLength: 10 },
|
|
252
253
|
KG: { code: 'KG', label: 'Kyrgyzstan', phone: '996', phoneLength: 9 },
|
|
253
254
|
KH: { code: 'KH', label: 'Cambodia', phone: '855', phoneLength: 9 },
|
|
@@ -324,7 +325,7 @@ export const codes = {
|
|
|
324
325
|
phoneLength: 8
|
|
325
326
|
},
|
|
326
327
|
ML: { code: 'ML', label: 'Mali', phone: '223', phoneLength: 8 },
|
|
327
|
-
MM: { code: 'MM', label: 'Myanmar', phone: '95', min: 7, max: 10 },
|
|
328
|
+
MM: { code: 'MM', label: 'Myanmar', phone: '95', min: 7, max: 10, phoneLength: [7, 8, 9, 10] }, // Custom added by me
|
|
328
329
|
MN: { code: 'MN', label: 'Mongolia', phone: '976', phoneLength: 8 },
|
|
329
330
|
MO: { code: 'MO', label: 'Macao', phone: '853', phoneLength: 8 },
|
|
330
331
|
MP: {
|
package/dist/libs/utils.js
CHANGED
|
@@ -228,59 +228,117 @@ export function validityToUTCMillisecs(start, validity) {
|
|
|
228
228
|
export async function fileToJson(path, file) {
|
|
229
229
|
let data = (await readFile(new URL(file, path).toString().replace('file://', ''), 'utf8'));
|
|
230
230
|
// return JSON.parse((JSON as Record<string, any>).minify(data))
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
231
|
+
// import stripJsonComments from "strip-json-comments";
|
|
232
|
+
// ====================================================
|
|
233
|
+
const singleComment = Symbol('singleComment');
|
|
234
|
+
const multiComment = Symbol('multiComment');
|
|
235
|
+
const stripWithoutWhitespace = () => '';
|
|
236
|
+
// Replace all characters except ASCII spaces, tabs and line endings with regular spaces to ensure valid JSON output.
|
|
237
|
+
const stripWithWhitespace = (string, start, end) => string.slice(start, end).replace(/[^ \t\r\n]/g, ' ');
|
|
238
|
+
const isEscaped = (jsonString, quotePosition) => {
|
|
239
|
+
let index = quotePosition - 1;
|
|
240
|
+
let backslashCount = 0;
|
|
241
|
+
while (jsonString[index] === '\\') {
|
|
242
|
+
index -= 1;
|
|
243
|
+
backslashCount += 1;
|
|
244
|
+
}
|
|
245
|
+
return Boolean(backslashCount % 2);
|
|
246
|
+
};
|
|
247
|
+
function stripJsonComments(jsonString, { whitespace = true, trailingCommas = false } = {}) {
|
|
248
|
+
if (typeof jsonString !== 'string') {
|
|
249
|
+
throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof jsonString}\``);
|
|
250
|
+
}
|
|
251
|
+
const strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace;
|
|
252
|
+
let isInsideString = false;
|
|
253
|
+
let isInsideComment = false;
|
|
254
|
+
// let isInsideComment = false;
|
|
255
|
+
let offset = 0;
|
|
256
|
+
let buffer = '';
|
|
257
|
+
let result = '';
|
|
258
|
+
let commaIndex = -1;
|
|
259
|
+
for (let index = 0; index < jsonString.length; index++) {
|
|
260
|
+
const currentCharacter = jsonString[index];
|
|
261
|
+
const nextCharacter = jsonString[index + 1];
|
|
262
|
+
if (!isInsideComment && currentCharacter === '"') {
|
|
263
|
+
// Enter or exit string
|
|
264
|
+
const escaped = isEscaped(jsonString, index);
|
|
265
|
+
if (!escaped) {
|
|
266
|
+
isInsideString = !isInsideString;
|
|
241
267
|
}
|
|
242
|
-
new_str[ns++] = tmp2;
|
|
243
268
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
// found a " character, and we're not currently in
|
|
247
|
-
// a comment? check for previous `\` escaping immediately
|
|
248
|
-
// leftward adjacent to this match
|
|
249
|
-
if (tmp[0] === "\"" && !in_multiline_comment && !in_singleline_comment) {
|
|
250
|
-
// limit left-context matching to only go back
|
|
251
|
-
// to the position of the last token match
|
|
252
|
-
//
|
|
253
|
-
// see: https://github.com/getify/JSON.minify/issues/64
|
|
254
|
-
lc.lastIndex = prevFrom;
|
|
255
|
-
// perform leftward adjacent escaping match
|
|
256
|
-
tmp2 = lc.match(/(\\)*$/);
|
|
257
|
-
// start of string with ", or unescaped " character found to end string?
|
|
258
|
-
if (!in_string || !tmp2 || (tmp2[0].length % 2) === 0) {
|
|
259
|
-
in_string = !in_string;
|
|
260
|
-
}
|
|
261
|
-
from--; // include " character in next catch
|
|
262
|
-
rc = json.substring(from);
|
|
269
|
+
if (isInsideString) {
|
|
270
|
+
continue;
|
|
263
271
|
}
|
|
264
|
-
|
|
265
|
-
|
|
272
|
+
if (!isInsideComment && currentCharacter + nextCharacter === '//') {
|
|
273
|
+
// Enter single-line comment
|
|
274
|
+
buffer += jsonString.slice(offset, index);
|
|
275
|
+
offset = index;
|
|
276
|
+
isInsideComment = singleComment;
|
|
277
|
+
index++;
|
|
266
278
|
}
|
|
267
|
-
else if (
|
|
268
|
-
|
|
279
|
+
else if (isInsideComment === singleComment && currentCharacter + nextCharacter === '\r\n') {
|
|
280
|
+
// Exit single-line comment via \r\n
|
|
281
|
+
index++;
|
|
282
|
+
isInsideComment = false;
|
|
283
|
+
buffer += strip(jsonString, offset, index);
|
|
284
|
+
offset = index;
|
|
285
|
+
continue;
|
|
269
286
|
}
|
|
270
|
-
else if (
|
|
271
|
-
|
|
287
|
+
else if (isInsideComment === singleComment && currentCharacter === '\n') {
|
|
288
|
+
// Exit single-line comment via \n
|
|
289
|
+
isInsideComment = false;
|
|
290
|
+
buffer += strip(jsonString, offset, index);
|
|
291
|
+
offset = index;
|
|
272
292
|
}
|
|
273
|
-
else if (
|
|
274
|
-
|
|
293
|
+
else if (!isInsideComment && currentCharacter + nextCharacter === '/*') {
|
|
294
|
+
// Enter multiline comment
|
|
295
|
+
buffer += jsonString.slice(offset, index);
|
|
296
|
+
offset = index;
|
|
297
|
+
isInsideComment = multiComment;
|
|
298
|
+
index++;
|
|
299
|
+
continue;
|
|
275
300
|
}
|
|
276
|
-
else if (
|
|
277
|
-
|
|
301
|
+
else if (isInsideComment === multiComment && currentCharacter + nextCharacter === '*/') {
|
|
302
|
+
// Exit multiline comment
|
|
303
|
+
index++;
|
|
304
|
+
isInsideComment = false;
|
|
305
|
+
buffer += strip(jsonString, offset, index + 1);
|
|
306
|
+
offset = index + 1;
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
else if (trailingCommas && !isInsideComment) {
|
|
310
|
+
if (commaIndex !== -1) {
|
|
311
|
+
if (currentCharacter === '}' || currentCharacter === ']') {
|
|
312
|
+
// Strip trailing comma
|
|
313
|
+
buffer += jsonString.slice(offset, index);
|
|
314
|
+
result += strip(buffer, 0, 1) + buffer.slice(1);
|
|
315
|
+
buffer = '';
|
|
316
|
+
offset = index;
|
|
317
|
+
commaIndex = -1;
|
|
318
|
+
}
|
|
319
|
+
else if (currentCharacter !== ' ' && currentCharacter !== '\t' && currentCharacter !== '\r' && currentCharacter !== '\n') {
|
|
320
|
+
// Hit non-whitespace following a comma; comma is not trailing
|
|
321
|
+
buffer += jsonString.slice(offset, index);
|
|
322
|
+
offset = index;
|
|
323
|
+
commaIndex = -1;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
else if (currentCharacter === ',') {
|
|
327
|
+
// Flush buffer prior to this point, and save new comma index
|
|
328
|
+
result += buffer + jsonString.slice(offset, index);
|
|
329
|
+
buffer = '';
|
|
330
|
+
offset = index;
|
|
331
|
+
commaIndex = index;
|
|
332
|
+
}
|
|
278
333
|
}
|
|
279
334
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
335
|
+
const remaining = (isInsideComment === singleComment)
|
|
336
|
+
? strip(jsonString, offset)
|
|
337
|
+
: jsonString.slice(offset);
|
|
338
|
+
return result + buffer + remaining;
|
|
339
|
+
}
|
|
340
|
+
// ====================================================
|
|
341
|
+
return JSON.parse(stripJsonComments(data));
|
|
284
342
|
}
|
|
285
343
|
// ----------------
|
|
286
344
|
// File
|
package/libs/mobilecodes.ts
CHANGED
|
@@ -55,7 +55,8 @@ export const codes: Record<string, CountryItem> = {
|
|
|
55
55
|
label: 'Alland Islands',
|
|
56
56
|
phone: '358',
|
|
57
57
|
min: 7,
|
|
58
|
-
max: 10
|
|
58
|
+
max: 10,
|
|
59
|
+
phoneLength: [7, 8, 9, 10], // Custom added by me
|
|
59
60
|
},
|
|
60
61
|
AZ: { code: 'AZ', label: 'Azerbaijan', phone: '994', phoneLength: 9 },
|
|
61
62
|
BA: {
|
|
@@ -167,7 +168,7 @@ export const codes: Record<string, CountryItem> = {
|
|
|
167
168
|
ER: { code: 'ER', label: 'Eritrea', phone: '291', phoneLength: 7 },
|
|
168
169
|
ES: { code: 'ES', label: 'Spain', phone: '34', phoneLength: 9 },
|
|
169
170
|
ET: { code: 'ET', label: 'Ethiopia', phone: '251', phoneLength: 9 },
|
|
170
|
-
FI: { code: 'FI', label: 'Finland', phone: '358', min: 9, max: 11 },
|
|
171
|
+
FI: { code: 'FI', label: 'Finland', phone: '358', min: 9, max: 11, phoneLength: [9, 10, 11] }, // Custom added by me
|
|
171
172
|
FJ: { code: 'FJ', label: 'Fiji', phone: '679', phoneLength: 7 },
|
|
172
173
|
FK: {
|
|
173
174
|
code: 'FK',
|
|
@@ -252,7 +253,7 @@ export const codes: Record<string, CountryItem> = {
|
|
|
252
253
|
JE: { code: 'JE', label: 'Jersey', phone: '44', phoneLength: 10 },
|
|
253
254
|
JM: { code: 'JM', label: 'Jamaica', phone: '1-876', phoneLength: 10 },
|
|
254
255
|
JO: { code: 'JO', label: 'Jordan', phone: '962', phoneLength: [ 8, 9 ] },
|
|
255
|
-
JP: { code: 'JP', label: 'Japan', phone: '81', suggested: true },
|
|
256
|
+
JP: { code: 'JP', label: 'Japan', phone: '81', suggested: true, phoneLength: 11 }, // Custom added by me
|
|
256
257
|
KE: { code: 'KE', label: 'Kenya', phone: '254', phoneLength: 10 },
|
|
257
258
|
KG: { code: 'KG', label: 'Kyrgyzstan', phone: '996', phoneLength: 9 },
|
|
258
259
|
KH: { code: 'KH', label: 'Cambodia', phone: '855', phoneLength: 9 },
|
|
@@ -329,7 +330,7 @@ export const codes: Record<string, CountryItem> = {
|
|
|
329
330
|
phoneLength: 8
|
|
330
331
|
},
|
|
331
332
|
ML: { code: 'ML', label: 'Mali', phone: '223', phoneLength: 8 },
|
|
332
|
-
MM: { code: 'MM', label: 'Myanmar', phone: '95', min: 7, max: 10 },
|
|
333
|
+
MM: { code: 'MM', label: 'Myanmar', phone: '95', min: 7, max: 10, phoneLength: [7, 8, 9, 10] }, // Custom added by me
|
|
333
334
|
MN: { code: 'MN', label: 'Mongolia', phone: '976', phoneLength: 8 },
|
|
334
335
|
MO: { code: 'MO', label: 'Macao', phone: '853', phoneLength: 8 },
|
|
335
336
|
MP: {
|