@yorozu/utils 0.1.4 → 0.3.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/LICENSE +21 -0
- package/arrays/index.d.ts +4 -0
- package/arrays/typed/compare.d.ts +3 -0
- package/arrays/typed/find.d.ts +10 -0
- package/arrays/typed/index.d.ts +4 -0
- package/arrays/typed/misc.d.ts +10 -0
- package/arrays/typed/types.d.ts +2 -0
- package/arrays/u8/concat.d.ts +3 -0
- package/arrays/u8/index.d.ts +6 -0
- package/arrays/u8/misc.d.ts +3 -0
- package/arrays/u8/pool.d.ts +15 -0
- package/arrays/u8/reverse.d.ts +2 -0
- package/arrays/u8/swap.d.ts +4 -0
- package/arrays/u8/xor.d.ts +2 -0
- package/async/async-interval.d.ts +16 -0
- package/async/async-lock.d.ts +10 -0
- package/async/async-queue.d.ts +22 -0
- package/async/async-resource.d.ts +41 -0
- package/async/condition-variable.d.ts +6 -0
- package/async/deferred.d.ts +25 -0
- package/async/emitter.d.ts +15 -0
- package/async/index.d.ts +11 -0
- package/async/pool.d.ts +19 -0
- package/async/sleep.d.ts +1 -0
- package/async/timers.d.ts +8 -0
- package/bigint/bytes.d.ts +2 -0
- package/bigint/index.d.ts +2 -0
- package/bigint/math.d.ts +10 -0
- package/compress/bits.d.ts +5 -0
- package/compress/checksum.d.ts +15 -0
- package/compress/compress.d.ts +3 -0
- package/compress/decompress.d.ts +4 -0
- package/compress/deflate.d.ts +22 -0
- package/compress/detect.d.ts +2 -0
- package/compress/errors.d.ts +24 -0
- package/compress/gzip.d.ts +31 -0
- package/compress/huffman.d.ts +6 -0
- package/compress/index.d.ts +5 -0
- package/compress/inflate.d.ts +21 -0
- package/compress/types.d.ts +14 -0
- package/compress/zlib.d.ts +30 -0
- package/encoding/base64.d.ts +6 -0
- package/encoding/hex.d.ts +4 -0
- package/encoding/index.d.ts +4 -0
- package/encoding/utf8.d.ts +3 -0
- package/index.d.ts +9 -0
- package/index.js +3154 -0
- package/iterate/enumerate.d.ts +1 -0
- package/iterate/index.d.ts +1 -0
- package/misc/assert.d.ts +7 -0
- package/misc/composer.d.ts +4 -0
- package/misc/guards.d.ts +12 -0
- package/misc/index.d.ts +6 -0
- package/misc/noop.d.ts +1 -0
- package/misc/objects.d.ts +18 -0
- package/misc/string.d.ts +4 -0
- package/package.json +15 -17
- package/structures/_iterator.d.ts +2 -0
- package/structures/custom-map.d.ts +21 -0
- package/structures/custom-set.d.ts +25 -0
- package/structures/deque.d.ts +34 -0
- package/structures/index.d.ts +5 -0
- package/structures/lru-map.d.ts +15 -0
- package/structures/lru-set.d.ts +12 -0
- package/types/brand.d.ts +5 -0
- package/types/equal.d.ts +1 -0
- package/types/error.d.ts +6 -0
- package/types/index.d.ts +5 -0
- package/types/misc.d.ts +11 -0
- package/types/unions.d.ts +3 -0
- package/lib/index.cjs +0 -2044
- package/lib/index.d.cts +0 -468
- package/lib/index.d.ts +0 -468
- package/lib/index.js +0 -1958
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ivan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TypedArray } from './types';
|
|
2
|
+
export declare function indexOf(haystack: Exclude<TypedArray, BigInt64Array | BigUint64Array>, needle: number, start?: number): number;
|
|
3
|
+
export declare function indexOf(haystack: BigInt64Array | BigUint64Array, needle: bigint, start?: number): number;
|
|
4
|
+
export declare function lastIndexOf(haystack: Exclude<TypedArray, BigInt64Array | BigUint64Array>, needle: number, start?: number): number;
|
|
5
|
+
export declare function lastIndexOf(haystack: BigInt64Array | BigUint64Array, needle: bigint, start?: number): number;
|
|
6
|
+
export declare function indexOfArray<T extends TypedArray>(haystack: T, needle: T, start?: number): number;
|
|
7
|
+
export declare function lastIndexOfArray<T extends TypedArray>(haystack: T, needle: T, start?: number): number;
|
|
8
|
+
export declare function includes(haystack: Exclude<TypedArray, BigInt64Array | BigUint64Array>, needle: number): boolean;
|
|
9
|
+
export declare function includes(haystack: BigInt64Array | BigUint64Array, needle: bigint): boolean;
|
|
10
|
+
export declare function includesArray<T extends TypedArray>(haystack: T, needle: T): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TypedArray } from './types';
|
|
2
|
+
export declare function toDataView(buf: TypedArray): DataView;
|
|
3
|
+
export declare function view<R extends TypedArray>(ctor: {
|
|
4
|
+
new (buffer: ArrayBufferLike, byteOffset: number, byteLength: number): R;
|
|
5
|
+
BYTES_PER_ELEMENT: number;
|
|
6
|
+
}, buf: ArrayBufferView): R;
|
|
7
|
+
export declare function getPlatformByteOrder(): "little" | "big";
|
|
8
|
+
export declare namespace getPlatformByteOrder {
|
|
9
|
+
var _cachedByteOrder: boolean | null;
|
|
10
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class BufferPool {
|
|
2
|
+
readonly size: number;
|
|
3
|
+
readonly maxAllocSize: number;
|
|
4
|
+
protected _pool: ArrayBuffer;
|
|
5
|
+
protected _offset: number;
|
|
6
|
+
constructor(size?: number);
|
|
7
|
+
protected get _remaining(): number;
|
|
8
|
+
allocate(size: number): Uint8Array;
|
|
9
|
+
reset(): void;
|
|
10
|
+
protected _reallocate(): void;
|
|
11
|
+
protected _align(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare function setDefaultPool(size: number): void;
|
|
14
|
+
export declare function allocate(size: number): Uint8Array;
|
|
15
|
+
export declare function allocateWith(init: ArrayLike<number>): Uint8Array;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as timers from "./timers";
|
|
2
|
+
export declare class AsyncInterval {
|
|
3
|
+
protected _handler: (abortSignal: AbortSignal) => Promise<void>;
|
|
4
|
+
protected _interval: number;
|
|
5
|
+
protected _timer?: timers.Timer;
|
|
6
|
+
protected _onError: (err: unknown) => void;
|
|
7
|
+
protected _stopped: boolean;
|
|
8
|
+
protected _generation: number;
|
|
9
|
+
protected _abortController: AbortController;
|
|
10
|
+
constructor(handler: (abortSignal: AbortSignal) => Promise<void>, interval: number);
|
|
11
|
+
start(after?: number): void;
|
|
12
|
+
startNow(): void;
|
|
13
|
+
stop(): void;
|
|
14
|
+
onError(handler: (err: unknown) => void): void;
|
|
15
|
+
protected _onTimeout: (generation: number) => void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NoneToVoidFunction } from '../types';
|
|
2
|
+
import { Deque } from '../structures';
|
|
3
|
+
type LockInfo = [Promise<void>, NoneToVoidFunction];
|
|
4
|
+
export declare class AsyncLock {
|
|
5
|
+
protected _queue: Deque<LockInfo>;
|
|
6
|
+
acquire(): Promise<void>;
|
|
7
|
+
release(): void;
|
|
8
|
+
with<T>(func: () => Promise<T>): Promise<T>;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Deque } from '../structures';
|
|
2
|
+
import { Deferred } from './deferred';
|
|
3
|
+
export declare class AsyncQueue<T> {
|
|
4
|
+
readonly queue: Deque<T>;
|
|
5
|
+
readonly maxSize: number | undefined;
|
|
6
|
+
protected _consumerWaiters: Deque<Deferred<T | undefined>>;
|
|
7
|
+
protected _producerWaiters: Deque<Deferred<void>>;
|
|
8
|
+
protected _ended: boolean;
|
|
9
|
+
constructor(from?: ArrayLike<T> | Deque<T>, maxSize?: number);
|
|
10
|
+
get length(): number;
|
|
11
|
+
get isFull(): boolean;
|
|
12
|
+
get remainingCapacity(): number;
|
|
13
|
+
get ended(): boolean;
|
|
14
|
+
enqueue(item: T): Promise<void>;
|
|
15
|
+
tryEnqueue(item: T): boolean;
|
|
16
|
+
end(): void;
|
|
17
|
+
peek(): T | undefined;
|
|
18
|
+
next(): T | undefined;
|
|
19
|
+
nextOrWait(): Promise<T | undefined>;
|
|
20
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<T>;
|
|
21
|
+
protected _wakeProducerIfNeeded(): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { UnsafeMutate } from '../types';
|
|
2
|
+
import { Deferred } from './deferred';
|
|
3
|
+
import { Emitter } from './emitter';
|
|
4
|
+
import * as timers from "./timers";
|
|
5
|
+
export interface AsyncResourceContext<T> {
|
|
6
|
+
readonly current: T | null;
|
|
7
|
+
readonly currentFetchedAt: number;
|
|
8
|
+
readonly currentExpiresAt: number;
|
|
9
|
+
readonly isBackground: boolean;
|
|
10
|
+
readonly abort: AbortSignal | null;
|
|
11
|
+
}
|
|
12
|
+
export interface AsyncResourceOptions<T> {
|
|
13
|
+
autoReload?: boolean;
|
|
14
|
+
autoReloadAfter?: number;
|
|
15
|
+
/** @deprecated Use `autoReloadAfter`. */
|
|
16
|
+
authReloadAfter?: number;
|
|
17
|
+
swr?: boolean;
|
|
18
|
+
swrValidator?: (ctx: AsyncResourceContext<T>) => boolean;
|
|
19
|
+
fetcher: (ctx: AsyncResourceContext<T>) => Promise<{
|
|
20
|
+
data: T;
|
|
21
|
+
expiresIn: number;
|
|
22
|
+
}>;
|
|
23
|
+
onError?: (err: unknown, ctx: AsyncResourceContext<T>) => void;
|
|
24
|
+
}
|
|
25
|
+
export declare class AsyncResource<T> {
|
|
26
|
+
readonly options: AsyncResourceOptions<T>;
|
|
27
|
+
readonly onUpdated: Emitter<AsyncResourceContext<T>>;
|
|
28
|
+
protected _abort?: AbortController;
|
|
29
|
+
protected _ctx: UnsafeMutate<AsyncResourceContext<T>>;
|
|
30
|
+
protected _updating?: Deferred<void>;
|
|
31
|
+
protected _timeout?: timers.Timer;
|
|
32
|
+
protected _destroyed: boolean;
|
|
33
|
+
constructor(options: AsyncResourceOptions<T>);
|
|
34
|
+
get isStale(): boolean;
|
|
35
|
+
setData(data: T, expiresIn: number): void;
|
|
36
|
+
update(force?: boolean): Promise<void>;
|
|
37
|
+
get(): Promise<T | null>;
|
|
38
|
+
getCached(): T | null;
|
|
39
|
+
destroy(): void;
|
|
40
|
+
protected _clearTimer(): void;
|
|
41
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare class Deferred<T = void> {
|
|
2
|
+
readonly resolve: (value: T) => void;
|
|
3
|
+
readonly reject: (reason: unknown) => void;
|
|
4
|
+
readonly promise: Promise<T>;
|
|
5
|
+
constructor();
|
|
6
|
+
}
|
|
7
|
+
export declare class DeferredTracked<T = void> {
|
|
8
|
+
readonly promise: Promise<T>;
|
|
9
|
+
readonly status: {
|
|
10
|
+
type: "pending";
|
|
11
|
+
} | {
|
|
12
|
+
type: "fulfilled";
|
|
13
|
+
value: T;
|
|
14
|
+
} | {
|
|
15
|
+
type: "rejected";
|
|
16
|
+
reason: unknown;
|
|
17
|
+
};
|
|
18
|
+
protected _resolve: (value: T) => void;
|
|
19
|
+
protected _reject: (reason: unknown) => void;
|
|
20
|
+
constructor();
|
|
21
|
+
get result(): T | undefined;
|
|
22
|
+
get error(): unknown | undefined;
|
|
23
|
+
resolve(value: T): void;
|
|
24
|
+
reject(reason: unknown): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class Emitter<T> {
|
|
2
|
+
protected _listeners: ((value: T) => void)[];
|
|
3
|
+
protected _emit: (value: T) => void;
|
|
4
|
+
get length(): number;
|
|
5
|
+
add(listener: (value: T) => void): void;
|
|
6
|
+
forwardTo(emitter: Emitter<T>): void;
|
|
7
|
+
remove(listener: (value: T) => void): void;
|
|
8
|
+
emit(value: T): void;
|
|
9
|
+
once(listener: (value: T) => void): void;
|
|
10
|
+
listeners(): readonly ((value: T) => void)[];
|
|
11
|
+
clear(): void;
|
|
12
|
+
protected _emitFew: (value: T) => void;
|
|
13
|
+
protected _emitAll: (value: T) => void;
|
|
14
|
+
protected _updateEmit: () => void;
|
|
15
|
+
}
|
package/async/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as timers from "./timers";
|
|
2
|
+
export * from './async-interval';
|
|
3
|
+
export * from './async-lock';
|
|
4
|
+
export * from './async-queue';
|
|
5
|
+
export * from './async-resource';
|
|
6
|
+
export * from './condition-variable';
|
|
7
|
+
export * from './deferred';
|
|
8
|
+
export * from './emitter';
|
|
9
|
+
export * from './pool';
|
|
10
|
+
export * from './sleep';
|
|
11
|
+
export { timers };
|
package/async/pool.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MaybePromise } from '../types';
|
|
2
|
+
export interface AsyncPoolOptions<T> {
|
|
3
|
+
limit?: number;
|
|
4
|
+
signal?: AbortSignal;
|
|
5
|
+
onErrorStrategy?: (item: T, index: number, error: unknown) => MaybePromise<"ignore" | "collect" | "throw">;
|
|
6
|
+
}
|
|
7
|
+
declare class ErrorInfo<T> {
|
|
8
|
+
readonly item: T;
|
|
9
|
+
readonly index: number;
|
|
10
|
+
readonly error: unknown;
|
|
11
|
+
constructor(item: T, index: number, error: unknown);
|
|
12
|
+
}
|
|
13
|
+
export declare class AggregateError<T> extends Error {
|
|
14
|
+
readonly errors: Array<ErrorInfo<T>>;
|
|
15
|
+
constructor(errors: Array<ErrorInfo<T>>);
|
|
16
|
+
}
|
|
17
|
+
export declare function asyncPool<T>(iterable: Iterable<T> | AsyncIterable<T>, executor: (item: T, index: number) => MaybePromise<T | void>, options?: AsyncPoolOptions<T>): Promise<void>;
|
|
18
|
+
export declare function parallelMap<T, R>(iterable: Iterable<T> | AsyncIterable<T>, executor: (item: T, index: number) => MaybePromise<R>, options?: AsyncPoolOptions<T>): Promise<Array<R>>;
|
|
19
|
+
export {};
|
package/async/sleep.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Brand } from '../types/brand';
|
|
2
|
+
export type Timer = Brand<object, "Timer">;
|
|
3
|
+
export type Interval = Brand<object, "Interval">;
|
|
4
|
+
declare const setTimeoutWrap: <T extends (...args: any[]) => any>(fn: T, ms: number, ...args: Parameters<T>) => Timer;
|
|
5
|
+
declare const setIntervalWrap: <T extends (...args: any[]) => any>(fn: T, ms: number, ...args: Parameters<T>) => Interval;
|
|
6
|
+
declare const clearTimeoutWrap: (timer?: Timer) => void;
|
|
7
|
+
declare const clearIntervalWrap: (timer?: Interval) => void;
|
|
8
|
+
export { clearIntervalWrap as clearInterval, clearTimeoutWrap as clearTimeout, setIntervalWrap as setInterval, setTimeoutWrap as setTimeout, };
|
package/bigint/math.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function bitLength(n: bigint): number;
|
|
2
|
+
export declare function twoMultiplicity(n: bigint): bigint;
|
|
3
|
+
export declare function min2(a: bigint, b: bigint): bigint;
|
|
4
|
+
export declare function min(...args: Array<bigint>): bigint;
|
|
5
|
+
export declare function max2(a: bigint, b: bigint): bigint;
|
|
6
|
+
export declare function max(...args: Array<bigint>): bigint;
|
|
7
|
+
export declare function abs(a: bigint): bigint;
|
|
8
|
+
export declare function euclideanGcd(a: bigint, b: bigint): bigint;
|
|
9
|
+
export declare function modPowBinary(base: bigint, exp: bigint, mod: bigint): bigint;
|
|
10
|
+
export declare function modInv(a: bigint, n: bigint): bigint;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function readBits(data: Uint8Array, bitPos: number, mask: number): number;
|
|
2
|
+
export declare function readBits16(data: Uint8Array, bitPos: number): number;
|
|
3
|
+
export declare function writeBits(data: Uint8Array, bitPos: number, value: number): void;
|
|
4
|
+
export declare function writeBits16(data: Uint8Array, bitPos: number, value: number): void;
|
|
5
|
+
export declare function byteCeil(bitPos: number): number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class Crc32 {
|
|
2
|
+
protected _c: number;
|
|
3
|
+
constructor(seed?: number);
|
|
4
|
+
update(data: Uint8Array): this;
|
|
5
|
+
digest(): number;
|
|
6
|
+
}
|
|
7
|
+
export declare function crc32(data: Uint8Array, seed?: number): number;
|
|
8
|
+
export declare class Adler32 {
|
|
9
|
+
protected _a: number;
|
|
10
|
+
protected _b: number;
|
|
11
|
+
constructor(seed?: number);
|
|
12
|
+
update(data: Uint8Array): this;
|
|
13
|
+
digest(): number;
|
|
14
|
+
}
|
|
15
|
+
export declare function adler32(data: Uint8Array, seed?: number): number;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CompressOptions } from './types';
|
|
2
|
+
export type DeflateState = {
|
|
3
|
+
head?: Uint16Array;
|
|
4
|
+
prev?: Uint16Array;
|
|
5
|
+
index?: number;
|
|
6
|
+
end?: number;
|
|
7
|
+
wait?: number;
|
|
8
|
+
remainder?: number;
|
|
9
|
+
last: number;
|
|
10
|
+
};
|
|
11
|
+
export declare function deflateWithOptions(data: Uint8Array, options: CompressOptions, pre: number, post: number, state?: DeflateState): Uint8Array;
|
|
12
|
+
export declare function compress(data: Uint8Array, options?: CompressOptions): Uint8Array;
|
|
13
|
+
export declare class Compressor {
|
|
14
|
+
protected _options: CompressOptions;
|
|
15
|
+
protected _state: DeflateState;
|
|
16
|
+
protected _buffer: Uint8Array;
|
|
17
|
+
protected _done: boolean;
|
|
18
|
+
constructor(options?: CompressOptions);
|
|
19
|
+
protected _emit(final: boolean): Uint8Array;
|
|
20
|
+
push(chunk: Uint8Array, final?: boolean): Uint8Array;
|
|
21
|
+
flush(sync?: boolean): Uint8Array;
|
|
22
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare class FlateError extends Error {
|
|
2
|
+
constructor(message: string, options?: ErrorOptions);
|
|
3
|
+
}
|
|
4
|
+
export declare class UnexpectedEofError extends FlateError {
|
|
5
|
+
constructor(options?: ErrorOptions);
|
|
6
|
+
}
|
|
7
|
+
export declare class InvalidBlockTypeError extends FlateError {
|
|
8
|
+
constructor(options?: ErrorOptions);
|
|
9
|
+
}
|
|
10
|
+
export declare class InvalidLengthLiteralError extends FlateError {
|
|
11
|
+
constructor(options?: ErrorOptions);
|
|
12
|
+
}
|
|
13
|
+
export declare class InvalidDistanceError extends FlateError {
|
|
14
|
+
constructor(options?: ErrorOptions);
|
|
15
|
+
}
|
|
16
|
+
export declare class InvalidHeaderError extends FlateError {
|
|
17
|
+
constructor(message?: string, options?: ErrorOptions);
|
|
18
|
+
}
|
|
19
|
+
export declare class StreamFinishedError extends FlateError {
|
|
20
|
+
constructor(options?: ErrorOptions);
|
|
21
|
+
}
|
|
22
|
+
export declare class ChecksumMismatchError extends FlateError {
|
|
23
|
+
constructor(options?: ErrorOptions);
|
|
24
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Crc32 } from './checksum';
|
|
2
|
+
import { Compressor as RawCompressor } from './deflate';
|
|
3
|
+
import { InflateState } from './inflate';
|
|
4
|
+
import { DecompressOptions, GzipCompressOptions } from './types';
|
|
5
|
+
export declare function gzipHeaderLength(data: Uint8Array): number;
|
|
6
|
+
export declare function compress(data: Uint8Array, options?: GzipCompressOptions): Uint8Array;
|
|
7
|
+
export declare function decompress(data: Uint8Array, options?: DecompressOptions): Uint8Array;
|
|
8
|
+
export declare class Compressor {
|
|
9
|
+
protected _inner: RawCompressor;
|
|
10
|
+
protected _options: GzipCompressOptions;
|
|
11
|
+
protected _crc: Crc32;
|
|
12
|
+
protected _length: number;
|
|
13
|
+
protected _header: boolean;
|
|
14
|
+
protected _done: boolean;
|
|
15
|
+
constructor(options?: GzipCompressOptions);
|
|
16
|
+
protected _wrap(raw: Uint8Array, final: boolean): Uint8Array;
|
|
17
|
+
push(chunk: Uint8Array, final?: boolean): Uint8Array;
|
|
18
|
+
flush(sync?: boolean): Uint8Array;
|
|
19
|
+
}
|
|
20
|
+
export declare class Decompressor {
|
|
21
|
+
protected _pending: Uint8Array;
|
|
22
|
+
protected _needHeader: boolean;
|
|
23
|
+
protected _state: InflateState;
|
|
24
|
+
protected _window: Uint8Array;
|
|
25
|
+
protected _crc: Crc32;
|
|
26
|
+
protected _length: number;
|
|
27
|
+
protected _check: boolean;
|
|
28
|
+
protected _done: boolean;
|
|
29
|
+
constructor(options?: DecompressOptions);
|
|
30
|
+
push(chunk: Uint8Array, final?: boolean): Uint8Array;
|
|
31
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function buildEncodeMap(lengths: Uint8Array, maxBits: number): Uint16Array;
|
|
2
|
+
export declare function buildDecodeMap(lengths: Uint8Array, maxBits: number): Uint16Array;
|
|
3
|
+
export declare function buildLengthLimitedTree(freqs: Uint16Array, maxBits: number): {
|
|
4
|
+
lengths: Uint8Array;
|
|
5
|
+
maxBits: number;
|
|
6
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { adler32, Adler32, crc32, Crc32 } from './checksum';
|
|
2
|
+
export * as compress from './compress';
|
|
3
|
+
export * as decompress from './decompress';
|
|
4
|
+
export { ChecksumMismatchError, FlateError, InvalidBlockTypeError, InvalidDistanceError, InvalidHeaderError, InvalidLengthLiteralError, StreamFinishedError, UnexpectedEofError, } from './errors';
|
|
5
|
+
export type { CompressOptions, DecompressOptions, GzipCompressOptions } from './types';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DecompressOptions } from './types';
|
|
2
|
+
export type InflateState = {
|
|
3
|
+
lengthMap?: Uint16Array;
|
|
4
|
+
distanceMap?: Uint16Array;
|
|
5
|
+
lengthBits?: number;
|
|
6
|
+
distanceBits?: number;
|
|
7
|
+
final?: number;
|
|
8
|
+
bitPos?: number;
|
|
9
|
+
outputLength?: number;
|
|
10
|
+
mode: number;
|
|
11
|
+
};
|
|
12
|
+
export declare function inflateRaw(data: Uint8Array, state: InflateState, buf?: Uint8Array, dictionary?: Uint8Array): Uint8Array;
|
|
13
|
+
export declare function decompress(data: Uint8Array, options?: DecompressOptions): Uint8Array;
|
|
14
|
+
export declare class Decompressor {
|
|
15
|
+
protected _state: InflateState;
|
|
16
|
+
protected _window: Uint8Array;
|
|
17
|
+
protected _pending: Uint8Array;
|
|
18
|
+
protected _done: boolean;
|
|
19
|
+
constructor(options?: DecompressOptions);
|
|
20
|
+
push(chunk: Uint8Array, final?: boolean): Uint8Array;
|
|
21
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface CompressOptions {
|
|
2
|
+
level?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
3
|
+
mem?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
4
|
+
dictionary?: Uint8Array;
|
|
5
|
+
}
|
|
6
|
+
export interface DecompressOptions {
|
|
7
|
+
dictionary?: Uint8Array;
|
|
8
|
+
out?: Uint8Array;
|
|
9
|
+
check?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface GzipCompressOptions extends CompressOptions {
|
|
12
|
+
mtime?: Date | string | number;
|
|
13
|
+
filename?: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Adler32 } from './checksum';
|
|
2
|
+
import { Compressor as RawCompressor } from './deflate';
|
|
3
|
+
import { InflateState } from './inflate';
|
|
4
|
+
import { CompressOptions, DecompressOptions } from './types';
|
|
5
|
+
export declare function zlibHeaderLength(data: Uint8Array, dictionary?: Uint8Array): number;
|
|
6
|
+
export declare function compress(data: Uint8Array, options?: CompressOptions): Uint8Array;
|
|
7
|
+
export declare function decompress(data: Uint8Array, options?: DecompressOptions): Uint8Array;
|
|
8
|
+
export declare class Compressor {
|
|
9
|
+
protected _inner: RawCompressor;
|
|
10
|
+
protected _options: CompressOptions;
|
|
11
|
+
protected _sum: Adler32;
|
|
12
|
+
protected _header: boolean;
|
|
13
|
+
protected _done: boolean;
|
|
14
|
+
constructor(options?: CompressOptions);
|
|
15
|
+
protected _wrap(raw: Uint8Array, final: boolean): Uint8Array;
|
|
16
|
+
push(chunk: Uint8Array, final?: boolean): Uint8Array;
|
|
17
|
+
flush(sync?: boolean): Uint8Array;
|
|
18
|
+
}
|
|
19
|
+
export declare class Decompressor {
|
|
20
|
+
protected _pending: Uint8Array;
|
|
21
|
+
protected _header: boolean;
|
|
22
|
+
protected _state: InflateState;
|
|
23
|
+
protected _window: Uint8Array;
|
|
24
|
+
protected _sum: Adler32;
|
|
25
|
+
protected _dictionary?: Uint8Array;
|
|
26
|
+
protected _check: boolean;
|
|
27
|
+
protected _done: boolean;
|
|
28
|
+
constructor(options?: DecompressOptions);
|
|
29
|
+
push(chunk: Uint8Array, final?: boolean): Uint8Array;
|
|
30
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const lookup: Map<number, number>;
|
|
2
|
+
export declare const encodeLookup: Map<number, number>;
|
|
3
|
+
export declare function decode(data: string, url?: boolean): Uint8Array;
|
|
4
|
+
export declare function encode(bytes: Uint8Array, url?: boolean): string;
|
|
5
|
+
export declare function encodedLength(n: number): number;
|
|
6
|
+
export declare function decodedLength(n: number): number;
|
package/index.d.ts
ADDED