@difizen/libro-common 0.0.2-alpha.0

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 (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +0 -0
  3. package/es/array.d.ts +368 -0
  4. package/es/array.d.ts.map +1 -0
  5. package/es/array.js +577 -0
  6. package/es/display-wrapper.d.ts +6 -0
  7. package/es/display-wrapper.d.ts.map +1 -0
  8. package/es/display-wrapper.js +12 -0
  9. package/es/index.d.ts +11 -0
  10. package/es/index.d.ts.map +1 -0
  11. package/es/index.js +10 -0
  12. package/es/iter.d.ts +147 -0
  13. package/es/iter.d.ts.map +1 -0
  14. package/es/iter.js +162 -0
  15. package/es/json.d.ts +126 -0
  16. package/es/json.d.ts.map +1 -0
  17. package/es/json.js +274 -0
  18. package/es/path.d.ts +97 -0
  19. package/es/path.d.ts.map +1 -0
  20. package/es/path.js +60 -0
  21. package/es/polling/index.d.ts +3 -0
  22. package/es/polling/index.d.ts.map +1 -0
  23. package/es/polling/index.js +2 -0
  24. package/es/polling/poll.d.ts +193 -0
  25. package/es/polling/poll.d.ts.map +1 -0
  26. package/es/polling/poll.js +501 -0
  27. package/es/polling/protocol.d.ts +120 -0
  28. package/es/polling/protocol.d.ts.map +1 -0
  29. package/es/polling/protocol.js +13 -0
  30. package/es/posix.d.ts +2 -0
  31. package/es/posix.d.ts.map +1 -0
  32. package/es/posix.js +71 -0
  33. package/es/protocol/cell-protocol.d.ts +181 -0
  34. package/es/protocol/cell-protocol.d.ts.map +1 -0
  35. package/es/protocol/cell-protocol.js +1 -0
  36. package/es/protocol/index.d.ts +4 -0
  37. package/es/protocol/index.d.ts.map +1 -0
  38. package/es/protocol/index.js +3 -0
  39. package/es/protocol/notebook-protocol.d.ts +63 -0
  40. package/es/protocol/notebook-protocol.d.ts.map +1 -0
  41. package/es/protocol/notebook-protocol.js +41 -0
  42. package/es/protocol/output-protocol.d.ts +125 -0
  43. package/es/protocol/output-protocol.d.ts.map +1 -0
  44. package/es/protocol/output-protocol.js +1 -0
  45. package/es/sanitizer.d.ts +44 -0
  46. package/es/sanitizer.d.ts.map +1 -0
  47. package/es/sanitizer.js +659 -0
  48. package/es/url.d.ts +98 -0
  49. package/es/url.d.ts.map +1 -0
  50. package/es/url.js +134 -0
  51. package/es/utils.d.ts +57 -0
  52. package/es/utils.d.ts.map +1 -0
  53. package/es/utils.js +124 -0
  54. package/package.json +62 -0
  55. package/src/array.ts +608 -0
  56. package/src/display-wrapper.tsx +11 -0
  57. package/src/index.ts +10 -0
  58. package/src/iter.ts +199 -0
  59. package/src/json.ts +321 -0
  60. package/src/path.ts +138 -0
  61. package/src/polling/index.ts +2 -0
  62. package/src/polling/poll.ts +508 -0
  63. package/src/polling/protocol.ts +145 -0
  64. package/src/posix.ts +75 -0
  65. package/src/protocol/cell-protocol.ts +215 -0
  66. package/src/protocol/index.ts +3 -0
  67. package/src/protocol/notebook-protocol.ts +73 -0
  68. package/src/protocol/output-protocol.ts +162 -0
  69. package/src/sanitizer.ts +944 -0
  70. package/src/url.ts +157 -0
  71. package/src/utils.ts +145 -0
package/src/array.ts ADDED
@@ -0,0 +1,608 @@
1
+ /**
2
+ * Find the index of the first occurrence of a value in an array.
3
+ *
4
+ * @param array - The array-like object to search.
5
+ *
6
+ * @param value - The value to locate in the array. Values are
7
+ * compared using strict `===` equality.
8
+ *
9
+ * @param start - The index of the first element in the range to be
10
+ * searched, inclusive. The default value is `0`. Negative values
11
+ * are taken as an offset from the end of the array.
12
+ *
13
+ * @param stop - The index of the last element in the range to be
14
+ * searched, inclusive. The default value is `-1`. Negative values
15
+ * are taken as an offset from the end of the array.
16
+ *
17
+ * @returns The index of the first occurrence of the value, or `-1`
18
+ * if the value is not found.
19
+ *
20
+ * #### Notes
21
+ * If `stop < start` the search will wrap at the end of the array.
22
+ *
23
+ * #### Complexity
24
+ * Linear.
25
+ *
26
+ * #### Undefined Behavior
27
+ * A `start` or `stop` which is non-integral.
28
+ *
29
+ * #### Example
30
+ * ```typescript
31
+ *
32
+ * let data = ['one', 'two', 'three', 'four', 'one'];
33
+ * firstIndexOfArray(data, 'red'); // -1
34
+ * firstIndexOfArray(data, 'one'); // 0
35
+ * firstIndexOfArray(data, 'one', 1); // 4
36
+ * firstIndexOfArray(data, 'two', 2); // -1
37
+ * firstIndexOfArray(data, 'two', 2, 1); // 1
38
+ * ```
39
+ */
40
+ export function firstIndexOfArray<T>(
41
+ array: ArrayLike<T>,
42
+ value: T,
43
+ start = 0,
44
+ stop = -1,
45
+ ): number {
46
+ const n = array.length;
47
+ let arrStart = start;
48
+ let arrStop = stop;
49
+ if (n === 0) {
50
+ return -1;
51
+ }
52
+ if (arrStart < 0) {
53
+ arrStart = Math.max(0, arrStart + n);
54
+ } else {
55
+ arrStart = Math.min(arrStart, n - 1);
56
+ }
57
+ if (arrStop < 0) {
58
+ arrStop = Math.max(0, arrStop + n);
59
+ } else {
60
+ arrStop = Math.min(arrStop, n - 1);
61
+ }
62
+ let span: number;
63
+ if (arrStop < arrStart) {
64
+ span = arrStop + 1 + (n - arrStart);
65
+ } else {
66
+ span = arrStop - arrStart + 1;
67
+ }
68
+ for (let i = 0; i < span; ++i) {
69
+ const j = (arrStart + i) % n;
70
+ if (array[j] === value) {
71
+ return j;
72
+ }
73
+ }
74
+ return -1;
75
+ }
76
+
77
+ /**
78
+ * Find the index of the first value which matches a predicate.
79
+ *
80
+ * @param array - The array-like object to search.
81
+ *
82
+ * @param fn - The predicate function to apply to the values.
83
+ *
84
+ * @param start - The index of the first element in the range to be
85
+ * searched, inclusive. The default value is `0`. Negative values
86
+ * are taken as an offset from the end of the array.
87
+ *
88
+ * @param stop - The index of the last element in the range to be
89
+ * searched, inclusive. The default value is `-1`. Negative values
90
+ * are taken as an offset from the end of the array.
91
+ *
92
+ * @returns The index of the first matching value, or `-1` if no
93
+ * matching value is found.
94
+ *
95
+ * #### Notes
96
+ * If `stop < start` the search will wrap at the end of the array.
97
+ *
98
+ * #### Complexity
99
+ * Linear.
100
+ *
101
+ * #### Undefined Behavior
102
+ * A `start` or `stop` which is non-integral.
103
+ *
104
+ * Modifying the length of the array while searching.
105
+ *
106
+ * #### Example
107
+ * ```typescript
108
+ *
109
+ * function isEven(value: number): boolean {
110
+ * return value % 2 === 0;
111
+ * }
112
+ *
113
+ * let data = [1, 2, 3, 4, 3, 2, 1];
114
+ * findFirstArrayIndex(data, isEven); // 1
115
+ * findFirstArrayIndex(data, isEven, 4); // 5
116
+ * findFirstArrayIndex(data, isEven, 6); // -1
117
+ * findFirstArrayIndex(data, isEven, 6, 5); // 1
118
+ * ```
119
+ */
120
+ export function findFirstArrayIndex<T>(
121
+ array: ArrayLike<T>,
122
+ fn: (value: T, index: number) => boolean,
123
+ start = 0,
124
+ stop = -1,
125
+ ): number {
126
+ const n = array.length;
127
+ let arrStart = start;
128
+ let arrStop = stop;
129
+ if (n === 0) {
130
+ return -1;
131
+ }
132
+ if (arrStart < 0) {
133
+ arrStart = Math.max(0, arrStart + n);
134
+ } else {
135
+ arrStart = Math.min(arrStart, n - 1);
136
+ }
137
+ if (arrStop < 0) {
138
+ arrStop = Math.max(0, arrStop + n);
139
+ } else {
140
+ arrStop = Math.min(arrStop, n - 1);
141
+ }
142
+ let span: number;
143
+ if (arrStop < arrStart) {
144
+ span = arrStop + 1 + (n - arrStart);
145
+ } else {
146
+ span = arrStop - arrStart + 1;
147
+ }
148
+ for (let i = 0; i < span; ++i) {
149
+ const j = (arrStart + i) % n;
150
+ if (fn(array[j], j)) {
151
+ return j;
152
+ }
153
+ }
154
+ return -1;
155
+ }
156
+
157
+ /**
158
+ * Find the index of the last value which matches a predicate.
159
+ *
160
+ * @param object - The array-like object to search.
161
+ *
162
+ * @param fn - The predicate function to apply to the values.
163
+ *
164
+ * @param start - The index of the first element in the range to be
165
+ * searched, inclusive. The default value is `-1`. Negative values
166
+ * are taken as an offset from the end of the array.
167
+ *
168
+ * @param stop - The index of the last element in the range to be
169
+ * searched, inclusive. The default value is `0`. Negative values
170
+ * are taken as an offset from the end of the array.
171
+ *
172
+ * @returns The index of the last matching value, or `-1` if no
173
+ * matching value is found.
174
+ *
175
+ * #### Notes
176
+ * If `start < stop` the search will wrap at the front of the array.
177
+ *
178
+ * #### Complexity
179
+ * Linear.
180
+ *
181
+ * #### Undefined Behavior
182
+ * A `start` or `stop` which is non-integral.
183
+ *
184
+ * Modifying the length of the array while searching.
185
+ *
186
+ * #### Example
187
+ * ```typescript
188
+ *
189
+ * function isEven(value: number): boolean {
190
+ * return value % 2 === 0;
191
+ * }
192
+ *
193
+ * let data = [1, 2, 3, 4, 3, 2, 1];
194
+ * findLastArrayIndex(data, isEven); // 5
195
+ * findLastArrayIndex(data, isEven, 4); // 3
196
+ * findLastArrayIndex(data, isEven, 0); // -1
197
+ * findLastArrayIndex(data, isEven, 0, 1); // 5
198
+ * ```
199
+ */
200
+ export function findLastArrayIndex<T>(
201
+ array: ArrayLike<T>,
202
+ fn: (value: T, index: number) => boolean,
203
+ start = -1,
204
+ stop = 0,
205
+ ): number {
206
+ let arrStart = start;
207
+ let arrStop = stop;
208
+
209
+ const n = array.length;
210
+ if (n === 0) {
211
+ return -1;
212
+ }
213
+ if (arrStart < 0) {
214
+ arrStart = Math.max(0, arrStart + n);
215
+ } else {
216
+ arrStart = Math.min(arrStart, n - 1);
217
+ }
218
+ if (arrStop < 0) {
219
+ arrStop = Math.max(0, arrStop + n);
220
+ } else {
221
+ arrStop = Math.min(arrStop, n - 1);
222
+ }
223
+ let d: number;
224
+ if (arrStart < arrStop) {
225
+ d = arrStart + 1 + (n - arrStop);
226
+ } else {
227
+ d = arrStart - arrStop + 1;
228
+ }
229
+ for (let i = 0; i < d; ++i) {
230
+ const j = (arrStart - i + n) % n;
231
+ if (fn(array[j], j)) {
232
+ return j;
233
+ }
234
+ }
235
+ return -1;
236
+ }
237
+
238
+ /**
239
+ * Find the first value which matches a predicate.
240
+ *
241
+ * @param array - The array-like object to search.
242
+ *
243
+ * @param fn - The predicate function to apply to the values.
244
+ *
245
+ * @param start - The index of the first element in the range to be
246
+ * searched, inclusive. The default value is `0`. Negative values
247
+ * are taken as an offset from the end of the array.
248
+ *
249
+ * @param stop - The index of the last element in the range to be
250
+ * searched, inclusive. The default value is `-1`. Negative values
251
+ * are taken as an offset from the end of the array.
252
+ *
253
+ * @returns The first matching value, or `undefined` if no matching
254
+ * value is found.
255
+ *
256
+ * #### Notes
257
+ * If `stop < start` the search will wrap at the end of the array.
258
+ *
259
+ * #### Complexity
260
+ * Linear.
261
+ *
262
+ * #### Undefined Behavior
263
+ * A `start` or `stop` which is non-integral.
264
+ *
265
+ * Modifying the length of the array while searching.
266
+ *
267
+ * #### Example
268
+ * ```typescript
269
+ *
270
+ * function isEven(value: number): boolean {
271
+ * return value % 2 === 0;
272
+ * }
273
+ *
274
+ * let data = [1, 2, 3, 4, 3, 2, 1];
275
+ * findFirstArrayValue(data, isEven); // 2
276
+ * findFirstArrayValue(data, isEven, 2); // 4
277
+ * findFirstArrayValue(data, isEven, 6); // undefined
278
+ * findFirstArrayValue(data, isEven, 6, 5); // 2
279
+ * ```
280
+ */
281
+ export function findFirstArrayValue<T>(
282
+ array: ArrayLike<T>,
283
+ fn: (value: T, index: number) => boolean,
284
+ start = 0,
285
+ stop = -1,
286
+ ): T | undefined {
287
+ const index = findFirstArrayIndex(array, fn, start, stop);
288
+ return index !== -1 ? array[index] : undefined;
289
+ }
290
+
291
+ /**
292
+ * Find the last value which matches a predicate.
293
+ *
294
+ * @param object - The array-like object to search.
295
+ *
296
+ * @param fn - The predicate function to apply to the values.
297
+ *
298
+ * @param start - The index of the first element in the range to be
299
+ * searched, inclusive. The default value is `-1`. Negative values
300
+ * are taken as an offset from the end of the array.
301
+ *
302
+ * @param stop - The index of the last element in the range to be
303
+ * searched, inclusive. The default value is `0`. Negative values
304
+ * are taken as an offset from the end of the array.
305
+ *
306
+ * @returns The last matching value, or `undefined` if no matching
307
+ * value is found.
308
+ *
309
+ * #### Notes
310
+ * If `start < stop` the search will wrap at the front of the array.
311
+ *
312
+ * #### Complexity
313
+ * Linear.
314
+ *
315
+ * #### Undefined Behavior
316
+ * A `start` or `stop` which is non-integral.
317
+ *
318
+ * Modifying the length of the array while searching.
319
+ *
320
+ * #### Example
321
+ * ```typescript
322
+ *
323
+ * function isEven(value: number): boolean {
324
+ * return value % 2 === 0;
325
+ * }
326
+ *
327
+ * let data = [1, 2, 3, 4, 3, 2, 1];
328
+ * findLastArrayValue(data, isEven); // 2
329
+ * findLastArrayValue(data, isEven, 4); // 4
330
+ * findLastArrayValue(data, isEven, 0); // undefined
331
+ * findLastArrayValue(data, isEven, 0, 1); // 2
332
+ * ```
333
+ */
334
+ export function findLastArrayValue<T>(
335
+ array: ArrayLike<T>,
336
+ fn: (value: T, index: number) => boolean,
337
+ start = -1,
338
+ stop = 0,
339
+ ): T | undefined {
340
+ const index = findLastArrayIndex(array, fn, start, stop);
341
+ return index !== -1 ? array[index] : undefined;
342
+ }
343
+
344
+ /**
345
+ * Find the index of the first element which compares `>=` to a value.
346
+ *
347
+ * @param array - The sorted array-like object to search.
348
+ *
349
+ * @param value - The value to locate in the array.
350
+ *
351
+ * @param fn - The 3-way comparison function to apply to the values.
352
+ * It should return `< 0` if an element is less than a value, `0` if
353
+ * an element is equal to a value, or `> 0` if an element is greater
354
+ * than a value.
355
+ *
356
+ * @param start - The index of the first element in the range to be
357
+ * searched, inclusive. The default value is `0`. Negative values
358
+ * are taken as an offset from the end of the array.
359
+ *
360
+ * @param stop - The index of the last element in the range to be
361
+ * searched, inclusive. The default value is `-1`. Negative values
362
+ * are taken as an offset from the end of the array.
363
+ *
364
+ * @returns The index of the first element which compares `>=` to the
365
+ * value, or `length` if there is no such element. If the computed
366
+ * index for `stop` is less than `start`, then the computed index
367
+ * for `start` is returned.
368
+ *
369
+ * #### Notes
370
+ * The array must already be sorted in ascending order according to
371
+ * the comparison function.
372
+ *
373
+ * #### Complexity
374
+ * Logarithmic.
375
+ *
376
+ * #### Undefined Behavior
377
+ * Searching a range which is not sorted in ascending order.
378
+ *
379
+ * A `start` or `stop` which is non-integral.
380
+ *
381
+ * Modifying the length of the array while searching.
382
+ *
383
+ * #### Example
384
+ * ```typescript
385
+ *
386
+ * function numberCmp(a: number, b: number): number {
387
+ * return a - b;
388
+ * }
389
+ *
390
+ * let data = [0, 3, 4, 7, 7, 9];
391
+ * lowerArrayBound(data, 0, numberCmp); // 0
392
+ * lowerArrayBound(data, 6, numberCmp); // 3
393
+ * lowerArrayBound(data, 7, numberCmp); // 3
394
+ * lowerArrayBound(data, -1, numberCmp); // 0
395
+ * lowerArrayBound(data, 10, numberCmp); // 6
396
+ * ```
397
+ */
398
+ export function lowerArrayBound<T, U>(
399
+ array: ArrayLike<T>,
400
+ value: U,
401
+ fn: (element: T, value: U) => number,
402
+ start = 0,
403
+ stop = -1,
404
+ ): number {
405
+ let arrStart = start;
406
+ let arrStop = stop;
407
+ const n = array.length;
408
+ if (n === 0) {
409
+ return 0;
410
+ }
411
+ if (arrStart < 0) {
412
+ arrStart = Math.max(0, arrStart + n);
413
+ } else {
414
+ arrStart = Math.min(arrStart, n - 1);
415
+ }
416
+ if (arrStop < 0) {
417
+ arrStop = Math.max(0, arrStop + n);
418
+ } else {
419
+ arrStop = Math.min(arrStop, n - 1);
420
+ }
421
+ let begin = arrStart;
422
+ let span = arrStop - arrStart + 1;
423
+ while (span > 0) {
424
+ const half = span >> 1;
425
+ const middle = begin + half;
426
+ if (fn(array[middle], value) < 0) {
427
+ begin = middle + 1;
428
+ span -= half + 1;
429
+ } else {
430
+ span = half;
431
+ }
432
+ }
433
+ return begin;
434
+ }
435
+
436
+ /**
437
+ * Find the index of the first element which compares `>` than a value.
438
+ *
439
+ * @param array - The sorted array-like object to search.
440
+ *
441
+ * @param value - The value to locate in the array.
442
+ *
443
+ * @param fn - The 3-way comparison function to apply to the values.
444
+ * It should return `< 0` if an element is less than a value, `0` if
445
+ * an element is equal to a value, or `> 0` if an element is greater
446
+ * than a value.
447
+ *
448
+ * @param start - The index of the first element in the range to be
449
+ * searched, inclusive. The default value is `0`. Negative values
450
+ * are taken as an offset from the end of the array.
451
+ *
452
+ * @param stop - The index of the last element in the range to be
453
+ * searched, inclusive. The default value is `-1`. Negative values
454
+ * are taken as an offset from the end of the array.
455
+ *
456
+ * @returns The index of the first element which compares `>` than the
457
+ * value, or `length` if there is no such element. If the computed
458
+ * index for `stop` is less than `start`, then the computed index
459
+ * for `start` is returned.
460
+ *
461
+ * #### Notes
462
+ * The array must already be sorted in ascending order according to
463
+ * the comparison function.
464
+ *
465
+ * #### Complexity
466
+ * Logarithmic.
467
+ *
468
+ * #### Undefined Behavior
469
+ * Searching a range which is not sorted in ascending order.
470
+ *
471
+ * A `start` or `stop` which is non-integral.
472
+ *
473
+ * Modifying the length of the array while searching.
474
+ *
475
+ * #### Example
476
+ * ```typescript
477
+ *
478
+ * function numberCmp(a: number, b: number): number {
479
+ * return a - b;
480
+ * }
481
+ *
482
+ * let data = [0, 3, 4, 7, 7, 9];
483
+ * upperArrayBound(data, 0, numberCmp); // 1
484
+ * upperArrayBound(data, 6, numberCmp); // 3
485
+ * upperArrayBound(data, 7, numberCmp); // 5
486
+ * upperArrayBound(data, -1, numberCmp); // 0
487
+ * upperArrayBound(data, 10, numberCmp); // 6
488
+ * ```
489
+ */
490
+ export function upperArrayBound<T, U>(
491
+ array: ArrayLike<T>,
492
+ value: U,
493
+ fn: (element: T, value: U) => number,
494
+ start = 0,
495
+ stop = -1,
496
+ ): number {
497
+ const n = array.length;
498
+ let arrStart = start;
499
+ let arrStop = stop;
500
+ if (n === 0) {
501
+ return 0;
502
+ }
503
+ if (arrStart < 0) {
504
+ arrStart = Math.max(0, arrStart + n);
505
+ } else {
506
+ arrStart = Math.min(arrStart, n - 1);
507
+ }
508
+ if (arrStop < 0) {
509
+ arrStop = Math.max(0, arrStop + n);
510
+ } else {
511
+ arrStop = Math.min(arrStop, n - 1);
512
+ }
513
+ let begin = arrStart;
514
+ let span = arrStop - arrStart + 1;
515
+ while (span > 0) {
516
+ const half = span >> 1;
517
+ const middle = begin + half;
518
+ if (fn(array[middle], value) > 0) {
519
+ span = half;
520
+ } else {
521
+ begin = middle + 1;
522
+ span -= half + 1;
523
+ }
524
+ }
525
+ return begin;
526
+ }
527
+
528
+ /**
529
+ * Remove all occurrences of values which match a predicate.
530
+ *
531
+ * @param array - The array of interest.
532
+ *
533
+ * @param fn - The predicate function to apply to the values.
534
+ *
535
+ * @param start - The index of the first element in the range to be
536
+ * searched, inclusive. The default value is `0`. Negative values
537
+ * are taken as an offset from the end of the array.
538
+ *
539
+ * @param stop - The index of the last element in the range to be
540
+ * searched, inclusive. The default value is `-1`. Negative values
541
+ * are taken as an offset from the end of the array.
542
+ *
543
+ * @returns The number of elements removed from the array.
544
+ *
545
+ * #### Notes
546
+ * If `stop < start` the search will conceptually wrap at the end of
547
+ * the array, however the array will be traversed front-to-back.
548
+ *
549
+ * #### Complexity
550
+ * Linear.
551
+ *
552
+ * #### Example
553
+ * ```typescript
554
+ *
555
+ * function isEven(value: number): boolean {
556
+ * return value % 2 === 0;
557
+ * }
558
+ *
559
+ * function isNegative(value: number): boolean {
560
+ * return value < 0;
561
+ * }
562
+ *
563
+ * let data = [0, 12, -13, -9, 23, 39, 14, -15, 12, 75];
564
+ * removeAllWhereFromArray(data, isEven); // 4
565
+ * removeAllWhereFromArray(data, isNegative, 0, 3); // 2
566
+ * ```
567
+ */
568
+ export function removeAllWhereFromArray<T>(
569
+ array: T[],
570
+ fn: (value: T, index: number) => boolean,
571
+ start = 0,
572
+ stop = -1,
573
+ ): number {
574
+ const n = array.length;
575
+ let arrStart = start;
576
+ let arrStop = stop;
577
+ if (n === 0) {
578
+ return 0;
579
+ }
580
+ if (arrStart < 0) {
581
+ arrStart = Math.max(0, arrStart + n);
582
+ } else {
583
+ arrStart = Math.min(arrStart, n - 1);
584
+ }
585
+ if (arrStop < 0) {
586
+ arrStop = Math.max(0, arrStop + n);
587
+ } else {
588
+ arrStop = Math.min(arrStop, n - 1);
589
+ }
590
+ let count = 0;
591
+ for (let i = 0; i < n; ++i) {
592
+ if (arrStart <= arrStop && i >= arrStart && i <= arrStop && fn(array[i], i)) {
593
+ count++;
594
+ } else if (
595
+ arrStop < arrStart &&
596
+ (i <= arrStop || i >= arrStart) &&
597
+ fn(array[i], i)
598
+ ) {
599
+ count++;
600
+ } else if (count > 0) {
601
+ array[i - count] = array[i];
602
+ }
603
+ }
604
+ if (count > 0) {
605
+ array.length = n - count;
606
+ }
607
+ return count;
608
+ }
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+
3
+ export const DisplayWrapComponent: React.FC<{
4
+ children: any;
5
+ mode: boolean | undefined;
6
+ }> = ({ children, mode }) => {
7
+ if (mode) {
8
+ return null;
9
+ }
10
+ return <div>{children}</div>;
11
+ };
package/src/index.ts ADDED
@@ -0,0 +1,10 @@
1
+ export * from './array.js';
2
+ export * from './iter.js';
3
+ export * from './json.js';
4
+ export * from './utils.js';
5
+ export * from './sanitizer.js';
6
+ export * from './url.js';
7
+ export * from './path.js';
8
+ export * from './polling/index.js';
9
+ export * from './display-wrapper.js';
10
+ export * from './protocol/index.js';