mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-06 18:20:09 +00:00
pako type definition fixing
This commit is contained in:
224
types/pako/index.d.ts
vendored
224
types/pako/index.d.ts
vendored
@@ -1,84 +1,148 @@
|
||||
// Type definitions for pako 1.0.4
|
||||
// Type definitions for pako 1.0
|
||||
// Project: https://github.com/nodeca/pako
|
||||
// Definitions by: Denis Cappellin <https://github.com/cappellin>, Caleb Eggensperger <https://github.com/calebegg>
|
||||
// Definitions by: Denis Cappellin <https://github.com/cappellin>,
|
||||
// Caleb Eggensperger <https://github.com/calebegg>,
|
||||
// Muhammet Öztürk <https://github.com/hlthi>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = Pako;
|
||||
export as namespace pako;
|
||||
|
||||
declare namespace Pako {
|
||||
export interface DeflateOptions {
|
||||
level?: number;
|
||||
windowBits?: number;
|
||||
memLevel?: number;
|
||||
strategy?: number;
|
||||
dictionary?: any;
|
||||
raw?: boolean;
|
||||
to?: 'string';
|
||||
}
|
||||
|
||||
export interface InflateOptions {
|
||||
windowBits?: number;
|
||||
raw?: boolean;
|
||||
to?: 'string';
|
||||
}
|
||||
|
||||
export type Data = Uint8Array | Array<number> | string;
|
||||
|
||||
/**
|
||||
* Compress data with deflate algorithm and options.
|
||||
*/
|
||||
export function deflate( data: Data, options: DeflateOptions & {to: 'string'} ): string;
|
||||
export function deflate( data: Data, options?: DeflateOptions ): Uint8Array;
|
||||
|
||||
/**
|
||||
* The same as deflate, but creates raw data, without wrapper (header and adler32 crc).
|
||||
*/
|
||||
export function deflateRaw( data: Data, options: DeflateOptions & {to: 'string'} ): string;
|
||||
export function deflateRaw( data: Data, options?: DeflateOptions ): Uint8Array;
|
||||
|
||||
/**
|
||||
* The same as deflate, but create gzip wrapper instead of deflate one.
|
||||
*/
|
||||
export function gzip( data: Data, options: DeflateOptions & {to: 'string'} ): string;
|
||||
export function gzip( data: Data, options?: DeflateOptions ): Uint8Array;
|
||||
|
||||
/**
|
||||
* Decompress data with inflate/ungzip and options. Autodetect format via wrapper header
|
||||
* by default. That's why we don't provide separate ungzip method.
|
||||
*/
|
||||
export function inflate( data: Data, options: InflateOptions & {to: 'string'} ): string;
|
||||
export function inflate( data: Data, options?: InflateOptions ): Uint8Array;
|
||||
|
||||
/**
|
||||
* The same as inflate, but creates raw data, without wrapper (header and adler32 crc).
|
||||
*/
|
||||
export function inflateRaw( data: Data, options: InflateOptions & {to: 'string'} ): string;
|
||||
export function inflateRaw( data: Data, options?: InflateOptions ): Uint8Array;
|
||||
|
||||
/**
|
||||
* Just shortcut to inflate, because it autodetects format by header.content. Done for convenience.
|
||||
*/
|
||||
export function ungzip( data: Data, options: InflateOptions & {to: 'string'} ): string;
|
||||
export function ungzip( data: Data, options?: InflateOptions ): Uint8Array;
|
||||
|
||||
export class Deflate {
|
||||
constructor( options?: DeflateOptions );
|
||||
err: number;
|
||||
msg: string;
|
||||
result: Uint8Array | Array<number>;
|
||||
onData( chunk: Data ): void;
|
||||
onEnd( status: number ): void;
|
||||
push( data: Data | ArrayBuffer, mode?: number | boolean ): boolean;
|
||||
}
|
||||
|
||||
export class Inflate {
|
||||
constructor( options?: InflateOptions );
|
||||
err: number;
|
||||
msg: string;
|
||||
result: Data;
|
||||
onData( chunk: Data ): void;
|
||||
onEnd( status: number ): void;
|
||||
push( data: Data | ArrayBuffer, mode?: number | boolean ): boolean;
|
||||
}
|
||||
export enum FlushValues {
|
||||
Z_NO_FLUSH = 0,
|
||||
Z_PARTIAL_FLUSH = 1,
|
||||
Z_SYNC_FLUSH = 2,
|
||||
Z_FULL_FLUSH = 3,
|
||||
Z_FINISH = 4,
|
||||
Z_BLOCK = 5,
|
||||
Z_TREES = 6,
|
||||
}
|
||||
|
||||
export enum StrategyValues {
|
||||
Z_FILTERED = 1,
|
||||
Z_HUFFMAN_ONLY = 2,
|
||||
Z_RLE = 3,
|
||||
Z_FIXED = 4,
|
||||
Z_DEFAULT_STRATEGY = 0,
|
||||
}
|
||||
|
||||
export enum ReturnCodes {
|
||||
Z_OK = 0,
|
||||
Z_STREAM_END = 1,
|
||||
Z_NEED_DICT = 2,
|
||||
Z_ERRNO = -1,
|
||||
Z_STREAM_ERROR = -2,
|
||||
Z_DATA_ERROR = -3,
|
||||
Z_BUF_ERROR = -5,
|
||||
}
|
||||
|
||||
export interface DeflateOptions {
|
||||
level?: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
||||
windowBits?: number;
|
||||
memLevel?: number;
|
||||
strategy?: StrategyValues;
|
||||
dictionary?: any;
|
||||
raw?: boolean;
|
||||
to?: 'string';
|
||||
chunkSize?: number;
|
||||
gzip?: boolean;
|
||||
header?: Header;
|
||||
}
|
||||
|
||||
export interface DeflateFunctionOptions {
|
||||
level?: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
||||
windowBits?: number;
|
||||
memLevel?: number;
|
||||
strategy?: StrategyValues;
|
||||
dictionary?: any;
|
||||
raw?: boolean;
|
||||
to?: 'string';
|
||||
}
|
||||
|
||||
export interface InflateOptions {
|
||||
windowBits?: number;
|
||||
dictionary?: any;
|
||||
raw?: boolean;
|
||||
to?: 'string';
|
||||
chunkSize?: number;
|
||||
}
|
||||
|
||||
export interface InflateFunctionOptions {
|
||||
windowBits?: number;
|
||||
raw?: boolean;
|
||||
to?: 'string';
|
||||
}
|
||||
|
||||
export interface Header {
|
||||
text?: boolean;
|
||||
time?: number;
|
||||
os?: number;
|
||||
extra?: number[];
|
||||
name?: string;
|
||||
comment?: string;
|
||||
hcrc?: boolean;
|
||||
}
|
||||
|
||||
export type Data = Uint8Array | number[] | string;
|
||||
|
||||
/**
|
||||
* Compress data with deflate algorithm and options.
|
||||
*/
|
||||
export function deflate(data: Data, options: DeflateFunctionOptions & { to: 'string' }): string;
|
||||
export function deflate(data: Data, options?: DeflateFunctionOptions): Uint8Array;
|
||||
|
||||
/**
|
||||
* The same as deflate, but creates raw data, without wrapper (header and adler32 crc).
|
||||
*/
|
||||
export function deflateRaw(data: Data, options: DeflateFunctionOptions & { to: 'string' }): string;
|
||||
export function deflateRaw(data: Data, options?: DeflateFunctionOptions): Uint8Array;
|
||||
|
||||
/**
|
||||
* The same as deflate, but create gzip wrapper instead of deflate one.
|
||||
*/
|
||||
export function gzip(data: Data, options: DeflateFunctionOptions & { to: 'string' }): string;
|
||||
export function gzip(data: Data, options?: DeflateFunctionOptions): Uint8Array;
|
||||
|
||||
/**
|
||||
* Decompress data with inflate/ungzip and options. Autodetect format via wrapper header
|
||||
* by default. That's why we don't provide separate ungzip method.
|
||||
*/
|
||||
export function inflate(data: Data, options: InflateFunctionOptions & { to: 'string' }): string;
|
||||
export function inflate(data: Data, options?: InflateFunctionOptions): Uint8Array;
|
||||
|
||||
/**
|
||||
* The same as inflate, but creates raw data, without wrapper (header and adler32 crc).
|
||||
*/
|
||||
export function inflateRaw(data: Data, options: InflateFunctionOptions & { to: 'string' }): string;
|
||||
export function inflateRaw(data: Data, options?: InflateFunctionOptions): Uint8Array;
|
||||
|
||||
/**
|
||||
* Just shortcut to inflate, because it autodetects format by header.content. Done for convenience.
|
||||
*/
|
||||
export function ungzip(data: Data, options: InflateFunctionOptions & { to: 'string' }): string;
|
||||
export function ungzip(data: Data, options?: InflateFunctionOptions): Uint8Array;
|
||||
|
||||
export class Deflate {
|
||||
constructor(options?: DeflateOptions);
|
||||
|
||||
err: ReturnCodes;
|
||||
msg: string;
|
||||
result: Uint8Array | number[];
|
||||
|
||||
onData(chunk: Data): void;
|
||||
|
||||
onEnd(status: number): void;
|
||||
|
||||
push(data: Data | ArrayBuffer, mode?: FlushValues | boolean): boolean;
|
||||
}
|
||||
|
||||
export class Inflate {
|
||||
constructor(options?: InflateOptions);
|
||||
|
||||
err: ReturnCodes;
|
||||
msg: string;
|
||||
result: Data;
|
||||
|
||||
onData(chunk: Data): void;
|
||||
|
||||
onEnd(status: number): void;
|
||||
|
||||
push(data: Data | ArrayBuffer, mode?: FlushValues | boolean): boolean;
|
||||
}
|
||||
|
||||
@@ -1,24 +1,21 @@
|
||||
|
||||
|
||||
import pako = require("pako");
|
||||
|
||||
var chunk1 = new Uint8Array([1,2,3,4,5,6,7,8,9])
|
||||
var chunk2 = new Uint8Array([10,11,12,13,14,15,16,17,18,19]);
|
||||
const chunk1 = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9]);
|
||||
const chunk2 = new Uint8Array([10, 11, 12, 13, 14, 15, 16, 17, 18, 19]);
|
||||
|
||||
var deflate = new pako.Deflate({ level: 3 });
|
||||
const deflate = new pako.Deflate({level: 3});
|
||||
|
||||
deflate.push(chunk1, false);
|
||||
deflate.push(chunk2, true); // true -> last chunk
|
||||
|
||||
if (deflate.err) {
|
||||
throw new Error( deflate.err.toString() );
|
||||
throw new Error(deflate.err.toString());
|
||||
}
|
||||
|
||||
console.log(deflate.result);
|
||||
|
||||
let str: string = pako.deflate('1234', {to: 'string'});
|
||||
let arr: Uint8Array = pako.deflate('1234');
|
||||
|
||||
let str2: string = pako.inflate('1234', {to: 'string'});
|
||||
let arr2: Uint8Array = pako.inflate('1234');
|
||||
const str: string = pako.deflate('1234', {to: 'string'});
|
||||
const arr: Uint8Array = pako.deflate('1234');
|
||||
|
||||
const str2: string = pako.inflate('1234', {to: 'string'});
|
||||
const arr2: Uint8Array = pako.inflate('1234');
|
||||
|
||||
@@ -1,79 +1,6 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user