mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
add zopfli tests
This commit is contained in:
parent
9752e82a3d
commit
e9923e6940
69
types/node-zopfli/index.d.ts
vendored
Normal file
69
types/node-zopfli/index.d.ts
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
// Type definitions for node-zopfli 2.0
|
||||
// Project: https://github.com/pierreinglebert/node-zopfli
|
||||
// Definitions by: Alorel <https://github.com/Alorel>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import { Transform } from 'stream';
|
||||
|
||||
declare class Zopfli extends Transform {
|
||||
constructor(format?: Zopfli.Format, options?: Zopfli.Options);
|
||||
|
||||
static createGzip(options?: Zopfli.Options): Zopfli;
|
||||
static createDeflate(options?: Zopfli.Options): Zopfli;
|
||||
static createZlib(options?: Zopfli.Options): Zopfli;
|
||||
|
||||
static gzipSync(options?: Zopfli.Options): Buffer;
|
||||
static deflateSync(options?: Zopfli.Options): Buffer;
|
||||
static zlibSync(options?: Zopfli.Options): Buffer;
|
||||
|
||||
static deflate(input: Buffer, options: Zopfli.Options, cb: (err: Error, out: Buffer) => void): void;
|
||||
static deflate(input: Buffer, cb: (err: Error, out: Buffer) => void): void;
|
||||
static deflate(input: Buffer, options?: Zopfli.Options): Promise<Buffer>;
|
||||
|
||||
static gzip(input: Buffer, options: Zopfli.Options, cb: (err: Error, out: Buffer) => void): void;
|
||||
static gzip(input: Buffer, cb: (err: Error, out: Buffer) => void): void;
|
||||
static gzip(input: Buffer, options?: Zopfli.Options): Promise<Buffer>;
|
||||
|
||||
static zlib(input: Buffer, options: Zopfli.Options, cb: (err: Error, out: Buffer) => void): void;
|
||||
static zlib(input: Buffer, cb: (err: Error, out: Buffer) => void): void;
|
||||
static zlib(input: Buffer, options?: Zopfli.Options): Promise<Buffer>;
|
||||
|
||||
static compress(input: Buffer, format: Zopfli.Format, options: Zopfli.Options, cb: (err: Error, out: Buffer) => void): void;
|
||||
static compress(input: Buffer, format: Zopfli.Format, cb: (err: Error, out: Buffer) => void): void;
|
||||
static compress(input: Buffer, format: Zopfli.Format, options?: Zopfli.Options): Promise<Buffer>;
|
||||
}
|
||||
|
||||
declare namespace Zopfli {
|
||||
type Format = 'deflate' | 'gzip' | 'zlib';
|
||||
|
||||
interface Options {
|
||||
verbose?: boolean;
|
||||
verbose_more?: boolean;
|
||||
/**
|
||||
* Maximum amount of times to rerun forward and backward pass to optimize LZ77 compression cost.
|
||||
* Good values: 10, 15 for small files, 5 for files over several MB in size or it will be too slow.
|
||||
*/
|
||||
numiterations?: number;
|
||||
/**
|
||||
* If true, splits the data in multiple deflate blocks with optimal choice for the block boundaries.
|
||||
* Block splitting gives better compression.
|
||||
*/
|
||||
blocksplitting?: boolean;
|
||||
/**
|
||||
* If true, chooses the optimal block split points only after doing the iterative LZ77 compression.
|
||||
* If false, chooses the block split points first, then does iterative LZ77 on each individual block.
|
||||
* Depending on the file, either first or last gives the best compression.
|
||||
*/
|
||||
blocksplittinglast?: boolean;
|
||||
/**
|
||||
* Maximum amount of blocks to split into (0 for unlimited,
|
||||
* but this can give extreme results that hurt compression on some files).
|
||||
*/
|
||||
blocksplittingmax?: number;
|
||||
}
|
||||
}
|
||||
|
||||
export = Zopfli;
|
||||
51
types/node-zopfli/node-zopfli-tests.ts
Normal file
51
types/node-zopfli/node-zopfli-tests.ts
Normal file
@ -0,0 +1,51 @@
|
||||
import * as Zopfli from 'node-zopfli';
|
||||
import * as fs from 'fs';
|
||||
|
||||
const opts: Zopfli.Options = {
|
||||
verbose: true,
|
||||
numiterations: 1
|
||||
};
|
||||
let input: Buffer = Buffer.from('foo');
|
||||
const read = fs.createReadStream('foo');
|
||||
const write = fs.createWriteStream('foo');
|
||||
|
||||
function cb(e: Error, b: Buffer): void {}
|
||||
function then(b: Buffer): void {}
|
||||
|
||||
Zopfli.zlib(input, cb);
|
||||
Zopfli.zlib(input, opts, cb);
|
||||
Zopfli.zlib(input, opts).then(then);
|
||||
Zopfli.zlib(input).then(then);
|
||||
|
||||
Zopfli.gzip(input, cb);
|
||||
Zopfli.gzip(input, opts, cb);
|
||||
Zopfli.gzip(input, opts).then(then);
|
||||
Zopfli.gzip(input).then(then);
|
||||
|
||||
Zopfli.deflate(input, cb);
|
||||
Zopfli.deflate(input, opts, cb);
|
||||
Zopfli.deflate(input, opts).then(then);
|
||||
Zopfli.deflate(input).then(then);
|
||||
|
||||
Zopfli.compress(input, 'zlib', cb);
|
||||
Zopfli.compress(input, 'zlib', opts, cb);
|
||||
Zopfli.compress(input, 'zlib', opts).then(then);
|
||||
Zopfli.compress(input, 'zlib').then(then);
|
||||
|
||||
input = Zopfli.gzipSync();
|
||||
input = Zopfli.gzipSync(opts);
|
||||
|
||||
input = Zopfli.deflateSync();
|
||||
input = Zopfli.deflateSync(opts);
|
||||
|
||||
input = Zopfli.zlibSync();
|
||||
input = Zopfli.zlibSync(opts);
|
||||
|
||||
read.pipe(Zopfli.createGzip()).pipe(write);
|
||||
read.pipe(Zopfli.createGzip(opts)).pipe(write);
|
||||
|
||||
read.pipe(Zopfli.createDeflate()).pipe(write);
|
||||
read.pipe(Zopfli.createDeflate(opts)).pipe(write);
|
||||
|
||||
read.pipe(Zopfli.createZlib()).pipe(write);
|
||||
read.pipe(Zopfli.createZlib(opts)).pipe(write);
|
||||
23
types/node-zopfli/tsconfig.json
Normal file
23
types/node-zopfli/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"node-zopfli-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/node-zopfli/tslint.json
Normal file
1
types/node-zopfli/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user