diff --git a/types/node-gzip/index.d.ts b/types/node-gzip/index.d.ts new file mode 100644 index 0000000000..f599f2461d --- /dev/null +++ b/types/node-gzip/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for node-gzip 1.1 +// Project: https://github.com/Rebsos/node-gzip#readme +// Definitions by: mike castleman +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// TypeScript Version: 2.1 + +/// + +import { InputType, ZlibOptions } from 'zlib'; + +export function gzip(input: InputType, options?: ZlibOptions): Promise; +export function ungzip(input: InputType, options?: ZlibOptions): Promise; diff --git a/types/node-gzip/node-gzip-tests.ts b/types/node-gzip/node-gzip-tests.ts new file mode 100644 index 0000000000..bbe979e7df --- /dev/null +++ b/types/node-gzip/node-gzip-tests.ts @@ -0,0 +1,16 @@ +import { gzip, ungzip } from 'node-gzip'; + +const testGzip = async () => { + const someBuffer = Buffer.from('hello'); + const zipped1 = await gzip(someBuffer); + + const zipped2 = await gzip('gzipping a string directly'); + + return [zipped1.byteLength, zipped2[0]]; +}; + +const testUngzip = async () => { + const data = Buffer.from('H4sICHeEGV0AA2EA4wIAkwbXMgEAAAA=', 'base64'); + const ungzipped = await ungzip(data); + return ungzipped.toString('utf-8'); +}; diff --git a/types/node-gzip/tsconfig.json b/types/node-gzip/tsconfig.json new file mode 100644 index 0000000000..e3bbf143c9 --- /dev/null +++ b/types/node-gzip/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "node-gzip-tests.ts" + ] +} diff --git a/types/node-gzip/tslint.json b/types/node-gzip/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/node-gzip/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }