@difizen/libro-common 0.1.0 → 0.1.2
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 +368 -0
- package/es/array.d.ts.map +1 -0
- package/es/display-wrapper.d.ts +6 -0
- package/es/display-wrapper.d.ts.map +1 -0
- package/es/dom.d.ts +3 -0
- package/es/dom.d.ts.map +1 -0
- package/es/dom.js +97 -0
- package/es/index.d.ts +12 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +2 -1
- package/es/iter.d.ts +147 -0
- package/es/iter.d.ts.map +1 -0
- package/es/json.d.ts +126 -0
- package/es/json.d.ts.map +1 -0
- package/es/path.d.ts +97 -0
- package/es/path.d.ts.map +1 -0
- package/es/polling/index.d.ts +3 -0
- package/es/polling/index.d.ts.map +1 -0
- package/es/polling/poll.d.ts +193 -0
- package/es/polling/poll.d.ts.map +1 -0
- package/es/polling/poll.js +1 -1
- package/es/polling/protocol.d.ts +120 -0
- package/es/polling/protocol.d.ts.map +1 -0
- package/es/posix.d.ts +2 -0
- package/es/posix.d.ts.map +1 -0
- package/es/protocol/cell-protocol.d.ts +181 -0
- package/es/protocol/cell-protocol.d.ts.map +1 -0
- package/es/protocol/index.d.ts +4 -0
- package/es/protocol/index.d.ts.map +1 -0
- package/es/protocol/notebook-protocol.d.ts +63 -0
- package/es/protocol/notebook-protocol.d.ts.map +1 -0
- package/es/protocol/output-protocol.d.ts +125 -0
- package/es/protocol/output-protocol.d.ts.map +1 -0
- package/es/sanitizer.d.ts +45 -0
- package/es/sanitizer.d.ts.map +1 -0
- package/es/url.d.ts +98 -0
- package/es/url.d.ts.map +1 -0
- package/es/url.js +1 -1
- package/es/utils.d.ts +57 -0
- package/es/utils.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/dom.ts +71 -0
- package/src/index.ts +1 -0
- package/src/iter.ts +2 -2
- package/src/polling/poll.ts +2 -2
- package/src/polling/protocol.ts +1 -1
- package/src/sanitizer.ts +15 -15
- package/src/url.ts +1 -1
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 @@
|
|
|
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/dom.d.ts
ADDED
package/es/dom.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,cAAc,WAAY,MAAM,SA0B5C,CAAC;AAgBF,eAAO,MAAM,iBAAiB,uBAgB7B,CAAC"}
|
package/es/dom.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
function copyFallback(string) {
|
|
6
|
+
function handler(event) {
|
|
7
|
+
var clipboardData = event.clipboardData || window.clipboardData;
|
|
8
|
+
clipboardData.setData('text/plain', string);
|
|
9
|
+
event.preventDefault();
|
|
10
|
+
document.removeEventListener('copy', handler, true);
|
|
11
|
+
}
|
|
12
|
+
document.addEventListener('copy', handler, true);
|
|
13
|
+
document.execCommand('copy');
|
|
14
|
+
}
|
|
15
|
+
// 复制到剪贴板
|
|
16
|
+
export var copy2clipboard = function copy2clipboard(string) {
|
|
17
|
+
navigator.permissions.query({
|
|
18
|
+
name: 'clipboard-write'
|
|
19
|
+
}).then(function (result) {
|
|
20
|
+
if (result.state === 'granted' || result.state === 'prompt') {
|
|
21
|
+
if (window.navigator && window.navigator.clipboard) {
|
|
22
|
+
window.navigator.clipboard.writeText(string).then(function () {
|
|
23
|
+
return;
|
|
24
|
+
}).catch(function (err) {
|
|
25
|
+
console.error('Could not copy text: ', err);
|
|
26
|
+
});
|
|
27
|
+
} else {
|
|
28
|
+
console.warn('navigator is not exist');
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
console.warn('浏览器权限不允许复制');
|
|
32
|
+
copyFallback(string);
|
|
33
|
+
}
|
|
34
|
+
return;
|
|
35
|
+
}).catch(console.error);
|
|
36
|
+
};
|
|
37
|
+
function readFallback() {
|
|
38
|
+
function handler(event) {
|
|
39
|
+
// 获取剪贴板数据
|
|
40
|
+
var clipboardData = event.clipboardData || window.clipboardData;
|
|
41
|
+
// 读取文本内容
|
|
42
|
+
var pastedData = clipboardData.getData('text/plain');
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
document.removeEventListener('paste', handler, true);
|
|
45
|
+
return pastedData;
|
|
46
|
+
}
|
|
47
|
+
document.addEventListener('paste', handler, true);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 从剪贴板读取
|
|
51
|
+
export var readFromClipboard = /*#__PURE__*/function () {
|
|
52
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
53
|
+
var clipboardValue, result;
|
|
54
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
55
|
+
while (1) switch (_context.prev = _context.next) {
|
|
56
|
+
case 0:
|
|
57
|
+
clipboardValue = '';
|
|
58
|
+
_context.next = 3;
|
|
59
|
+
return navigator.permissions.query({
|
|
60
|
+
name: 'clipboard-read'
|
|
61
|
+
});
|
|
62
|
+
case 3:
|
|
63
|
+
result = _context.sent;
|
|
64
|
+
if (!(result.state === 'granted' || result.state === 'prompt')) {
|
|
65
|
+
_context.next = 14;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
if (!(window.navigator && window.navigator.clipboard)) {
|
|
69
|
+
_context.next = 11;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
_context.next = 8;
|
|
73
|
+
return window.navigator.clipboard.readText();
|
|
74
|
+
case 8:
|
|
75
|
+
clipboardValue = _context.sent;
|
|
76
|
+
_context.next = 12;
|
|
77
|
+
break;
|
|
78
|
+
case 11:
|
|
79
|
+
console.warn('navigator is not exist');
|
|
80
|
+
case 12:
|
|
81
|
+
_context.next = 16;
|
|
82
|
+
break;
|
|
83
|
+
case 14:
|
|
84
|
+
console.warn('浏览器权限不允许粘贴');
|
|
85
|
+
readFallback();
|
|
86
|
+
case 16:
|
|
87
|
+
return _context.abrupt("return", clipboardValue);
|
|
88
|
+
case 17:
|
|
89
|
+
case "end":
|
|
90
|
+
return _context.stop();
|
|
91
|
+
}
|
|
92
|
+
}, _callee);
|
|
93
|
+
}));
|
|
94
|
+
return function readFromClipboard() {
|
|
95
|
+
return _ref.apply(this, arguments);
|
|
96
|
+
};
|
|
97
|
+
}();
|
package/es/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
export * from './dom.js';
|
|
12
|
+
//# 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;AACpC,cAAc,UAAU,CAAC"}
|
package/es/index.js
CHANGED
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
|
+
protected _index: number;
|
|
92
|
+
protected _source: ArrayLike<T>;
|
|
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
|