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