mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-02-03 23:42:50 +00:00
iltorb tests
This commit is contained in:
parent
35272568c9
commit
e701d85609
36
types/iltorb/iltorb-tests.ts
Normal file
36
types/iltorb/iltorb-tests.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import {createReadStream, createWriteStream} from 'fs';
|
||||
import * as br from 'iltorb';
|
||||
|
||||
const opts: br.BrotliEncodeParams = {
|
||||
disable_literal_context_modeling: false,
|
||||
lgblock: 0,
|
||||
lgwin: 22,
|
||||
mode: 0,
|
||||
quality: 11,
|
||||
size_hint: 0
|
||||
};
|
||||
|
||||
const onCompress = (err1: Error | null | undefined, compressed: Buffer) => {
|
||||
br.decompress(compressed, (err2: Error | null | undefined, decompressed: Buffer) => {
|
||||
console.log(decompressed.toString());
|
||||
});
|
||||
};
|
||||
|
||||
br.compress(Buffer.from('foo', 'utf8'), onCompress);
|
||||
|
||||
br.compress(Buffer.from('foo', 'utf8'), opts, onCompress);
|
||||
|
||||
createReadStream(__filename)
|
||||
.pipe(br.compressStream())
|
||||
.pipe(createWriteStream('foo.ts'));
|
||||
|
||||
createReadStream(__dirname)
|
||||
.pipe(br.compressStream(opts))
|
||||
.pipe(createWriteStream('bar.ts'));
|
||||
|
||||
createReadStream('bar.ts')
|
||||
.pipe(br.decompressStream())
|
||||
.pipe(createWriteStream('qux.ts'));
|
||||
|
||||
br.decompressSync(br.compressSync(Buffer.from('foo', 'utf8')));
|
||||
br.decompressSync(br.compressSync(Buffer.from('foo', 'utf8'), opts));
|
||||
30
types/iltorb/index.d.ts
vendored
Normal file
30
types/iltorb/index.d.ts
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
// Type definitions for iltorb 2.0
|
||||
// Project: https://github.com/MayhemYDG/iltorb
|
||||
// Definitions by: Arturas Molcanovas <https://github.com/Alorel>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node"/>
|
||||
|
||||
import { Transform } from 'stream';
|
||||
|
||||
export interface BrotliEncodeParams {
|
||||
disable_literal_context_modeling?: boolean;
|
||||
lgblock?: number;
|
||||
lgwin?: number;
|
||||
mode?: number;
|
||||
quality?: number;
|
||||
size_hint?: number;
|
||||
}
|
||||
|
||||
export type IltorbCallback = (err: Error | null | undefined, output: Buffer) => any;
|
||||
|
||||
export function compress(buffer: Buffer, options: BrotliEncodeParams, callback: IltorbCallback): void;
|
||||
export function compress(buffer: Buffer, callback: IltorbCallback): void;
|
||||
|
||||
export function decompress(buffer: Buffer, callback: IltorbCallback): void;
|
||||
|
||||
export function compressSync(buffer: Buffer, options?: BrotliEncodeParams): Buffer;
|
||||
export function decompressSync(buffer: Buffer): Buffer;
|
||||
|
||||
export function compressStream(options?: BrotliEncodeParams): Transform;
|
||||
export function decompressStream(): Transform;
|
||||
23
types/iltorb/tsconfig.json
Normal file
23
types/iltorb/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"iltorb-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/iltorb/tslint.json
Normal file
3
types/iltorb/tslint.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user