@yorozu/utils 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/lib/index.d.ts ADDED
@@ -0,0 +1,468 @@
1
+ type TypesAreEqual<T, V> = (() => T) extends () => V ? ((() => V) extends () => T ? true : false) : false;
2
+
3
+ declare function unknownToError(err: unknown): Error;
4
+ declare class NotImplementedError extends Error {
5
+ constructor(message?: string, options?: ErrorOptions);
6
+ }
7
+ declare function throwNotImplemented(message?: string, options?: ErrorOptions): never;
8
+ declare function throwUnreachable(): never;
9
+
10
+ type NoneToVoidFunction = () => void;
11
+ type AnyFunction = (...args: any[]) => any;
12
+ type AnyToVoidFunction = (...args: any[]) => void;
13
+ type AnyToNever<T> = any extends T ? never : T;
14
+ type MaybePromise<T> = Promise<T> | T;
15
+ type MaybeArray<T> = Array<T> | T;
16
+ type Values<T> = T[keyof T];
17
+ type Truthy<T> = T extends false | "" | 0 | null | undefined ? never : T;
18
+ type UnsafeMutate<T> = {
19
+ -readonly [P in keyof T]: T[P];
20
+ };
21
+
22
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
23
+ type LastOfUnion<U> = UnionToIntersection<U extends any ? () => U : never> extends () => infer R ? R : never;
24
+ type UnionToTuple<U, Acc extends Array<any> = [], L = LastOfUnion<U>> = [U] extends [never] ? Acc : UnionToTuple<Exclude<U, L>, [L, ...Acc]>;
25
+
26
+ type TypedArray = Uint8Array | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | AnyToNever<BigInt64Array> | AnyToNever<BigUint64Array>;
27
+
28
+ declare function compare<T extends TypedArray>(a: T, b: T): -1 | 0 | 1;
29
+ declare function equal<T extends TypedArray>(a: T, b: T): boolean;
30
+
31
+ declare function indexOf(haystack: Exclude<TypedArray, BigInt64Array | BigUint64Array>, needle: number, start?: number): number;
32
+ declare function indexOf(haystack: BigInt64Array | BigUint64Array, needle: bigint, start?: number): number;
33
+ declare function lastIndexOf(haystack: Exclude<TypedArray, BigInt64Array | BigUint64Array>, needle: number, start: number): number;
34
+ declare function lastIndexOf(haystack: BigInt64Array | BigUint64Array, needle: bigint, start?: number): number;
35
+ declare function indexOfArray<T extends TypedArray>(haystack: T, needle: T, start?: number): number;
36
+ declare function lastIndexOfArray<T extends TypedArray>(haystack: T, needle: T, start?: number): number;
37
+ declare function includes(haystack: Exclude<TypedArray, BigInt64Array | BigUint64Array>, needle: number): boolean;
38
+ declare function includes(haystack: BigInt64Array | BigUint64Array, needle: bigint): boolean;
39
+ declare function includesArray<T extends TypedArray>(haystack: T, needle: T): boolean;
40
+
41
+ declare function toDataView(buf: TypedArray): DataView;
42
+ declare function view<R extends TypedArray>(ctor: {
43
+ new (buffer: ArrayBufferLike, byteOffset: number, byteLength: number): R;
44
+ BYTES_PER_ELEMENT: number;
45
+ }, buf: ArrayBufferView): R;
46
+ declare function getPlatformByteOrder(): "little" | "big";
47
+ declare namespace getPlatformByteOrder {
48
+ var _cachedByteOrder: boolean | null;
49
+ }
50
+
51
+ type index$1_TypedArray = TypedArray;
52
+ declare const index$1_compare: typeof compare;
53
+ declare const index$1_equal: typeof equal;
54
+ declare const index$1_getPlatformByteOrder: typeof getPlatformByteOrder;
55
+ declare const index$1_includes: typeof includes;
56
+ declare const index$1_includesArray: typeof includesArray;
57
+ declare const index$1_indexOf: typeof indexOf;
58
+ declare const index$1_indexOfArray: typeof indexOfArray;
59
+ declare const index$1_lastIndexOf: typeof lastIndexOf;
60
+ declare const index$1_lastIndexOfArray: typeof lastIndexOfArray;
61
+ declare const index$1_toDataView: typeof toDataView;
62
+ declare const index$1_view: typeof view;
63
+ declare namespace index$1 {
64
+ export { type index$1_TypedArray as TypedArray, index$1_compare as compare, index$1_equal as equal, index$1_getPlatformByteOrder as getPlatformByteOrder, index$1_includes as includes, index$1_includesArray as includesArray, index$1_indexOf as indexOf, index$1_indexOfArray as indexOfArray, index$1_lastIndexOf as lastIndexOf, index$1_lastIndexOfArray as lastIndexOfArray, index$1_toDataView as toDataView, index$1_view as view };
65
+ }
66
+
67
+ declare function concat(bufs: Array<Uint8Array>): Uint8Array;
68
+ declare function concat2(a: ArrayLike<number>, b: ArrayLike<number>): Uint8Array;
69
+ declare function concat3(a: ArrayLike<number>, b: ArrayLike<number>, c: ArrayLike<number>): Uint8Array;
70
+
71
+ declare const empty: Uint8Array;
72
+ declare function clone(buf: Uint8Array): Uint8Array;
73
+ declare function readNthBit(byte: number, bit: number): number;
74
+
75
+ declare class BufferPool {
76
+ #private;
77
+ readonly size: number;
78
+ readonly maxAllocSize: number;
79
+ constructor(size?: number);
80
+ allocate(size: number): Uint8Array;
81
+ reset(): void;
82
+ }
83
+ declare function setDefaultPool(size: number): void;
84
+ declare function allocate(size: number): Uint8Array;
85
+ declare function allocateWith(init: ArrayLike<number>): Uint8Array;
86
+
87
+ declare function reverse(buffer: Uint8Array): void;
88
+ declare function toReversed(buffer: ArrayLike<number>): Uint8Array;
89
+
90
+ declare function swap16(buf: Uint8Array): void;
91
+ declare function swap32(buf: Uint8Array): void;
92
+ declare function swap64(buf: Uint8Array): void;
93
+ declare function swapNibbles(buf: Uint8Array): void;
94
+
95
+ declare function xor(data: Uint8Array, key: Uint8Array): Uint8Array;
96
+ declare function xorInPlace(data: Uint8Array, key: Uint8Array): void;
97
+
98
+ type index_BufferPool = BufferPool;
99
+ declare const index_BufferPool: typeof BufferPool;
100
+ declare const index_allocate: typeof allocate;
101
+ declare const index_allocateWith: typeof allocateWith;
102
+ declare const index_clone: typeof clone;
103
+ declare const index_concat: typeof concat;
104
+ declare const index_concat2: typeof concat2;
105
+ declare const index_concat3: typeof concat3;
106
+ declare const index_empty: typeof empty;
107
+ declare const index_readNthBit: typeof readNthBit;
108
+ declare const index_reverse: typeof reverse;
109
+ declare const index_setDefaultPool: typeof setDefaultPool;
110
+ declare const index_swap16: typeof swap16;
111
+ declare const index_swap32: typeof swap32;
112
+ declare const index_swap64: typeof swap64;
113
+ declare const index_swapNibbles: typeof swapNibbles;
114
+ declare const index_toReversed: typeof toReversed;
115
+ declare const index_xor: typeof xor;
116
+ declare const index_xorInPlace: typeof xorInPlace;
117
+ declare namespace index {
118
+ export { index_BufferPool as BufferPool, index_allocate as allocate, index_allocateWith as allocateWith, index_clone as clone, index_concat as concat, index_concat2 as concat2, index_concat3 as concat3, index_empty as empty, index_readNthBit as readNthBit, index_reverse as reverse, index_setDefaultPool as setDefaultPool, index_swap16 as swap16, index_swap32 as swap32, index_swap64 as swap64, index_swapNibbles as swapNibbles, index_toReversed as toReversed, index_xor as xor, index_xorInPlace as xorInPlace };
119
+ }
120
+
121
+ declare function toBytes(value: bigint, length?: number, le?: boolean): Uint8Array;
122
+ declare function fromBytes(buffer: Uint8Array, le?: boolean): bigint;
123
+
124
+ declare function bitLength(n: bigint): number;
125
+ declare function twoMultiplicity(n: bigint): bigint;
126
+ declare function min2(a: bigint, b: bigint): bigint;
127
+ declare function min(...args: Array<bigint>): bigint;
128
+ declare function max2(a: bigint, b: bigint): bigint;
129
+ declare function max(...args: Array<bigint>): bigint;
130
+ declare function abs(a: bigint): bigint;
131
+ declare function euclideanGcd(a: bigint, b: bigint): bigint;
132
+ declare function modPowBinary(base: bigint, exp: bigint, mod: bigint): bigint;
133
+ declare function modInv(a: bigint, n: bigint): bigint;
134
+
135
+ declare const lookup: Map<number, number>;
136
+ declare const encodeLookup: Map<number, number>;
137
+ declare function decode$1(data: string, url?: boolean): Uint8Array;
138
+ declare function encode$1(bytes: Uint8Array, url?: boolean): string;
139
+ declare function encodedLength$2(n: number): number;
140
+ declare function decodedLength$1(n: number): number;
141
+
142
+ declare const base64_encodeLookup: typeof encodeLookup;
143
+ declare const base64_lookup: typeof lookup;
144
+ declare namespace base64 {
145
+ export { decode$1 as decode, decodedLength$1 as decodedLength, encode$1 as encode, base64_encodeLookup as encodeLookup, encodedLength$2 as encodedLength, base64_lookup as lookup };
146
+ }
147
+
148
+ declare function encode(buf: Uint8Array): string;
149
+ declare function decode(data: string): Uint8Array;
150
+ declare function encodedLength$1(n: number): number;
151
+ declare function decodedLength(n: number): number;
152
+
153
+ declare const hex_decode: typeof decode;
154
+ declare const hex_decodedLength: typeof decodedLength;
155
+ declare const hex_encode: typeof encode;
156
+ declare namespace hex {
157
+ export { hex_decode as decode, hex_decodedLength as decodedLength, hex_encode as encode, encodedLength$1 as encodedLength };
158
+ }
159
+
160
+ declare const encoder: TextEncoder;
161
+ declare const decoder: TextDecoder;
162
+ declare function encodedLength(data: string): number;
163
+
164
+ declare const utf8_decoder: typeof decoder;
165
+ declare const utf8_encodedLength: typeof encodedLength;
166
+ declare const utf8_encoder: typeof encoder;
167
+ declare namespace utf8 {
168
+ export { utf8_decoder as decoder, utf8_encodedLength as encodedLength, utf8_encoder as encoder };
169
+ }
170
+
171
+ declare function enumerate<T>(iterable: Iterable<T>): IterableIterator<[number, T]>;
172
+
173
+ declare const brand: unique symbol;
174
+ type Brand<T, Name extends string> = T & {
175
+ [brand]: Name;
176
+ };
177
+
178
+ declare function assert(condition: boolean, message?: unknown): asserts condition;
179
+ declare function assertHashKey<Obj extends object, Key extends string>(obj: Obj, key: Key): asserts obj is Obj & Record<Key, unknown>;
180
+ declare function unsafeCastType<T>(value: unknown): asserts value is T;
181
+ declare function assertNotNull<T>(value: T): asserts value is Exclude<T, null | undefined>;
182
+ declare function asNonNull<T>(value: null extends T ? T : undefined extends T ? T : Brand<"type is not nullable", "TypeError">): Exclude<T, null | undefined>;
183
+ declare function assertMatches(str: string, regex: RegExp): RegExpMatchArray;
184
+
185
+ type Middleware<C, R = void> = (ctx: C, next: (ctx: C) => Promise<R>) => Promise<R>;
186
+ type ComposedMiddleware<C, R = void> = (ctx: C) => Promise<R>;
187
+ declare function composeMiddlewares<C, R = void>(middlewares: Array<Middleware<C, R>>, final: ComposedMiddleware<C, R>): ComposedMiddleware<C, R>;
188
+ declare function composeMiddlewares<C, R = void>(middlewares: Array<Middleware<C, R>>): Middleware<C, R>;
189
+
190
+ declare const isNotUndefined: <T>(val: T) => val is Exclude<T, undefined>;
191
+ declare const isNotNull: <T>(val: T) => val is Exclude<T, null>;
192
+ declare const isBoolean: (val: any) => val is boolean;
193
+ declare const isTruthy: <T>(val: T) => val is Truthy<T>;
194
+ declare const isFalsy: <T>(val: T) => val is Exclude<T, Truthy<T>>;
195
+ declare const isFunction: (val: any) => val is AnyFunction;
196
+ declare const isNumber: (val: any) => val is number;
197
+ declare const isString: (val: unknown) => val is string;
198
+ declare const isSymbol: (val: any) => val is symbol;
199
+ declare const isBigInt: (val: any) => val is bigint;
200
+ declare const isObject: (val: any) => val is object;
201
+
202
+ declare function noop(): void;
203
+
204
+ declare function objectKeys<T extends object>(obj: T): Array<`${keyof T & (string | number | boolean | null | undefined)}`>;
205
+ declare function objectEntries<T extends object>(obj: T): Array<[keyof T, T[keyof T]]>;
206
+ declare function clearUndefinedInPlace<T extends object>(obj: T): void;
207
+ type MergeInsertions<T> = T extends object ? {
208
+ [K in keyof T]: MergeInsertions<T[K]>;
209
+ } : T;
210
+ type DeepMerge<F, S> = MergeInsertions<{
211
+ [K in keyof F | keyof S]: K extends keyof S & keyof F ? DeepMerge<F[K], S[K]> : K extends keyof S ? S[K] : K extends keyof F ? F[K] : never;
212
+ }>;
213
+ interface DeepMergeOptions {
214
+ undefined?: "replace" | "ignore";
215
+ properties?: "replace" | "ignore";
216
+ arrays?: "replace" | "ignore" | "merge";
217
+ objects?: "replace" | "ignore" | "merge";
218
+ }
219
+ declare function deepMerge<T extends object = object>(into: T, from: MaybeArray<T>, options?: DeepMergeOptions): T;
220
+ declare function deepMerge<T extends object = object, S extends object = T>(into: T, from: MaybeArray<S>, options?: DeepMergeOptions): DeepMerge<T, S>;
221
+
222
+ declare function splitOnce(str: string, separator: string): [string, string];
223
+ declare function assertStartsWith(str: string, prefix: string): asserts str is `${typeof prefix}${string}`;
224
+ declare function assertsEndsWith(str: string, suffix: string): asserts str is `${string}${typeof suffix}`;
225
+
226
+ type Timer = Brand<object, "Timer">;
227
+ type Interval = Brand<object, "Interval">;
228
+ declare const setTimeoutWrap: <T extends (...args: any[]) => any>(fn: T, ms: number, ...args: Parameters<T>) => Timer;
229
+ declare const setIntervalWrap: <T extends (...args: any[]) => any>(fn: T, ms: number, ...args: Parameters<T>) => Interval;
230
+ declare const clearTimeoutWrap: (timer?: Timer) => void;
231
+ declare const clearIntervalWrap: (timer?: Interval) => void;
232
+
233
+ type timers_Interval = Interval;
234
+ type timers_Timer = Timer;
235
+ declare namespace timers {
236
+ export { type timers_Interval as Interval, type timers_Timer as Timer, clearIntervalWrap as clearInterval, clearTimeoutWrap as clearTimeout, setIntervalWrap as setInterval, setTimeoutWrap as setTimeout };
237
+ }
238
+
239
+ declare class AsyncInterval {
240
+ #private;
241
+ constructor(handler: (abortSignal: AbortSignal) => Promise<void>, interval: number);
242
+ start(after?: number): void;
243
+ startNow(): void;
244
+ stop(): void;
245
+ onError(handler: (err: unknown) => void): void;
246
+ }
247
+
248
+ declare class AsyncLock {
249
+ private _queue;
250
+ acquire(): Promise<void>;
251
+ release(): void;
252
+ with<T>(func: () => Promise<T>): Promise<T>;
253
+ }
254
+
255
+ declare class CustomMap<ExternalKey, InternalKey, V> implements Map<ExternalKey, V> {
256
+ #private;
257
+ readonly clear: Map<ExternalKey, V>["clear"];
258
+ constructor(externalToInternal: (key: ExternalKey) => InternalKey, internalToExternal: (key: InternalKey) => ExternalKey);
259
+ get size(): number;
260
+ get [Symbol.toStringTag](): string;
261
+ getInternalMap(): Map<InternalKey, V>;
262
+ delete(key: ExternalKey): boolean;
263
+ forEach(cb: (value: V, key: ExternalKey, map: Map<ExternalKey, V>) => void, thisArg?: any): void;
264
+ get(key: ExternalKey): V | undefined;
265
+ has(key: ExternalKey): boolean;
266
+ set(key: ExternalKey, value: V): this;
267
+ getOrInsert(key: ExternalKey, value: V): ReturnType<Map<ExternalKey, V>["getOrInsert"]>;
268
+ getOrInsertComputed(key: ExternalKey, callback: (key: ExternalKey) => V): ReturnType<Map<ExternalKey, V>["getOrInsertComputed"]>;
269
+ entries(): ReturnType<Map<ExternalKey, V>["entries"]>;
270
+ keys(): ReturnType<Map<ExternalKey, V>["keys"]>;
271
+ values(): ReturnType<Map<ExternalKey, V>["values"]>;
272
+ [Symbol.iterator](): ReturnType<Map<ExternalKey, V>["entries"]>;
273
+ }
274
+
275
+ declare class CustomSet<ExternalKey, InternalKey> implements Set<ExternalKey> {
276
+ #private;
277
+ readonly clear: Set<ExternalKey>["clear"];
278
+ constructor(externalToInternal: (key: ExternalKey) => InternalKey, internalToExternal: (key: InternalKey) => ExternalKey);
279
+ get size(): number;
280
+ get [Symbol.toStringTag](): string;
281
+ add(value: ExternalKey): this;
282
+ delete(value: ExternalKey): boolean;
283
+ forEach(cb: (value: ExternalKey, value2: ExternalKey, set: Set<ExternalKey>) => void, thisArg?: any): void;
284
+ has(value: ExternalKey): boolean;
285
+ entries(): ReturnType<Set<ExternalKey>["entries"]>;
286
+ keys(): ReturnType<Set<ExternalKey>["keys"]>;
287
+ values(): ReturnType<Set<ExternalKey>["values"]>;
288
+ union<U>(other: Set<U>): Set<ExternalKey | U>;
289
+ intersection<U>(other: Set<U>): Set<ExternalKey & U>;
290
+ difference<U>(other: ReadonlySetLike<ExternalKey & U>): Set<ExternalKey>;
291
+ symmetricDifference<U>(other: Set<U>): Set<ExternalKey | U>;
292
+ isSubsetOf(other: ReadonlySetLike<ExternalKey>): boolean;
293
+ isSupersetOf(other: Set<ExternalKey>): boolean;
294
+ isDisjointFrom(other: Set<ExternalKey>): boolean;
295
+ [Symbol.iterator](): ReturnType<Set<ExternalKey>["keys"]>;
296
+ getInternalSet(): Set<InternalKey>;
297
+ }
298
+
299
+ interface DequeOptions {
300
+ capacity?: number;
301
+ }
302
+ declare class Deque<T> {
303
+ #private;
304
+ protected _list: Array<T | undefined>;
305
+ protected _head: number;
306
+ protected _tail: number;
307
+ protected _capacityMask: number;
308
+ protected _capacity?: number;
309
+ constructor(array?: ArrayLike<T>, options?: DequeOptions);
310
+ get length(): number;
311
+ isEmpty(): boolean;
312
+ at(index: number): T | undefined;
313
+ peekFront(): T | undefined;
314
+ peekBack(): T | undefined;
315
+ pushFront(item: T): number;
316
+ pushBack(item: T): number;
317
+ popFront(): T | undefined;
318
+ popBack(): T | undefined;
319
+ removeOne(idx: number): T | undefined;
320
+ removeBy(predicate: (item: T) => boolean): void;
321
+ clear(): void;
322
+ indexOf(item: T): number;
323
+ findIndex(predicate: (item: T) => boolean): number;
324
+ find(predicate: (item: T) => boolean): T | undefined;
325
+ includes(item: T): boolean;
326
+ toArray(): Array<T>;
327
+ [Symbol.iterator](): Iterator<T>;
328
+ }
329
+
330
+ interface TwoWayLinkedList<K, V> {
331
+ key: K;
332
+ value: V;
333
+ prev?: TwoWayLinkedList<K, V>;
334
+ next?: TwoWayLinkedList<K, V>;
335
+ }
336
+ declare class LruMap<K, V> {
337
+ #private;
338
+ constructor(capacity: number, MapImpl?: new () => Map<K, TwoWayLinkedList<K, V>>);
339
+ get size(): number;
340
+ get(key: K): V | undefined;
341
+ has(key: K): boolean;
342
+ set(key: K, value: V): void;
343
+ delete(key: K): void;
344
+ clear(): void;
345
+ }
346
+
347
+ declare class LruSet<T> {
348
+ #private;
349
+ constructor(capacity: number, SetImpl?: new () => Set<T>);
350
+ get size(): number;
351
+ add(value: T): void;
352
+ has(value: T): boolean;
353
+ clear(): void;
354
+ }
355
+
356
+ declare class AsyncQueue<T> {
357
+ #private;
358
+ readonly queue: Deque<T>;
359
+ readonly maxSize: number | undefined;
360
+ constructor(from?: ArrayLike<T> | Deque<T>, maxSize?: number);
361
+ get length(): number;
362
+ get isFull(): boolean;
363
+ get remainingCapacity(): number;
364
+ get ended(): boolean;
365
+ enqueue(item: T): Promise<void>;
366
+ tryEnqueue(item: T): boolean;
367
+ end(): void;
368
+ peek(): T | undefined;
369
+ next(): T | undefined;
370
+ nextOrWait(): Promise<T | undefined>;
371
+ [Symbol.asyncIterator](): AsyncIterableIterator<T>;
372
+ }
373
+
374
+ declare class Emitter<T> {
375
+ #private;
376
+ get length(): number;
377
+ add(listener: (value: T) => void): void;
378
+ forwardTo(emitter: Emitter<T>): void;
379
+ remove(listener: (value: T) => void): void;
380
+ emit(value: T): void;
381
+ once(listener: (value: T) => void): void;
382
+ listeners(): readonly ((value: T) => void)[];
383
+ clear(): void;
384
+ }
385
+
386
+ interface AsyncResourceContext<T> {
387
+ readonly current: T | null;
388
+ readonly currentFetchedAt: number;
389
+ readonly currentExpiresAt: number;
390
+ readonly isBackground: boolean;
391
+ readonly abort: AbortSignal | null;
392
+ }
393
+ interface AsyncResourceOptions<T> {
394
+ autoReload?: boolean;
395
+ authReloadAfter?: number;
396
+ swr?: boolean;
397
+ swrValidator?: (ctx: AsyncResourceContext<T>) => boolean;
398
+ fetcher: (ctx: AsyncResourceContext<T>) => Promise<{
399
+ data: T;
400
+ expiresIn: number;
401
+ }>;
402
+ onError?: (err: unknown, ctx: AsyncResourceContext<T>) => void;
403
+ }
404
+ declare class AsyncResource<T> {
405
+ #private;
406
+ readonly options: AsyncResourceOptions<T>;
407
+ readonly onUpdated: Emitter<AsyncResourceContext<T>>;
408
+ constructor(options: AsyncResourceOptions<T>);
409
+ get isStale(): boolean;
410
+ setData(data: T, expiresIn: number): void;
411
+ update(force?: boolean): Promise<void>;
412
+ get(): Promise<T | null>;
413
+ getCached(): T | null;
414
+ destroy(): void;
415
+ }
416
+
417
+ declare class ConditionVariable {
418
+ #private;
419
+ wait(): Promise<void>;
420
+ notify(): void;
421
+ }
422
+
423
+ declare class Deferred<T = void> {
424
+ readonly resolve: (value: T) => void;
425
+ readonly reject: (reason: unknown) => void;
426
+ readonly promise: Promise<T>;
427
+ constructor();
428
+ }
429
+ declare class DeferredTracked<T = void> {
430
+ #private;
431
+ readonly promise: Promise<T>;
432
+ readonly status: {
433
+ type: "pending";
434
+ } | {
435
+ type: "fulfilled";
436
+ value: T;
437
+ } | {
438
+ type: "rejected";
439
+ reason: unknown;
440
+ };
441
+ constructor();
442
+ get result(): T | undefined;
443
+ get error(): unknown | undefined;
444
+ resolve(value: T): void;
445
+ reject(reason: unknown): void;
446
+ }
447
+
448
+ interface AsyncPoolOptions<T> {
449
+ limit?: number;
450
+ signal?: AbortSignal;
451
+ onErrorStrategy?: (item: T, index: number, error: unknown) => MaybePromise<"ignore" | "collect" | "throw">;
452
+ }
453
+ declare class ErrorInfo<T> {
454
+ readonly item: T;
455
+ readonly index: number;
456
+ readonly error: unknown;
457
+ constructor(item: T, index: number, error: unknown);
458
+ }
459
+ declare class AggregateError<T> extends Error {
460
+ readonly errors: Array<ErrorInfo<T>>;
461
+ constructor(errors: Array<ErrorInfo<T>>);
462
+ }
463
+ declare function asyncPool<T>(iterable: Iterable<T> | AsyncIterable<T>, executor: (item: T, index: number) => MaybePromise<T | void>, options?: AsyncPoolOptions<T>): Promise<void>;
464
+ declare function parallelMap<T, R>(iterable: Iterable<T> | AsyncIterable<T>, executor: (item: T, index: number) => MaybePromise<R>, options?: AsyncPoolOptions<T>): Promise<Array<R>>;
465
+
466
+ declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
467
+
468
+ export { AggregateError, type AnyFunction, type AnyToNever, type AnyToVoidFunction, AsyncInterval, AsyncLock, type AsyncPoolOptions, AsyncQueue, AsyncResource, type AsyncResourceContext, type AsyncResourceOptions, type ComposedMiddleware, ConditionVariable, CustomMap, CustomSet, type DeepMerge, type DeepMergeOptions, Deferred, DeferredTracked, Deque, type DequeOptions, Emitter, type LastOfUnion, LruMap, LruSet, type MaybeArray, type MaybePromise, type MergeInsertions, type Middleware, type NoneToVoidFunction, NotImplementedError, type Truthy, type TypedArray, type TypesAreEqual, type UnionToIntersection, type UnionToTuple, type UnsafeMutate, type Values, abs, asNonNull, assert, assertHashKey, assertMatches, assertNotNull, assertStartsWith, assertsEndsWith, asyncPool, base64, bitLength, clearUndefinedInPlace, composeMiddlewares, deepMerge, enumerate, euclideanGcd, fromBytes, hex, isBigInt, isBoolean, isFalsy, isFunction, isNotNull, isNotUndefined, isNumber, isObject, isString, isSymbol, isTruthy, max, max2, min, min2, modInv, modPowBinary, noop, objectEntries, objectKeys, parallelMap, sleep, splitOnce, throwNotImplemented, throwUnreachable, timers, toBytes, twoMultiplicity, index$1 as typed, index as u8, unknownToError, unsafeCastType, utf8 };