Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types: add type declarations #20

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
50 changes: 50 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/// <reference types="node" />
import Minipass, { Encoding } from 'minipass'
import type { Mode } from 'node:fs'

export class ReadStream extends Minipass {
constructor(
path: string,
options?: {
fd?: number
readSize?: number
size?: number
autoClose: boolean
}
)

get fd(): number
get path(): string

readable: false
writeable: true
}

export class ReadStreamSync extends ReadStream {}

export class WriteStream extends Minipass {
constructor(
path: string,
options?: {
fd?: number
mode?: Mode
start?: number
autoClose?: boolean
flags?: string
}
)

get fd(): number
get path(): string

end(cb?: () => void): never
end(chunk: any, cb?: () => void): never
end(chunk: any, encoding?: Encoding, cb?: () => void): never
end(buf: Buffer | string, enc: BufferEncoding, cb?: () => void): this

write(chunk: any, cb?: () => void): never
write(chunk: any, encoding?: Encoding, cb?: () => void): never
write(buf: Buffer | string, enc: BufferEncoding): boolean
}

export class WriteStreamSync extends WriteStream {}
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "fs-minipass",
"version": "2.1.0",
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"test": "tap",
"preversion": "npm test",
Expand All @@ -24,11 +25,14 @@
"minipass": "^3.0.0"
},
"devDependencies": {
"@types/node": "^18.11.9",
"mutate-fs": "^2.0.1",
"tap": "^15.0.10"
"tap": "^15.0.10",
"typescript": "^4.8.4"
},
"files": [
"index.js"
"index.js",
"index.d.ts"
],
"tap": {
"check-coverage": true
Expand Down