From 4c11f21e749bca8280bdfcf7a1b308b91a2a3ef5 Mon Sep 17 00:00:00 2001 From: Linda_pp Date: Tue, 9 Jan 2018 03:28:02 +0900 Subject: [PATCH] Add types for gzip-js (#22752) --- types/gzip-js/gzip-js-tests.ts | 16 ++++++++++++++++ types/gzip-js/index.d.ts | 15 +++++++++++++++ types/gzip-js/tsconfig.json | 23 +++++++++++++++++++++++ types/gzip-js/tslint.json | 1 + 4 files changed, 55 insertions(+) create mode 100644 types/gzip-js/gzip-js-tests.ts create mode 100644 types/gzip-js/index.d.ts create mode 100644 types/gzip-js/tsconfig.json create mode 100644 types/gzip-js/tslint.json diff --git a/types/gzip-js/gzip-js-tests.ts b/types/gzip-js/gzip-js-tests.ts new file mode 100644 index 0000000000..f492685abe --- /dev/null +++ b/types/gzip-js/gzip-js-tests.ts @@ -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()); diff --git a/types/gzip-js/index.d.ts b/types/gzip-js/index.d.ts new file mode 100644 index 0000000000..2807e698a8 --- /dev/null +++ b/types/gzip-js/index.d.ts @@ -0,0 +1,15 @@ +// Type definitions for gzip-js 0.3 +// Project: https://github.com/beatgammit/gzip-js +// Definitions by: rhysd +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +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; diff --git a/types/gzip-js/tsconfig.json b/types/gzip-js/tsconfig.json new file mode 100644 index 0000000000..a8138e1de9 --- /dev/null +++ b/types/gzip-js/tsconfig.json @@ -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" + ] +} diff --git a/types/gzip-js/tslint.json b/types/gzip-js/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/gzip-js/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }