From bd4e79efd4ded82d3bb95b308d78e947628307d6 Mon Sep 17 00:00:00 2001 From: Jimi van der Woning Date: Mon, 13 Nov 2017 11:19:45 +0100 Subject: [PATCH] feat: add definitions for gzip-size v4 --- types/gzip-size/index.d.ts | 16 ++++++++++----- types/gzip-size/v3/gzip-size-tests.ts | 7 +++++++ types/gzip-size/v3/index.d.ts | 13 +++++++++++++ types/gzip-size/v3/tsconfig.json | 28 +++++++++++++++++++++++++++ types/gzip-size/v3/tslint.json | 3 +++ 5 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 types/gzip-size/v3/gzip-size-tests.ts create mode 100644 types/gzip-size/v3/index.d.ts create mode 100644 types/gzip-size/v3/tsconfig.json create mode 100644 types/gzip-size/v3/tslint.json diff --git a/types/gzip-size/index.d.ts b/types/gzip-size/index.d.ts index 12b1899b54..cab8ec225b 100644 --- a/types/gzip-size/index.d.ts +++ b/types/gzip-size/index.d.ts @@ -1,13 +1,19 @@ -// Type definitions for gzip-size 3.0 +// Type definitions for gzip-size 4.0 // Project: https://github.com/sindresorhus/gzip-size // Definitions by: York Yao +// Jimi van der Woning // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -declare function gzipSize(input: string | Buffer, callback: (error: Error, size: number) => void): string; -export = gzipSize; +import * as stream from 'stream'; +import * as zlib from 'zlib'; + +declare function gzipSize(input: string | Buffer, options?: zlib.ZlibOptions): Promise; + declare namespace gzipSize { - function sync(input: string | Buffer): number; - function stream(): NodeJS.ReadWriteStream; + function sync(input: string | Buffer, options?: zlib.ZlibOptions): number; + function stream(options?: zlib.ZlibOptions): stream.PassThrough; } + +export = gzipSize; diff --git a/types/gzip-size/v3/gzip-size-tests.ts b/types/gzip-size/v3/gzip-size-tests.ts new file mode 100644 index 0000000000..f07d99bd50 --- /dev/null +++ b/types/gzip-size/v3/gzip-size-tests.ts @@ -0,0 +1,7 @@ +import gzipSize = require('gzip-size'); + +const string = 'Lorem ipsum dolor sit amet.'; + +console.log(string.length); + +console.log(gzipSize.sync(string)); diff --git a/types/gzip-size/v3/index.d.ts b/types/gzip-size/v3/index.d.ts new file mode 100644 index 0000000000..12b1899b54 --- /dev/null +++ b/types/gzip-size/v3/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for gzip-size 3.0 +// Project: https://github.com/sindresorhus/gzip-size +// Definitions by: York Yao +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare function gzipSize(input: string | Buffer, callback: (error: Error, size: number) => void): string; +export = gzipSize; +declare namespace gzipSize { + function sync(input: string | Buffer): number; + function stream(): NodeJS.ReadWriteStream; +} diff --git a/types/gzip-size/v3/tsconfig.json b/types/gzip-size/v3/tsconfig.json new file mode 100644 index 0000000000..88a695711b --- /dev/null +++ b/types/gzip-size/v3/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "paths": { + "gzip-size": [ + "gzip-size/v3" + ] + }, + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "gzip-size-tests.ts" + ] +} diff --git a/types/gzip-size/v3/tslint.json b/types/gzip-size/v3/tslint.json new file mode 100644 index 0000000000..e60c15844f --- /dev/null +++ b/types/gzip-size/v3/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file