Add types for gzip-js (#22752)

This commit is contained in:
Linda_pp 2018-01-09 03:28:02 +09:00 committed by Ryan Cavanaugh
parent 5e0afb0d2e
commit 4c11f21e74
4 changed files with 55 additions and 0 deletions

View File

@ -0,0 +1,16 @@
import * as gz from 'gzip-js';
const options = {
level: 3,
name: 'hello-world.txt',
timestamp: Date.now() / 1000,
};
const out = Buffer.from(gz.zip('Hello world', options));
console.log(out);
let buf;
buf = Buffer.from(gz.unzip([42, 42, 42]));
buf = Buffer.from(gz.unzip(Buffer.from([42, 42, 42])));
buf = Buffer.from(gz.unzip(new Uint8Array([42, 42, 42])));
console.log(buf.toString());

15
types/gzip-js/index.d.ts vendored Normal file
View File

@ -0,0 +1,15 @@
// Type definitions for gzip-js 0.3
// Project: https://github.com/beatgammit/gzip-js
// Definitions by: rhysd <https://github.com/rhysd>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
export interface ZipOptions {
level?: number;
name?: string;
timestamp?: number;
}
export function zip(data: string, opts?: ZipOptions): number[];
export function unzip(data: number[] | Buffer | Uint8Array): number[];
export const DEFAULT_LEVEL: number;

View 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",
"gzip-js-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }