@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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-present Difizen Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
File without changes
package/es/array.d.ts ADDED
@@ -0,0 +1,368 @@
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 declare function firstIndexOfArray<T>(array: ArrayLike<T>, value: T, start?: number, stop?: number): number;
41
+ /**
42
+ * Find the index of the first value which matches a predicate.
43
+ *
44
+ * @param array - The array-like object to search.
45
+ *
46
+ * @param fn - The predicate function to apply to the values.
47
+ *
48
+ * @param start - The index of the first element in the range to be
49
+ * searched, inclusive. The default value is `0`. Negative values
50
+ * are taken as an offset from the end of the array.
51
+ *
52
+ * @param stop - The index of the last element in the range to be
53
+ * searched, inclusive. The default value is `-1`. Negative values
54
+ * are taken as an offset from the end of the array.
55
+ *
56
+ * @returns The index of the first matching value, or `-1` if no
57
+ * matching value is found.
58
+ *
59
+ * #### Notes
60
+ * If `stop < start` the search will wrap at the end of the array.
61
+ *
62
+ * #### Complexity
63
+ * Linear.
64
+ *
65
+ * #### Undefined Behavior
66
+ * A `start` or `stop` which is non-integral.
67
+ *
68
+ * Modifying the length of the array while searching.
69
+ *
70
+ * #### Example
71
+ * ```typescript
72
+ *
73
+ * function isEven(value: number): boolean {
74
+ * return value % 2 === 0;
75
+ * }
76
+ *
77
+ * let data = [1, 2, 3, 4, 3, 2, 1];
78
+ * findFirstArrayIndex(data, isEven); // 1
79
+ * findFirstArrayIndex(data, isEven, 4); // 5
80
+ * findFirstArrayIndex(data, isEven, 6); // -1
81
+ * findFirstArrayIndex(data, isEven, 6, 5); // 1
82
+ * ```
83
+ */
84
+ export declare function findFirstArrayIndex<T>(array: ArrayLike<T>, fn: (value: T, index: number) => boolean, start?: number, stop?: number): number;
85
+ /**
86
+ * Find the index of the last value which matches a predicate.
87
+ *
88
+ * @param object - The array-like object to search.
89
+ *
90
+ * @param fn - The predicate function to apply to the values.
91
+ *
92
+ * @param start - The index of the first element in the range to be
93
+ * searched, inclusive. The default value is `-1`. Negative values
94
+ * are taken as an offset from the end of the array.
95
+ *
96
+ * @param stop - The index of the last element in the range to be
97
+ * searched, inclusive. The default value is `0`. Negative values
98
+ * are taken as an offset from the end of the array.
99
+ *
100
+ * @returns The index of the last matching value, or `-1` if no
101
+ * matching value is found.
102
+ *
103
+ * #### Notes
104
+ * If `start < stop` the search will wrap at the front of the array.
105
+ *
106
+ * #### Complexity
107
+ * Linear.
108
+ *
109
+ * #### Undefined Behavior
110
+ * A `start` or `stop` which is non-integral.
111
+ *
112
+ * Modifying the length of the array while searching.
113
+ *
114
+ * #### Example
115
+ * ```typescript
116
+ *
117
+ * function isEven(value: number): boolean {
118
+ * return value % 2 === 0;
119
+ * }
120
+ *
121
+ * let data = [1, 2, 3, 4, 3, 2, 1];
122
+ * findLastArrayIndex(data, isEven); // 5
123
+ * findLastArrayIndex(data, isEven, 4); // 3
124
+ * findLastArrayIndex(data, isEven, 0); // -1
125
+ * findLastArrayIndex(data, isEven, 0, 1); // 5
126
+ * ```
127
+ */
128
+ export declare function findLastArrayIndex<T>(array: ArrayLike<T>, fn: (value: T, index: number) => boolean, start?: number, stop?: number): number;
129
+ /**
130
+ * Find the first value which matches a predicate.
131
+ *
132
+ * @param array - The array-like object to search.
133
+ *
134
+ * @param fn - The predicate function to apply to the values.
135
+ *
136
+ * @param start - The index of the first element in the range to be
137
+ * searched, inclusive. The default value is `0`. Negative values
138
+ * are taken as an offset from the end of the array.
139
+ *
140
+ * @param stop - The index of the last element in the range to be
141
+ * searched, inclusive. The default value is `-1`. Negative values
142
+ * are taken as an offset from the end of the array.
143
+ *
144
+ * @returns The first matching value, or `undefined` if no matching
145
+ * value is found.
146
+ *
147
+ * #### Notes
148
+ * If `stop < start` the search will wrap at the end of the array.
149
+ *
150
+ * #### Complexity
151
+ * Linear.
152
+ *
153
+ * #### Undefined Behavior
154
+ * A `start` or `stop` which is non-integral.
155
+ *
156
+ * Modifying the length of the array while searching.
157
+ *
158
+ * #### Example
159
+ * ```typescript
160
+ *
161
+ * function isEven(value: number): boolean {
162
+ * return value % 2 === 0;
163
+ * }
164
+ *
165
+ * let data = [1, 2, 3, 4, 3, 2, 1];
166
+ * findFirstArrayValue(data, isEven); // 2
167
+ * findFirstArrayValue(data, isEven, 2); // 4
168
+ * findFirstArrayValue(data, isEven, 6); // undefined
169
+ * findFirstArrayValue(data, isEven, 6, 5); // 2
170
+ * ```
171
+ */
172
+ export declare function findFirstArrayValue<T>(array: ArrayLike<T>, fn: (value: T, index: number) => boolean, start?: number, stop?: number): T | undefined;
173
+ /**
174
+ * Find the last value which matches a predicate.
175
+ *
176
+ * @param object - The array-like object to search.
177
+ *
178
+ * @param fn - The predicate function to apply to the values.
179
+ *
180
+ * @param start - The index of the first element in the range to be
181
+ * searched, inclusive. The default value is `-1`. Negative values
182
+ * are taken as an offset from the end of the array.
183
+ *
184
+ * @param stop - The index of the last element in the range to be
185
+ * searched, inclusive. The default value is `0`. Negative values
186
+ * are taken as an offset from the end of the array.
187
+ *
188
+ * @returns The last matching value, or `undefined` if no matching
189
+ * value is found.
190
+ *
191
+ * #### Notes
192
+ * If `start < stop` the search will wrap at the front of the array.
193
+ *
194
+ * #### Complexity
195
+ * Linear.
196
+ *
197
+ * #### Undefined Behavior
198
+ * A `start` or `stop` which is non-integral.
199
+ *
200
+ * Modifying the length of the array while searching.
201
+ *
202
+ * #### Example
203
+ * ```typescript
204
+ *
205
+ * function isEven(value: number): boolean {
206
+ * return value % 2 === 0;
207
+ * }
208
+ *
209
+ * let data = [1, 2, 3, 4, 3, 2, 1];
210
+ * findLastArrayValue(data, isEven); // 2
211
+ * findLastArrayValue(data, isEven, 4); // 4
212
+ * findLastArrayValue(data, isEven, 0); // undefined
213
+ * findLastArrayValue(data, isEven, 0, 1); // 2
214
+ * ```
215
+ */
216
+ export declare function findLastArrayValue<T>(array: ArrayLike<T>, fn: (value: T, index: number) => boolean, start?: number, stop?: number): T | undefined;
217
+ /**
218
+ * Find the index of the first element which compares `>=` to a value.
219
+ *
220
+ * @param array - The sorted array-like object to search.
221
+ *
222
+ * @param value - The value to locate in the array.
223
+ *
224
+ * @param fn - The 3-way comparison function to apply to the values.
225
+ * It should return `< 0` if an element is less than a value, `0` if
226
+ * an element is equal to a value, or `> 0` if an element is greater
227
+ * than a value.
228
+ *
229
+ * @param start - The index of the first element in the range to be
230
+ * searched, inclusive. The default value is `0`. Negative values
231
+ * are taken as an offset from the end of the array.
232
+ *
233
+ * @param stop - The index of the last element in the range to be
234
+ * searched, inclusive. The default value is `-1`. Negative values
235
+ * are taken as an offset from the end of the array.
236
+ *
237
+ * @returns The index of the first element which compares `>=` to the
238
+ * value, or `length` if there is no such element. If the computed
239
+ * index for `stop` is less than `start`, then the computed index
240
+ * for `start` is returned.
241
+ *
242
+ * #### Notes
243
+ * The array must already be sorted in ascending order according to
244
+ * the comparison function.
245
+ *
246
+ * #### Complexity
247
+ * Logarithmic.
248
+ *
249
+ * #### Undefined Behavior
250
+ * Searching a range which is not sorted in ascending order.
251
+ *
252
+ * A `start` or `stop` which is non-integral.
253
+ *
254
+ * Modifying the length of the array while searching.
255
+ *
256
+ * #### Example
257
+ * ```typescript
258
+ *
259
+ * function numberCmp(a: number, b: number): number {
260
+ * return a - b;
261
+ * }
262
+ *
263
+ * let data = [0, 3, 4, 7, 7, 9];
264
+ * lowerArrayBound(data, 0, numberCmp); // 0
265
+ * lowerArrayBound(data, 6, numberCmp); // 3
266
+ * lowerArrayBound(data, 7, numberCmp); // 3
267
+ * lowerArrayBound(data, -1, numberCmp); // 0
268
+ * lowerArrayBound(data, 10, numberCmp); // 6
269
+ * ```
270
+ */
271
+ export declare function lowerArrayBound<T, U>(array: ArrayLike<T>, value: U, fn: (element: T, value: U) => number, start?: number, stop?: number): number;
272
+ /**
273
+ * Find the index of the first element which compares `>` than a value.
274
+ *
275
+ * @param array - The sorted array-like object to search.
276
+ *
277
+ * @param value - The value to locate in the array.
278
+ *
279
+ * @param fn - The 3-way comparison function to apply to the values.
280
+ * It should return `< 0` if an element is less than a value, `0` if
281
+ * an element is equal to a value, or `> 0` if an element is greater
282
+ * than a value.
283
+ *
284
+ * @param start - The index of the first element in the range to be
285
+ * searched, inclusive. The default value is `0`. Negative values
286
+ * are taken as an offset from the end of the array.
287
+ *
288
+ * @param stop - The index of the last element in the range to be
289
+ * searched, inclusive. The default value is `-1`. Negative values
290
+ * are taken as an offset from the end of the array.
291
+ *
292
+ * @returns The index of the first element which compares `>` than the
293
+ * value, or `length` if there is no such element. If the computed
294
+ * index for `stop` is less than `start`, then the computed index
295
+ * for `start` is returned.
296
+ *
297
+ * #### Notes
298
+ * The array must already be sorted in ascending order according to
299
+ * the comparison function.
300
+ *
301
+ * #### Complexity
302
+ * Logarithmic.
303
+ *
304
+ * #### Undefined Behavior
305
+ * Searching a range which is not sorted in ascending order.
306
+ *
307
+ * A `start` or `stop` which is non-integral.
308
+ *
309
+ * Modifying the length of the array while searching.
310
+ *
311
+ * #### Example
312
+ * ```typescript
313
+ *
314
+ * function numberCmp(a: number, b: number): number {
315
+ * return a - b;
316
+ * }
317
+ *
318
+ * let data = [0, 3, 4, 7, 7, 9];
319
+ * upperArrayBound(data, 0, numberCmp); // 1
320
+ * upperArrayBound(data, 6, numberCmp); // 3
321
+ * upperArrayBound(data, 7, numberCmp); // 5
322
+ * upperArrayBound(data, -1, numberCmp); // 0
323
+ * upperArrayBound(data, 10, numberCmp); // 6
324
+ * ```
325
+ */
326
+ export declare function upperArrayBound<T, U>(array: ArrayLike<T>, value: U, fn: (element: T, value: U) => number, start?: number, stop?: number): number;
327
+ /**
328
+ * Remove all occurrences of values which match a predicate.
329
+ *
330
+ * @param array - The array of interest.
331
+ *
332
+ * @param fn - The predicate function to apply to the values.
333
+ *
334
+ * @param start - The index of the first element in the range to be
335
+ * searched, inclusive. The default value is `0`. Negative values
336
+ * are taken as an offset from the end of the array.
337
+ *
338
+ * @param stop - The index of the last element in the range to be
339
+ * searched, inclusive. The default value is `-1`. Negative values
340
+ * are taken as an offset from the end of the array.
341
+ *
342
+ * @returns The number of elements removed from the array.
343
+ *
344
+ * #### Notes
345
+ * If `stop < start` the search will conceptually wrap at the end of
346
+ * the array, however the array will be traversed front-to-back.
347
+ *
348
+ * #### Complexity
349
+ * Linear.
350
+ *
351
+ * #### Example
352
+ * ```typescript
353
+ *
354
+ * function isEven(value: number): boolean {
355
+ * return value % 2 === 0;
356
+ * }
357
+ *
358
+ * function isNegative(value: number): boolean {
359
+ * return value < 0;
360
+ * }
361
+ *
362
+ * let data = [0, 12, -13, -9, 23, 39, 14, -15, 12, 75];
363
+ * removeAllWhereFromArray(data, isEven); // 4
364
+ * removeAllWhereFromArray(data, isNegative, 0, 3); // 2
365
+ * ```
366
+ */
367
+ export declare function removeAllWhereFromArray<T>(array: T[], fn: (value: T, index: number) => boolean, start?: number, stop?: number): number;
368
+ //# sourceMappingURL=array.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../src/array.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EACnB,KAAK,EAAE,CAAC,EACR,KAAK,SAAI,EACT,IAAI,SAAK,GACR,MAAM,CA8BR;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EACnB,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,EACxC,KAAK,SAAI,EACT,IAAI,SAAK,GACR,MAAM,CA8BR;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EACnB,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,EACxC,KAAK,SAAK,EACV,IAAI,SAAI,GACP,MAAM,CA+BR;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EACnB,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,EACxC,KAAK,SAAI,EACT,IAAI,SAAK,GACR,CAAC,GAAG,SAAS,CAGf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EACnB,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,EACxC,KAAK,SAAK,EACV,IAAI,SAAI,GACP,CAAC,GAAG,SAAS,CAGf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,CAAC,EAClC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EACnB,KAAK,EAAE,CAAC,EACR,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,MAAM,EACpC,KAAK,SAAI,EACT,IAAI,SAAK,GACR,MAAM,CA8BR;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,CAAC,EAClC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EACnB,KAAK,EAAE,CAAC,EACR,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,MAAM,EACpC,KAAK,SAAI,EACT,IAAI,SAAK,GACR,MAAM,CA8BR;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EACvC,KAAK,EAAE,CAAC,EAAE,EACV,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,EACxC,KAAK,SAAI,EACT,IAAI,SAAK,GACR,MAAM,CAmCR"}