Merge pull request #32269 from BendingBender/is-progressive

[is-progressive] Add types
This commit is contained in:
Daniel Rosenwasser
2019-01-17 15:25:00 -08:00
committed by GitHub
4 changed files with 69 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
// Type definitions for is-progressive 3.0
// Project: https://github.com/sindresorhus/is-progressive#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
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<boolean>;
/**
* 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<boolean>;
/**
* Returns whether the buffer is a progressive JPEG.
* @param filepath Filepath to the image.
*/
export function fileSync(filepath: string): boolean;
@@ -0,0 +1,12 @@
import https = require('https');
import isProgressive = require('is-progressive');
isProgressive.file('baseline.jpg'); // $ExpectType Promise<boolean>
isProgressive.fileSync('progressive.jpg'); // $ExpectType boolean
https.get('/', res => {
isProgressive.stream(res); // $ExpectType Promise<boolean>
});
isProgressive.buffer(new Buffer(1)); // $ExpectType boolean
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }