@reliverse/relifso 1.4.5 → 2.2.7

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.
Files changed (92) hide show
  1. package/README.md +365 -447
  2. package/dist/copy.d.ts +3 -0
  3. package/dist/copy.js +95 -0
  4. package/dist/dir.d.ts +13 -0
  5. package/dist/dir.js +113 -0
  6. package/dist/file.d.ts +12 -0
  7. package/dist/file.js +169 -0
  8. package/dist/helpers.d.ts +3 -0
  9. package/dist/helpers.js +38 -0
  10. package/dist/internal/fs.d.ts +16 -0
  11. package/dist/internal/fs.js +32 -0
  12. package/dist/internal/path.d.ts +3 -0
  13. package/dist/internal/path.js +11 -0
  14. package/dist/links.d.ts +3 -0
  15. package/dist/links.js +74 -0
  16. package/dist/mod.d.ts +40 -0
  17. package/dist/mod.js +77 -0
  18. package/dist/types.d.ts +50 -0
  19. package/dist/types.js +0 -0
  20. package/package.json +15 -42
  21. package/LICENSE +0 -21
  22. package/LICENSES +0 -16
  23. package/bin/impl/bun.d.ts +0 -11
  24. package/bin/impl/bun.js +0 -23
  25. package/bin/impl/copy.d.ts +0 -40
  26. package/bin/impl/copy.js +0 -229
  27. package/bin/impl/create.d.ts +0 -34
  28. package/bin/impl/create.js +0 -54
  29. package/bin/impl/dive.d.ts +0 -27
  30. package/bin/impl/dive.js +0 -145
  31. package/bin/impl/empty.d.ts +0 -28
  32. package/bin/impl/empty.js +0 -75
  33. package/bin/impl/extras.d.ts +0 -35
  34. package/bin/impl/extras.js +0 -112
  35. package/bin/impl/json-utils.d.ts +0 -30
  36. package/bin/impl/json-utils.js +0 -46
  37. package/bin/impl/mkdirs.d.ts +0 -7
  38. package/bin/impl/mkdirs.js +0 -28
  39. package/bin/impl/move.d.ts +0 -28
  40. package/bin/impl/move.js +0 -140
  41. package/bin/impl/output-file.d.ts +0 -17
  42. package/bin/impl/output-file.js +0 -15
  43. package/bin/impl/output-json.d.ts +0 -21
  44. package/bin/impl/output-json.js +0 -77
  45. package/bin/impl/path-exists.d.ts +0 -2
  46. package/bin/impl/path-exists.js +0 -16
  47. package/bin/impl/read-file.d.ts +0 -31
  48. package/bin/impl/read-file.js +0 -165
  49. package/bin/impl/read-json.d.ts +0 -31
  50. package/bin/impl/read-json.js +0 -241
  51. package/bin/impl/remove.d.ts +0 -2
  52. package/bin/impl/remove.js +0 -8
  53. package/bin/impl/stats.d.ts +0 -31
  54. package/bin/impl/stats.js +0 -141
  55. package/bin/impl/write-file.d.ts +0 -31
  56. package/bin/impl/write-file.js +0 -177
  57. package/bin/impl/write-json.d.ts +0 -41
  58. package/bin/impl/write-json.js +0 -135
  59. package/bin/mod.d.ts +0 -253
  60. package/bin/mod.js +0 -514
  61. package/bin/utils/json/helpers/JSONRepairError.d.ts +0 -4
  62. package/bin/utils/json/helpers/JSONRepairError.js +0 -7
  63. package/bin/utils/json/helpers/JsonSchemaError.d.ts +0 -6
  64. package/bin/utils/json/helpers/JsonSchemaError.js +0 -6
  65. package/bin/utils/json/helpers/stringUtils.d.ts +0 -64
  66. package/bin/utils/json/helpers/stringUtils.js +0 -87
  67. package/bin/utils/json/regular/jsonc.d.ts +0 -45
  68. package/bin/utils/json/regular/jsonc.js +0 -88
  69. package/bin/utils/json/regular/jsonrepair.d.ts +0 -17
  70. package/bin/utils/json/regular/jsonrepair.js +0 -576
  71. package/bin/utils/json/regular/validate.d.ts +0 -22
  72. package/bin/utils/json/regular/validate.js +0 -52
  73. package/bin/utils/json/stream/JsonStreamError.d.ts +0 -6
  74. package/bin/utils/json/stream/JsonStreamError.js +0 -6
  75. package/bin/utils/json/stream/buffer/InputBuffer.d.ts +0 -13
  76. package/bin/utils/json/stream/buffer/InputBuffer.js +0 -68
  77. package/bin/utils/json/stream/buffer/OutputBuffer.d.ts +0 -17
  78. package/bin/utils/json/stream/buffer/OutputBuffer.js +0 -101
  79. package/bin/utils/json/stream/core.d.ts +0 -10
  80. package/bin/utils/json/stream/core.js +0 -695
  81. package/bin/utils/json/stream/jsonl.d.ts +0 -21
  82. package/bin/utils/json/stream/jsonl.js +0 -55
  83. package/bin/utils/json/stream/parser.d.ts +0 -14
  84. package/bin/utils/json/stream/parser.js +0 -81
  85. package/bin/utils/json/stream/stack.d.ts +0 -19
  86. package/bin/utils/json/stream/stack.js +0 -43
  87. package/bin/utils/json/stream/stream.d.ts +0 -6
  88. package/bin/utils/json/stream/stream.js +0 -30
  89. package/bin/utils/json/stream/writer.d.ts +0 -14
  90. package/bin/utils/json/stream/writer.js +0 -44
  91. package/bin/utils/log.d.ts +0 -1
  92. package/bin/utils/log.js +0 -7
package/bin/mod.js DELETED
@@ -1,514 +0,0 @@
1
- import {
2
- renameSync as nodeRenameSync,
3
- unlinkSync as nodeUnlinkSync,
4
- accessSync,
5
- constants,
6
- readdirSync,
7
- statSync,
8
- copyFileSync,
9
- appendFileSync,
10
- chmodSync,
11
- chownSync,
12
- closeSync,
13
- createReadStream,
14
- createWriteStream,
15
- fchmodSync,
16
- fchownSync,
17
- fdatasyncSync,
18
- fstatSync,
19
- fsyncSync,
20
- ftruncateSync,
21
- futimesSync,
22
- lchmodSync,
23
- lchownSync,
24
- linkSync,
25
- lstatSync,
26
- lutimesSync,
27
- mkdtempSync,
28
- openSync,
29
- opendirSync,
30
- readSync,
31
- readlinkSync,
32
- realpathSync,
33
- rmSync,
34
- rmdirSync,
35
- statfsSync,
36
- symlinkSync,
37
- truncateSync,
38
- unwatchFile,
39
- utimesSync,
40
- watchFile,
41
- writeFileSync,
42
- writeSync,
43
- readvSync,
44
- writevSync
45
- } from "node:fs";
46
- import {
47
- rename as nodeRename,
48
- unlink as nodeUnlink,
49
- access,
50
- appendFile,
51
- chmod,
52
- chown,
53
- copyFile,
54
- lchmod,
55
- lchown,
56
- link,
57
- lstat,
58
- lutimes,
59
- mkdtemp,
60
- open,
61
- opendir,
62
- readdir,
63
- readlink,
64
- realpath,
65
- rm,
66
- rmdir,
67
- stat,
68
- statfs,
69
- symlink,
70
- truncate,
71
- utimes,
72
- watch,
73
- writeFile
74
- } from "node:fs/promises";
75
- import { resolve } from "node:path";
76
- import { getFileBun, getFileTypeBun, isBun } from "./impl/bun.js";
77
- import { copy, copySync } from "./impl/copy.js";
78
- import {
79
- createFile,
80
- createFileSync,
81
- createDir,
82
- createDirs,
83
- createFiles,
84
- createDirSync,
85
- createDirsSync,
86
- createFilesSync
87
- } from "./impl/create.js";
88
- import { dive, diveSync } from "./impl/dive.js";
89
- import { emptyDir, emptyDirSync, emptyObject, emptyFile, emptyFileSync } from "./impl/empty.js";
90
- import {
91
- readText,
92
- readTextSync,
93
- readLines,
94
- readLinesSync,
95
- isDirectory,
96
- isDirectorySync,
97
- isSymlink,
98
- isSymlinkSync,
99
- execAsync,
100
- isDirectoryEmpty,
101
- isHiddenAttribute,
102
- rmEnsureDir,
103
- setHiddenAttribute
104
- } from "./impl/extras.js";
105
- import { validateAndRepairJson } from "./impl/json-utils.js";
106
- import { mkdirs, mkdirsSync } from "./impl/mkdirs.js";
107
- import { move, moveSync } from "./impl/move.js";
108
- import { outputFile, outputFileSync } from "./impl/output-file.js";
109
- import { outputJson, outputJsonSync } from "./impl/output-json.js";
110
- import { pathExists, pathExistsSync } from "./impl/path-exists.js";
111
- import { readFile, readFileSync } from "./impl/read-file.js";
112
- import { readJson, readJsonSync } from "./impl/read-json.js";
113
- import { remove, removeSync } from "./impl/remove.js";
114
- import { getFileExists, getFileLastModified, getFileSize, getStats, getStatsSync, toNodeStats } from "./impl/stats.js";
115
- import { writeJson, writeJsonSync } from "./impl/write-json.js";
116
- import { JSONRepairError } from "./utils/json/helpers/JSONRepairError.js";
117
- import { JsonSchemaError } from "./utils/json/helpers/JsonSchemaError.js";
118
- import { extractComments } from "./utils/json/regular/jsonc.js";
119
- import { jsonrepair } from "./utils/json/regular/jsonrepair.js";
120
- import { validateJson } from "./utils/json/regular/validate.js";
121
- import { createInputBuffer } from "./utils/json/stream/buffer/InputBuffer.js";
122
- import { createOutputBuffer } from "./utils/json/stream/buffer/OutputBuffer.js";
123
- import { jsonrepairCore } from "./utils/json/stream/core.js";
124
- import { createJsonlParser } from "./utils/json/stream/jsonl.js";
125
- import { createJsonlWriter } from "./utils/json/stream/jsonl.js";
126
- import { JsonStreamError } from "./utils/json/stream/JsonStreamError.js";
127
- import { createJsonStreamParser } from "./utils/json/stream/parser.js";
128
- import { jsonrepairTransform } from "./utils/json/stream/stream.js";
129
- import { createJsonStreamWriter } from "./utils/json/stream/writer.js";
130
- const mkdirp = mkdirs;
131
- const ensureDir = mkdirs;
132
- const ensureFile = createFile;
133
- const rimraf = remove;
134
- const ncp = copy;
135
- const mkdirpSync = mkdirsSync;
136
- const ensureDirSync = mkdirsSync;
137
- const ensureFileSync = createFileSync;
138
- const rimrafSync = removeSync;
139
- const ncpSync = copySync;
140
- const mkdir = mkdirs;
141
- const mkdirSync = mkdirsSync;
142
- const unlink = remove;
143
- const unlinkSync = removeSync;
144
- const rename = move;
145
- const renameSync = moveSync;
146
- const readJSON = readJson;
147
- const readJSONSync = readJsonSync;
148
- const writeJSON = writeJson;
149
- const writeJSONSync = writeJsonSync;
150
- const outputJSON = outputJson;
151
- const outputJSONSync = outputJsonSync;
152
- const cp = copy;
153
- const cpSync = copySync;
154
- const exists = pathExists;
155
- const existsSync = pathExistsSync;
156
- const jsonRepairRegular = jsonrepair;
157
- export {
158
- accessSync,
159
- appendFileSync,
160
- chmodSync,
161
- chownSync,
162
- closeSync,
163
- copyFileSync,
164
- createReadStream,
165
- createWriteStream,
166
- fchmodSync,
167
- fchownSync,
168
- fdatasyncSync,
169
- fstatSync,
170
- fsyncSync,
171
- ftruncateSync,
172
- futimesSync,
173
- lchmodSync,
174
- lchownSync,
175
- linkSync,
176
- lstatSync,
177
- lutimesSync,
178
- mkdtempSync,
179
- openSync,
180
- opendirSync,
181
- readFileSync,
182
- readlinkSync,
183
- readSync,
184
- readdirSync,
185
- realpathSync,
186
- nodeRenameSync,
187
- rmSync,
188
- rmdirSync,
189
- statSync,
190
- statfsSync,
191
- symlinkSync,
192
- truncateSync,
193
- nodeUnlinkSync,
194
- unwatchFile,
195
- utimesSync,
196
- watchFile,
197
- writeFileSync,
198
- writeSync,
199
- readvSync,
200
- writevSync,
201
- readJsonSync,
202
- writeJsonSync,
203
- createFileSync,
204
- createDirSync,
205
- createDirsSync,
206
- createFilesSync,
207
- emptyFileSync,
208
- mkdirsSync,
209
- emptyDirSync,
210
- pathExistsSync,
211
- copySync,
212
- moveSync,
213
- removeSync,
214
- outputJsonSync,
215
- outputFileSync,
216
- diveSync,
217
- cpSync,
218
- ensureDirSync as ensuredirSync,
219
- ensureDirSync,
220
- ensureFileSync,
221
- existsSync,
222
- mkdirpSync,
223
- mkdirSync,
224
- ncpSync,
225
- outputJSONSync,
226
- readJSONSync,
227
- renameSync,
228
- rimrafSync,
229
- unlinkSync,
230
- writeJSONSync,
231
- isDirectorySync,
232
- isSymlinkSync,
233
- readLinesSync,
234
- readTextSync,
235
- readJson,
236
- writeJson,
237
- createFile,
238
- createDir,
239
- createDirs,
240
- createFiles,
241
- emptyFile,
242
- mkdirs,
243
- emptyDir,
244
- pathExists,
245
- copy,
246
- move,
247
- remove,
248
- outputJson,
249
- outputFile,
250
- access,
251
- appendFile,
252
- chmod,
253
- chown,
254
- copyFile,
255
- lchmod,
256
- lchown,
257
- link,
258
- lstat,
259
- lutimes,
260
- mkdtemp,
261
- open,
262
- opendir,
263
- readFile,
264
- readdir,
265
- readlink,
266
- realpath,
267
- nodeRename,
268
- rm,
269
- rmdir,
270
- stat,
271
- statfs,
272
- symlink,
273
- truncate,
274
- nodeUnlink,
275
- utimes,
276
- watch,
277
- writeFile,
278
- constants,
279
- cp,
280
- ensureDir as ensuredir,
281
- ensureDir,
282
- ensureFile,
283
- exists,
284
- mkdir,
285
- mkdirp,
286
- ncp,
287
- outputJSON,
288
- readJSON,
289
- rename,
290
- resolve,
291
- rimraf,
292
- unlink,
293
- writeJSON,
294
- isDirectory,
295
- isSymlink,
296
- readLines,
297
- readText,
298
- execAsync,
299
- setHiddenAttribute,
300
- isHiddenAttribute,
301
- isDirectoryEmpty,
302
- rmEnsureDir,
303
- dive,
304
- getFileExists,
305
- getFileLastModified,
306
- getFileSize,
307
- getStats,
308
- getStatsSync,
309
- emptyObject,
310
- getFileBun,
311
- getFileTypeBun,
312
- toNodeStats,
313
- isBun,
314
- jsonrepair,
315
- jsonRepairRegular,
316
- createInputBuffer,
317
- createOutputBuffer,
318
- jsonrepairCore,
319
- JSONRepairError,
320
- jsonrepairTransform,
321
- validateAndRepairJson,
322
- validateJson,
323
- JsonSchemaError,
324
- createJsonStreamParser,
325
- createJsonStreamWriter,
326
- JsonStreamError,
327
- createJsonlParser,
328
- createJsonlWriter,
329
- extractComments
330
- };
331
- const fs = {
332
- // Sync direct exports (node:fs)
333
- accessSync,
334
- appendFileSync,
335
- chmodSync,
336
- chownSync,
337
- closeSync,
338
- copyFileSync,
339
- createReadStream,
340
- createWriteStream,
341
- fchmodSync,
342
- fchownSync,
343
- fdatasyncSync,
344
- fstatSync,
345
- fsyncSync,
346
- ftruncateSync,
347
- futimesSync,
348
- lchmodSync,
349
- lchownSync,
350
- linkSync,
351
- lstatSync,
352
- lutimesSync,
353
- mkdtempSync,
354
- openSync,
355
- opendirSync,
356
- readFileSync,
357
- readlinkSync,
358
- readSync,
359
- readdirSync,
360
- realpathSync,
361
- nodeRenameSync,
362
- rmSync,
363
- rmdirSync,
364
- statSync,
365
- statfsSync,
366
- symlinkSync,
367
- truncateSync,
368
- nodeUnlinkSync,
369
- unwatchFile,
370
- utimesSync,
371
- watchFile,
372
- writeFileSync,
373
- writeSync,
374
- readvSync,
375
- writevSync,
376
- readJsonSync,
377
- writeJsonSync,
378
- createFileSync,
379
- createDirSync,
380
- createDirsSync,
381
- createFilesSync,
382
- emptyFileSync,
383
- mkdirsSync,
384
- emptyDirSync,
385
- pathExistsSync,
386
- copySync,
387
- moveSync,
388
- removeSync,
389
- outputJsonSync,
390
- outputFileSync,
391
- diveSync,
392
- // Sync aliases
393
- cpSync,
394
- ensuredirSync: ensureDirSync,
395
- ensureDirSync,
396
- ensureFileSync,
397
- existsSync,
398
- mkdirpSync,
399
- mkdirSync,
400
- ncpSync,
401
- outputJSONSync,
402
- readJSONSync,
403
- renameSync,
404
- rimrafSync,
405
- unlinkSync,
406
- writeJSONSync,
407
- // Simple sync custom implementations
408
- isDirectorySync,
409
- isSymlinkSync,
410
- readLinesSync,
411
- readTextSync,
412
- // Async direct exports (node:fs/promises)
413
- readJson,
414
- writeJson,
415
- createFile,
416
- createDir,
417
- createDirs,
418
- createFiles,
419
- emptyFile,
420
- mkdirs,
421
- emptyDir,
422
- pathExists,
423
- copy,
424
- move,
425
- remove,
426
- outputJson,
427
- outputFile,
428
- access,
429
- appendFile,
430
- chmod,
431
- chown,
432
- copyFile,
433
- lchmod,
434
- lchown,
435
- link,
436
- lstat,
437
- lutimes,
438
- mkdtemp,
439
- open,
440
- opendir,
441
- readFile,
442
- readdir,
443
- readlink,
444
- realpath,
445
- nodeRename,
446
- rm,
447
- rmdir,
448
- stat,
449
- statfs,
450
- symlink,
451
- truncate,
452
- nodeUnlink,
453
- utimes,
454
- watch,
455
- writeFile,
456
- // Async aliases
457
- constants,
458
- cp,
459
- ensureDir,
460
- ensuredir: ensureDir,
461
- ensureFile,
462
- exists,
463
- mkdir,
464
- mkdirp,
465
- ncp,
466
- outputJSON,
467
- readJSON,
468
- rename,
469
- resolve,
470
- rimraf,
471
- unlink,
472
- writeJSON,
473
- // Simple async custom implementations
474
- isDirectory,
475
- isSymlink,
476
- readLines,
477
- readText,
478
- // Additional utility functions
479
- execAsync,
480
- setHiddenAttribute,
481
- isHiddenAttribute,
482
- isDirectoryEmpty,
483
- rmEnsureDir,
484
- dive,
485
- getFileExists,
486
- getFileLastModified,
487
- getFileSize,
488
- getStats,
489
- getStatsSync,
490
- emptyObject,
491
- // Bun-specific utilities
492
- getFileBun,
493
- getFileTypeBun,
494
- toNodeStats,
495
- isBun,
496
- // JSON utilities
497
- jsonrepair,
498
- jsonRepairRegular,
499
- createInputBuffer,
500
- createOutputBuffer,
501
- jsonrepairCore,
502
- JSONRepairError,
503
- jsonrepairTransform,
504
- validateAndRepairJson,
505
- validateJson,
506
- JsonSchemaError,
507
- createJsonStreamParser,
508
- createJsonStreamWriter,
509
- JsonStreamError,
510
- createJsonlParser,
511
- createJsonlWriter,
512
- extractComments
513
- };
514
- export default fs;
@@ -1,4 +0,0 @@
1
- export declare class JSONRepairError extends Error {
2
- position: number;
3
- constructor(message: string, position: number);
4
- }
@@ -1,7 +0,0 @@
1
- export class JSONRepairError extends Error {
2
- position;
3
- constructor(message, position) {
4
- super(`${message} at position ${position}`);
5
- this.position = position;
6
- }
7
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Custom error class for JSON Schema validation errors.
3
- */
4
- export declare class JsonSchemaError extends Error {
5
- constructor(message: string);
6
- }
@@ -1,6 +0,0 @@
1
- export class JsonSchemaError extends Error {
2
- constructor(message) {
3
- super(message);
4
- this.name = "JsonSchemaError";
5
- }
6
- }
@@ -1,64 +0,0 @@
1
- export declare function isHex(char: string): boolean;
2
- export declare function isDigit(char: string): boolean;
3
- export declare function isValidStringCharacter(char: string): boolean;
4
- export declare function isDelimiter(char: string): boolean;
5
- export declare function isFunctionNameCharStart(char: string): boolean;
6
- export declare function isFunctionNameChar(char: string): boolean;
7
- export declare const regexUrlStart: RegExp;
8
- export declare const regexUrlChar: RegExp;
9
- export declare function isUnquotedStringDelimiter(char: string): boolean;
10
- export declare function isStartOfValue(char: string): boolean;
11
- export declare function isControlCharacter(char: string): char is "\b" | "\f" | "\n" | "\r" | "\t";
12
- export interface Text {
13
- charCodeAt: (index: number) => number;
14
- }
15
- /**
16
- * Check if the given character is a whitespace character like space, tab, or
17
- * newline
18
- */
19
- export declare function isWhitespace(text: Text, index: number): boolean;
20
- /**
21
- * Check if the given character is a whitespace character like space or tab,
22
- * but NOT a newline
23
- */
24
- export declare function isWhitespaceExceptNewline(text: Text, index: number): boolean;
25
- /**
26
- * Check if the given character is a special whitespace character, some
27
- * unicode variant
28
- */
29
- export declare function isSpecialWhitespace(text: Text, index: number): boolean;
30
- /**
31
- * Test whether the given character is a quote or double quote character.
32
- * Also tests for special variants of quotes.
33
- */
34
- export declare function isQuote(char: string): boolean;
35
- /**
36
- * Test whether the given character is a double quote character.
37
- * Also tests for special variants of double quotes.
38
- */
39
- export declare function isDoubleQuoteLike(char: string): boolean;
40
- /**
41
- * Test whether the given character is a double quote character.
42
- * Does NOT test for special variants of double quotes.
43
- */
44
- export declare function isDoubleQuote(char: string): boolean;
45
- /**
46
- * Test whether the given character is a single quote character.
47
- * Also tests for special variants of single quotes.
48
- */
49
- export declare function isSingleQuoteLike(char: string): boolean;
50
- /**
51
- * Test whether the given character is a single quote character.
52
- * Does NOT test for special variants of single quotes.
53
- */
54
- export declare function isSingleQuote(char: string): boolean;
55
- /**
56
- * Strip last occurrence of textToStrip from text
57
- */
58
- export declare function stripLastOccurrence(text: string, textToStrip: string, stripRemainingText?: boolean): string;
59
- export declare function insertBeforeLastWhitespace(text: string, textToInsert: string): string;
60
- export declare function removeAtIndex(text: string, start: number, count: number): string;
61
- /**
62
- * Test whether a string ends with a newline or comma character and optional whitespace
63
- */
64
- export declare function endsWithCommaOrNewline(text: string): boolean;
@@ -1,87 +0,0 @@
1
- const codeSpace = 32;
2
- const codeNewline = 10;
3
- const codeTab = 9;
4
- const codeReturn = 13;
5
- const codeNonBreakingSpace = 160;
6
- const codeEnQuad = 8192;
7
- const codeHairSpace = 8202;
8
- const codeNarrowNoBreakSpace = 8239;
9
- const codeMediumMathematicalSpace = 8287;
10
- const codeIdeographicSpace = 12288;
11
- export function isHex(char) {
12
- return /^[0-9A-Fa-f]$/.test(char);
13
- }
14
- export function isDigit(char) {
15
- return char >= "0" && char <= "9";
16
- }
17
- export function isValidStringCharacter(char) {
18
- return char >= " ";
19
- }
20
- export function isDelimiter(char) {
21
- return ",:[]/{}()\n+".includes(char);
22
- }
23
- export function isFunctionNameCharStart(char) {
24
- return char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char === "_" || char === "$";
25
- }
26
- export function isFunctionNameChar(char) {
27
- return char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char === "_" || char === "$" || char >= "0" && char <= "9";
28
- }
29
- export const regexUrlStart = /^(http|https|ftp|mailto|file|data|irc):\/\/$/;
30
- export const regexUrlChar = /^[A-Za-z0-9-._~:/?#@!$&'()*+;=]$/;
31
- export function isUnquotedStringDelimiter(char) {
32
- return ",[]/{}\n+".includes(char);
33
- }
34
- export function isStartOfValue(char) {
35
- return isQuote(char) || regexStartOfValue.test(char);
36
- }
37
- const regexStartOfValue = /^[[{\w-]$/;
38
- export function isControlCharacter(char) {
39
- return char === "\n" || char === "\r" || char === " " || char === "\b" || char === "\f";
40
- }
41
- export function isWhitespace(text, index) {
42
- const code = text.charCodeAt(index);
43
- return code === codeSpace || code === codeNewline || code === codeTab || code === codeReturn;
44
- }
45
- export function isWhitespaceExceptNewline(text, index) {
46
- const code = text.charCodeAt(index);
47
- return code === codeSpace || code === codeTab || code === codeReturn;
48
- }
49
- export function isSpecialWhitespace(text, index) {
50
- const code = text.charCodeAt(index);
51
- return code === codeNonBreakingSpace || code >= codeEnQuad && code <= codeHairSpace || code === codeNarrowNoBreakSpace || code === codeMediumMathematicalSpace || code === codeIdeographicSpace;
52
- }
53
- export function isQuote(char) {
54
- return isDoubleQuoteLike(char) || isSingleQuoteLike(char);
55
- }
56
- export function isDoubleQuoteLike(char) {
57
- return char === '"' || char === "\u201C" || char === "\u201D";
58
- }
59
- export function isDoubleQuote(char) {
60
- return char === '"';
61
- }
62
- export function isSingleQuoteLike(char) {
63
- return char === "'" || char === "\u2018" || char === "\u2019" || char === "`" || char === "\xB4";
64
- }
65
- export function isSingleQuote(char) {
66
- return char === "'";
67
- }
68
- export function stripLastOccurrence(text, textToStrip, stripRemainingText = false) {
69
- const index = text.lastIndexOf(textToStrip);
70
- return index !== -1 ? text.substring(0, index) + (stripRemainingText ? "" : text.substring(index + 1)) : text;
71
- }
72
- export function insertBeforeLastWhitespace(text, textToInsert) {
73
- let index = text.length;
74
- if (!isWhitespace(text, index - 1)) {
75
- return text + textToInsert;
76
- }
77
- while (isWhitespace(text, index - 1)) {
78
- index--;
79
- }
80
- return text.substring(0, index) + textToInsert + text.substring(index);
81
- }
82
- export function removeAtIndex(text, start, count) {
83
- return text.substring(0, start) + text.substring(start + count);
84
- }
85
- export function endsWithCommaOrNewline(text) {
86
- return /[,\n][ \t\r]*$/.test(text);
87
- }