Archived
1
0
Fork
You've already forked untar-stream
0
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%
Find a file
2022年12月08日 07:48:02 +07:00
src refactor: use TextDecoder again for UTF-8 decode 2022年12月08日 07:48:02 +07:00
test refactor!: use iterable reader instead 2022年11月30日 07:37:25 +07:00
.editorconfig initial commit 2022年11月23日 23:10:09 +07:00
.gitattributes initial commit 2022年11月23日 23:10:09 +07:00
.gitignore initial commit 2022年11月23日 23:10:09 +07:00
.npmrc initial commit 2022年11月23日 23:10:09 +07:00
jsconfig.json chore: set proper moduleResolution 2022年11月30日 07:37:16 +07:00
LICENSE initial commit 2022年11月23日 23:10:09 +07:00
package.json v0.2.0 2022年11月30日 08:22:03 +07:00
README.md docs: don't put web streams usage guide here 2022年12月01日 09:58:25 +07:00

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));
	}
}