Streamable implementation of untar
This repository has been archived on 2024年03月02日 . You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
- JavaScript 98%
- HTML 2%
| src | refactor: use TextDecoder again for UTF-8 decode | |
| test | refactor!: use iterable reader instead | |
| .editorconfig | initial commit | |
| .gitattributes | initial commit | |
| .gitignore | initial commit | |
| .npmrc | initial commit | |
| jsconfig.json | chore: set proper moduleResolution | |
| LICENSE | initial commit | |
| package.json | v0.2.0 | |
| README.md | docs: don't put web streams usage guide here | |
untar-stream
Streamable implementation of untar
This library expects a ReadSeeker interface, you can convert async iterables by
using @intrnl/iterable-reader.
import { createReadStream } from 'node:fs';
import { createIterableReader } from '@intrnl/iterable-reader';
import { Untar } from '@intrnl/untar-stream';
let stream = createReadStream('./archive.tar');
let reader = createIterableReader(stream);
let untar = new Untar(reader);
for await (let entry of untar) {
console.log(entry.name);
if (entry.name === 'actor.json') {
let bytes = new Uint8Array(entry.size);
await entry.read(bytes);
let decoder = new TextDecoder();
let text = decoder.decode(bytes);
console.log(JSON.parse(text));
}
}