Skip to content

Commit

Permalink
feat: add types
Browse files Browse the repository at this point in the history
Adds typedefs for this module

BREAKING CHANGE: what was not typed is now typed which may suprise typed codebases
  • Loading branch information
achingbrain committed Aug 4, 2021
1 parent d584f0b commit 6fa8818
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
34 changes: 34 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import BufferList from 'bl/BufferList'

export interface TarEntryHeader {
name: string,
uid: number,
gid: number,
size: number,
mode: number,
mtime: Date,
type: 'file' | 'link' | 'symlink' | 'character-device' | 'block-device' | 'directory' | 'fifo' | 'contiguous-file' | 'pax-header' | 'pax-global-header' | 'gnu-long-link-path' | 'gnu-long-path',
linkname: string | null,
uname: string,
gname: string,
devmajor: number,
devminor: number
}

export interface TarEntry {
header: TarEntryHeader
body: AsyncIterable<Uint8Array>
}

export interface TarImportCandidate {
header: Partial<TarEntryHeader> & { name: string }
body?: AsyncIterable<Uint8Array>
}

export interface ExtractOptions {
highWaterMark: number
filenameEncoding: string
}

export function extract (options?: ExtractOptions): (source: AsyncIterable<Uint8Array>) => AsyncIterable<TarEntry>
export function pack (): (source: AsyncIterable<TarImportCandidate>) => AsyncIterable<BufferList>
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "it-tar is a streaming tar parser (and maybe a generator in the future) and nothing else. It operates purely using async iterables which means you can easily extract/parse tarballs without ever hitting the file system.",
"author": "Alan Shaw",
"dependencies": {
"@types/bl": "^5.0.1",
"bl": "^5.0.0",
"buffer": "^6.0.3",
"iso-constants": "^0.1.2",
Expand Down Expand Up @@ -53,5 +54,6 @@
"repository": {
"type": "git",
"url": "git+https://github.com/alanshaw/it-tar.git"
}
},
"types": "./index.d.ts"
}

0 comments on commit 6fa8818

Please sign in to comment.