@difizen/libro-common 0.1.0 → 0.1.1

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/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"}
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export declare const DisplayWrapComponent: React.FC<{
3
+ children: any;
4
+ mode: boolean | undefined;
5
+ }>;
6
+ //# sourceMappingURL=display-wrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"display-wrapper.d.ts","sourceRoot":"","sources":["../src/display-wrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC;IAC1C,QAAQ,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;CAC3B,CAKA,CAAC"}
package/es/index.d.ts ADDED
@@ -0,0 +1,11 @@
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';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC"}
package/es/iter.d.ts ADDED
@@ -0,0 +1,147 @@
1
+ /**
2
+ * An object which can produce an iterator over its values.
3
+ */
4
+ export interface IIterable<T> {
5
+ /**
6
+ * Get an iterator over the object's values.
7
+ *
8
+ * @returns An iterator which yields the object's values.
9
+ *
10
+ * #### Notes
11
+ * Depending on the iterable, the returned iterator may or may not be
12
+ * a new object. A collection or other container-like object should
13
+ * typically return a new iterator, while an iterator itself should
14
+ * normally return `this`.
15
+ */
16
+ iter: () => IIterator<T>;
17
+ }
18
+ /**
19
+ * An object which traverses a collection of values.
20
+ *
21
+ * #### Notes
22
+ * An `IIterator` is itself an `IIterable`. Most implementations of
23
+ * `IIterator` should simply return `this` from the `iter()` method.
24
+ */
25
+ export interface IIterator<T> extends IIterable<T> {
26
+ /**
27
+ * Create an independent clone of the iterator.
28
+ *
29
+ * @returns A new independent clone of the iterator.
30
+ *
31
+ * #### Notes
32
+ * The cloned iterator can be consumed independently of the current
33
+ * iterator. In essence, it is a copy of the iterator value stream
34
+ * which starts at the current location.
35
+ *
36
+ * This can be useful for lookahead and stream duplication.
37
+ */
38
+ clone: () => IIterator<T>;
39
+ /**
40
+ * Get the next value from the iterator.
41
+ *
42
+ * @returns The next value from the iterator, or `undefined`.
43
+ *
44
+ * #### Notes
45
+ * The `undefined` value is used to signal the end of iteration and
46
+ * should therefore not be used as a value in a collection.
47
+ *
48
+ * The use of the `undefined` sentinel is an explicit design choice
49
+ * which favors performance over purity. The ES6 iterator design of
50
+ * returning a `{ value, done }` pair is suboptimal, as it requires
51
+ * an object allocation on each iteration; and an `isDone()` method
52
+ * would increase implementation and runtime complexity.
53
+ */
54
+ next: () => T | undefined;
55
+ }
56
+ /**
57
+ * A type alias for an iterable or builtin array-like object.
58
+ */
59
+ export type IterableOrArrayLike<T> = IIterable<T> | ArrayLike<T>;
60
+ /**
61
+ * An iterator for an array-like object.
62
+ *
63
+ * #### Notes
64
+ * This iterator can be used for any builtin JS array-like object.
65
+ */
66
+ export declare class ArrayIterator<T> implements IIterator<T> {
67
+ /**
68
+ * Construct a new array iterator.
69
+ *
70
+ * @param source - The array-like object of interest.
71
+ */
72
+ constructor(source: ArrayLike<T>);
73
+ /**
74
+ * Get an iterator over the object's values.
75
+ *
76
+ * @returns An iterator which yields the object's values.
77
+ */
78
+ iter(): IIterator<T>;
79
+ /**
80
+ * Create an independent clone of the iterator.
81
+ *
82
+ * @returns A new independent clone of the iterator.
83
+ */
84
+ clone(): IIterator<T>;
85
+ /**
86
+ * Get the next value from the iterator.
87
+ *
88
+ * @returns The next value from the iterator, or `undefined`.
89
+ */
90
+ next(): T | undefined;
91
+ private _index;
92
+ private _source;
93
+ }
94
+ /**
95
+ * Create an iterator for an iterable object.
96
+ *
97
+ * @param object - The iterable or array-like object of interest.
98
+ *
99
+ * @returns A new iterator for the given object.
100
+ *
101
+ * #### Notes
102
+ * This function allows iteration algorithms to operate on user-defined
103
+ * iterable types and builtin array-like objects in a uniform fashion.
104
+ */
105
+ export declare function iter<T>(object: IterableOrArrayLike<T>): IIterator<T>;
106
+ /**
107
+ * Invoke a function for each value in an iterable.
108
+ *
109
+ * @param object - The iterable or array-like object of interest.
110
+ *
111
+ * @param fn - The callback function to invoke for each value.
112
+ *
113
+ * #### Notes
114
+ * Iteration can be terminated early by returning `false` from the
115
+ * callback function.
116
+ *
117
+ * #### Complexity
118
+ * Linear.
119
+ *
120
+ * #### Example
121
+ * ```typescript
122
+ *
123
+ * let data = [5, 7, 0, -2, 9];
124
+ *
125
+ * each(data, value => { console.log(value); });
126
+ * ```
127
+ */
128
+ export declare function each<T>(object: IterableOrArrayLike<T>, fn: (value: T, index: number) => boolean | void): void;
129
+ /**
130
+ * Create an array from an iterable of values.
131
+ *
132
+ * @param object - The iterable or array-like object of interest.
133
+ *
134
+ * @returns A new array of values from the given object.
135
+ *
136
+ * #### Example
137
+ * ```typescript
138
+ *
139
+ * let data = [1, 2, 3, 4, 5, 6];
140
+ *
141
+ * let stream = iter(data);
142
+ *
143
+ * toArray(stream); // [1, 2, 3, 4, 5, 6];
144
+ * ```
145
+ */
146
+ export declare function toArray<T>(object: IterableOrArrayLike<T>): T[];
147
+ //# sourceMappingURL=iter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iter.d.ts","sourceRoot":"","sources":["../src/iter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC;IAC1B;;;;;;;;;;OAUG;IACH,IAAI,EAAE,MAAM,SAAS,CAAC,CAAC,CAAC,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,SAAS,C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 /**
2
+ * A type alias for a JSON primitive.
3
+ */
4
+ export type JSONPrimitive = boolean | number | string | null;
5
+ /**
6
+ * A type alias for a JSON value.
7
+ */
8
+ export type JSONValue = JSONPrimitive | {
9
+ [key: string]: JSONValue;
10
+ } | JSONValue[];
11
+ /**
12
+ * A type definition for a JSON object.
13
+ */
14
+ export type JSONObject = Record<string, JSONValue>;
15
+ /**
16
+ * A type definition for a JSON array.
17
+ */
18
+ export type JSONArray = JSONValue[];
19
+ /**
20
+ * A type definition for a readonly JSON object.
21
+ */
22
+ export type ReadonlyJSONObject = Readonly<Record<string, ReadonlyJSONValue>>;
23
+ /**
24
+ * A type definition for a readonly JSON array.
25
+ */
26
+ export type ReadonlyJSONArray = readonly ReadonlyJSONValue[];
27
+ /**
28
+ * A type alias for a readonly JSON value.
29
+ */
30
+ export type ReadonlyJSONValue = JSONPrimitive | Readonly<{
31
+ [key: string]: ReadonlyJSONValue;
32
+ }> | readonly ReadonlyJSONValue[];
33
+ /**
34
+ * A type alias for a partial JSON value.
35
+ *
36
+ * Note: Partial here means that JSON object attributes can be `undefined`.
37
+ */
38
+ export type PartialJSONValue = JSONPrimitive | Partial<{
39
+ [key: string]: PartialJSONValue;
40
+ }> | PartialJSONValue[];
41
+ /**
42
+ * A type definition for a partial JSON array.
43
+ *
44
+ * Note: Partial here means that JSON object attributes can be `undefined`.
45
+ */
46
+ export type PartialJSONArray = PartialJSONValue[];
47
+ /**
48
+ * A type definition for a partial JSON object.
49
+ *
50
+ * Note: Partial here means that the JSON object attributes can be `undefined`.
51
+ */
52
+ export type PartialJSONObject = Record<string, PartialJSONValue | undefined>;
53
+ /**
54
+ * A type definition for a readonly partial JSON object.
55
+ *
56
+ * Note: Partial here means that JSON object attributes can be `undefined`.
57
+ */
58
+ export type ReadonlyPartialJSONObject = Readonly<Record<string, ReadonlyPartialJSONValue | undefined>>;
59
+ /**
60
+ * A type definition for a readonly partial JSON array.
61
+ *
62
+ * Note: Partial here means that JSON object attributes can be `undefined`.
63
+ */
64
+ export type ReadonlyPartialJSONArray = readonly ReadonlyPartialJSONValue[];
65
+ /**
66
+ * A type alias for a readonly partial JSON value.
67
+ *
68
+ * Note: Partial here means that JSON object attributes can be `undefined`.
69
+ */
70
+ export type ReadonlyPartialJSONValue = JSONPrimitive | {
71
+ readonly [key: string]: ReadonlyPartialJSONValue | undefined;
72
+ } | readonly ReadonlyPartialJSONValue[];
73
+ /**
74
+ * A shared frozen empty JSONObject
75
+ */
76
+ export declare const emptyObject: Readonly<Record<string, ReadonlyJSONValue>>;
77
+ /**
78
+ * A shared frozen empty JSONArray
79
+ */
80
+ export declare const emptyArray: ReadonlyJSONArray;
81
+ /**
82
+ * Test whether a JSON value is a primitive.
83
+ *
84
+ * @param value - The JSON value of interest.
85
+ *
86
+ * @returns `true` if the value is a primitive,`false` otherwise.
87
+ */
88
+ export declare function isPrimitive(value: ReadonlyPartialJSONValue): value is JSONPrimitive;
89
+ /**
90
+ * Test whether a JSON value is an array.
91
+ *
92
+ * @param value - The JSON value of interest.
93
+ *
94
+ * @returns `true` if the value is a an array, `false` otherwise.
95
+ */
96
+ export declare function isArray(value: JSONValue): value is JSONArray;
97
+ export declare function isArray(value: PartialJSONValue): value is PartialJSONArray;
98
+ export declare function isArray(value: ReadonlyPartialJSONValue): value is ReadonlyPartialJSONArray;
99
+ /**
100
+ * Test whether a JSON value is an object.
101
+ *
102
+ * @param value - The JSON value of interest.
103
+ *
104
+ * @returns `true` if the value is a an object, `false` otherwise.
105
+ */
106
+ export declare function isObject(value: JSONValue): value is JSONObject;
107
+ export declare function isObject(value: PartialJSONValue): value is PartialJSONObject;
108
+ /**
109
+ * Compare two JSON values for deep equality.
110
+ *
111
+ * @param first - The first JSON value of interest.
112
+ *
113
+ * @param second - The second JSON value of interest.
114
+ *
115
+ * @returns `true` if the values are equivalent, `false` otherwise.
116
+ */
117
+ export declare function deepEqual(first: ReadonlyPartialJSONValue, second: ReadonlyPartialJSONValue): boolean;
118
+ /**
119
+ * Create a deep copy of a JSON value.
120
+ *
121
+ * @param value - The JSON value to copy.
122
+ *
123
+ * @returns A deep copy of the given JSON value.
124
+ */
125
+ export declare function deepCopy<T extends ReadonlyPartialJSONValue>(value: T): T;
126
+ //# sourceMappingURL=json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAAG,SAAS,EAAE,CAAC;AAEnF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,EAAE,CAAC;AAEpC;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAE7E;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,SAAS,iBAAiB,EAAE,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB,aAAa,GACb,QAAQ,CAAC;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAAA;CAAE,CAAC,GAC9C,SAAS,iBAAiB,EAAE,CAAC;AAEjC;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,OAAO,CAAC;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAA;CAAE,CAAC,GAC5C,gBAAgB,EAAE,CAAC;AAEvB;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,EAAE,CAAC;AAElD;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,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