From 3a93a2f559f40f56d92a11cc61317472c6fad29c Mon Sep 17 00:00:00 2001 From: Paolo Insogna Date: Wed, 20 Dec 2023 16:15:38 +0100 Subject: [PATCH] chore: Updated dependencies. --- package.json | 20 ++++++++++---------- src/index.ts | 11 ++++++----- src/internals.ts | 2 +- src/stream.ts | 6 +++--- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index c9356f3..17ace53 100644 --- a/package.json +++ b/package.json @@ -52,21 +52,21 @@ }, "dependencies": { "image-size": "^1.0.2", - "undici": "^5.26.5" + "undici": "^6.1.0" }, "devDependencies": { - "@cowtech/eslint-config": "^8.10.0", - "@swc/cli": "^0.1.62", - "@swc/core": "^1.3.94", - "@types/node": "^20.8.7", - "@types/tap": "^15.0.10", + "@cowtech/eslint-config": "^9.0.0", + "@swc/cli": "^0.1.63", + "@swc/core": "^1.3.101", + "@types/node": "^20.10.5", + "@types/tap": "^15.0.11", "c8": "^8.0.1", "chokidar": "^3.5.3", "concurrently": "^8.2.2", - "prettier": "^3.0.3", - "tap": "^18.5.2", - "ts-node": "^10.9.1", - "typescript": "^5.2.2" + "prettier": "^3.1.1", + "tap": "^18.6.1", + "ts-node": "^10.9.2", + "typescript": "^5.3.3" }, "engines": { "node": ">= 18.18.0" diff --git a/src/index.ts b/src/index.ts index f91c77a..68b49bf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,11 +1,11 @@ import EventEmitter from 'node:events' import { type Stream, type Writable, type WritableOptions } from 'node:stream' -import { type Callback, ensurePromiseCallback } from './callback.js' +import { ensurePromiseCallback, type Callback } from './callback.js' import { handleData, handleError, toStream } from './internals.js' -import { defaultOptions, FastImageError, type ImageInfo, type Options } from './models.js' +import { FastImageError, defaultOptions, type ImageInfo, type Options } from './models.js' import { FastImageStream } from './stream.js' -export { defaultOptions, FastImageError } from './models.js' +export { FastImageError, defaultOptions } from './models.js' export async function info( source: string | Stream | Buffer, @@ -40,7 +40,7 @@ export async function info( finished = handleData(buffer, headers, threshold, start, aborter, callback) }) - stream.on('error', error => { + stream.on('error', (error: FastImageError) => { callback(handleError(error, url!)) }) @@ -55,7 +55,8 @@ export async function info( return promise! } catch (error) { - callback(error) + // eslint-disable-next-line n/no-callback-literal + callback(error as Error) return promise! } } diff --git a/src/internals.ts b/src/internals.ts index 685778b..ca2617b 100644 --- a/src/internals.ts +++ b/src/internals.ts @@ -62,7 +62,7 @@ export async function toStream( if ((error as FastImageError).code === 'FASTIMAGE_URL_ERROR') { throw error } else if (url) { - throw handleError(error, url) + throw handleError(error as FastImageError, url) } // Parsing failed. Treat as local file diff --git a/src/stream.ts b/src/stream.ts index 810c79e..bb0640c 100644 --- a/src/stream.ts +++ b/src/stream.ts @@ -1,7 +1,7 @@ import EventEmitter from 'node:events' import { Writable, type WritableOptions } from 'node:stream' import { handleData } from './internals.js' -import { defaultOptions, FastImageError, type Options } from './models.js' +import { FastImageError, defaultOptions, type Options } from './models.js' export class FastImageStream extends Writable { buffer: Buffer @@ -39,13 +39,13 @@ export class FastImageStream extends Writable { ) } - _write(chunk: any, _e: BufferEncoding, cb: (error?: Error | null) => void): void { + _write(chunk: Buffer, _e: BufferEncoding, cb: (error?: Error | null) => void): void { this.analyze(chunk) cb() } /* c8 ignore start */ - _writev(chunks: { chunk: any }[], cb: (error?: Error | null) => void): void { + _writev(chunks: { chunk: Buffer }[], cb: (error?: Error | null) => void): void { for (const { chunk } of chunks) { this.analyze(chunk) }