diff --git a/types/is-progressive/index.d.ts b/types/is-progressive/index.d.ts new file mode 100644 index 0000000000..3c05ab6fdc --- /dev/null +++ b/types/is-progressive/index.d.ts @@ -0,0 +1,33 @@ +// Type definitions for is-progressive 3.0 +// Project: https://github.com/sindresorhus/is-progressive#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { Readable } from 'stream'; + +/** + * Returns whether the `buffer` is a progressive JPEG image. + * @param buffer Buffer of a JPEG image. + * Must be at least `65535` bytes when the file is larger than that. + */ +export function buffer(buffer: Buffer): boolean; + +/** + * Returns a Promise for a boolean indicating whether the file stream is a progressive JPEG image. + * @param stream Data stream. + */ +export function stream(stream: Readable): Promise; + +/** + * Returns a Promise for a boolean indicating whether the file is a progressive JPEG image. + * @param filepath Filepath to the image. + */ +export function file(filepath: string): Promise; + +/** + * Returns whether the buffer is a progressive JPEG. + * @param filepath Filepath to the image. + */ +export function fileSync(filepath: string): boolean; diff --git a/types/is-progressive/is-progressive-tests.ts b/types/is-progressive/is-progressive-tests.ts new file mode 100644 index 0000000000..b5525962ad --- /dev/null +++ b/types/is-progressive/is-progressive-tests.ts @@ -0,0 +1,12 @@ +import https = require('https'); +import isProgressive = require('is-progressive'); + +isProgressive.file('baseline.jpg'); // $ExpectType Promise + +isProgressive.fileSync('progressive.jpg'); // $ExpectType boolean + +https.get('/', res => { + isProgressive.stream(res); // $ExpectType Promise +}); + +isProgressive.buffer(new Buffer(1)); // $ExpectType boolean diff --git a/types/is-progressive/tsconfig.json b/types/is-progressive/tsconfig.json new file mode 100644 index 0000000000..edc521b158 --- /dev/null +++ b/types/is-progressive/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", + "is-progressive-tests.ts" + ] +} diff --git a/types/is-progressive/tslint.json b/types/is-progressive/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/is-progressive/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }