-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Require Node.js 12.20 and move to ESM
- Loading branch information
1 parent
ed6da27
commit 6ee615d
Showing
8 changed files
with
109 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,79 @@ | ||
/// <reference types="node"/> | ||
import {Readable as ReadableStream} from 'stream'; | ||
import {Buffer} from 'node:buffer'; | ||
import {Readable as ReadableStream} from 'node:stream'; | ||
|
||
/** | ||
Checks if a `Buffer` contains a JPEG image that is [progressive](http://www.faqs.org/faqs/jpeg-faq/part1/section-11.html). | ||
declare const isProgressive: { | ||
/** | ||
Checks if a `Buffer` contains a JPEG image that is [progressive](http://www.faqs.org/faqs/jpeg-faq/part1/section-11.html). | ||
@param buffer - Buffer of a JPEG image. Must be at least `65535` bytes when the file is larger than that. | ||
@returns Whether the `buffer` is a progressive JPEG image. | ||
@param buffer - The buffer of a JPEG image. Must be at least `65535` bytes when the file is larger than that. | ||
@returns Whether the `buffer` is a progressive JPEG image. | ||
@example | ||
``` | ||
import {promisify} from 'util'; | ||
import {readFile} from 'fs'; | ||
import isProgressive = require('is-progressive'); | ||
@example | ||
``` | ||
import {promisify} from 'node:util'; | ||
import {readFile} from 'node:fs/promises'; | ||
import isProgressive from 'is-progressive'; | ||
const readFileP = promisify(readFile); | ||
(async () => { | ||
const buffer = await readFileP('baseline.jpg'); | ||
const buffer = await readFile('baseline.jpg'); | ||
console.log(await isProgressive.buffer(buffer)); | ||
//=> false | ||
})(); | ||
``` | ||
*/ | ||
export function buffer(buffer: Buffer): boolean; | ||
``` | ||
*/ | ||
buffer(buffer: Buffer): boolean; | ||
|
||
/** | ||
Checks if a `stream.Readable` produces a JPEG image that is [progressive](http://www.faqs.org/faqs/jpeg-faq/part1/section-11.html). | ||
/** | ||
Checks if a `stream.Readable` produces a JPEG image that is [progressive](http://www.faqs.org/faqs/jpeg-faq/part1/section-11.html). | ||
@param stream - Data stream with a JPEG image. | ||
@returns Whether the `stream` is a progressive JPEG image. | ||
@param stream - A data stream with a JPEG image. | ||
@returns Whether the `stream` is a progressive JPEG image. | ||
@example | ||
``` | ||
// Check if a remote JPEG image is progressive without downloading the whole file | ||
import * as https from 'https'; | ||
import isProgressive = require('is-progressive'); | ||
@example | ||
``` | ||
// Check if a remote JPEG image is progressive without downloading the whole file | ||
import https from 'https'; | ||
import isProgressive from 'is-progressive'; | ||
const url = 'https://raw.githubusercontent.com/sindresorhus/is-progressive/main/fixture/progressive.jpg'; | ||
const url = 'https://raw.githubusercontent.com/sindresorhus/is-progressive/main/fixture/progressive.jpg'; | ||
https.get(url, async response => { | ||
console.log(await isProgressive.stream(response)); | ||
//=> true | ||
}); | ||
``` | ||
*/ | ||
export function stream(stream: ReadableStream): Promise<boolean>; | ||
https.get(url, async response => { | ||
console.log(await isProgressive.stream(response)); | ||
//=> true | ||
}); | ||
``` | ||
*/ | ||
stream(stream: ReadableStream): Promise<boolean>; | ||
|
||
/** | ||
Checks if a file is a JPEG image that is [progressive](http://www.faqs.org/faqs/jpeg-faq/part1/section-11.html). | ||
/** | ||
Checks if a file is a JPEG image that is [progressive](http://www.faqs.org/faqs/jpeg-faq/part1/section-11.html). | ||
@param filePath - File path to the image. | ||
@returns Whether the file at the `filePath` is a progressive JPEG image. | ||
@param filePath - The file path to the image. | ||
@returns Whether the file at the `filePath` is a progressive JPEG image. | ||
@example | ||
``` | ||
import isProgressive = require('is-progressive'); | ||
@example | ||
``` | ||
import isProgressive from 'is-progressive'; | ||
(async () => { | ||
console.log(await isProgressive.file('baseline.jpg')); | ||
//=> false | ||
})(); | ||
``` | ||
*/ | ||
export function file(filePath: string): Promise<boolean>; | ||
|
||
/** | ||
Synchronously checks if a file is a JPEG image that is [progressive](http://www.faqs.org/faqs/jpeg-faq/part1/section-11.html). | ||
@param filePath - File path to the image. | ||
@returns Whether the the file at the `filePath` is a progressive JPEG. | ||
@example | ||
``` | ||
import isProgressive = require('is-progressive'); | ||
isProgressive.fileSync('progressive.jpg'); | ||
//=> true | ||
``` | ||
*/ | ||
export function fileSync(filePath: string): boolean; | ||
``` | ||
*/ | ||
file(filePath: string): Promise<boolean>; | ||
|
||
/** | ||
Synchronously checks if a file is a JPEG image that is [progressive](http://www.faqs.org/faqs/jpeg-faq/part1/section-11.html). | ||
@param filePath - The file path to the image. | ||
@returns Whether the the file at the `filePath` is a progressive JPEG. | ||
@example | ||
``` | ||
import isProgressive from 'is-progressive'; | ||
isProgressive.fileSync('progressive.jpg'); | ||
//=> true | ||
``` | ||
*/ | ||
fileSync(filePath: string): boolean; | ||
}; | ||
|
||
export default isProgressive; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import {Buffer} from 'node:buffer'; | ||
import https from 'node:https'; | ||
import {expectType} from 'tsd'; | ||
import * as https from 'https'; | ||
import isProgressive = require('.'); | ||
import isProgressive from './index.js'; | ||
|
||
expectType<Promise<boolean>>(isProgressive.file('baseline.jpg')); | ||
expectType<boolean>(isProgressive.fileSync('progressive.jpg')); | ||
https.get('/', response => { | ||
expectType<Promise<boolean>>(isProgressive.stream(response)); | ||
}); | ||
expectType<boolean>(isProgressive.buffer(Buffer.from(1))); | ||
expectType<boolean>(isProgressive.buffer(Buffer.from('1'))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters