diff --git a/types/inflation/index.d.ts b/types/inflation/index.d.ts new file mode 100644 index 0000000000..dab81d72a9 --- /dev/null +++ b/types/inflation/index.d.ts @@ -0,0 +1,27 @@ +// Type definitions for inflation 2.0 +// Project: https://github.com/stream-utils/inflation#readme +// Definitions by: Remco Haszing +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { Readable } from 'stream'; +import { ZlibOptions } from 'zlib'; + +export = inflate; + +/** + * Automatically unzip an HTTP stream. + * + * @returns a stream that emits inflated data from the given stream. + */ +declare function inflate(req: Readable, options?: inflate.Options): Readable; + +declare namespace inflate { + interface Options extends ZlibOptions { + /** + * The encoding of the stream. If not given, will look in `stream.headers['content-encoding']`. + */ + gzip?: 'deflate' | 'gzip' | 'identity'; + } +} diff --git a/types/inflation/inflation-tests.ts b/types/inflation/inflation-tests.ts new file mode 100644 index 0000000000..76db0b4bc5 --- /dev/null +++ b/types/inflation/inflation-tests.ts @@ -0,0 +1,7 @@ +import { createServer } from 'http'; + +import * as inflate from 'inflation'; + +createServer((req, res) => { + inflate(req).pipe(res); +}); diff --git a/types/inflation/tsconfig.json b/types/inflation/tsconfig.json new file mode 100644 index 0000000000..03ca2fdcc8 --- /dev/null +++ b/types/inflation/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "strictFunctionTypes": true, + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "inflation-tests.ts" + ] +} diff --git a/types/inflation/tslint.json b/types/inflation/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/inflation/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }