archive-stream
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

node-archive-stream

Unix ar archives stream for Node.js

Example

  • ReadStream
export interface IArchiveEntry {
  name: string;
  mtime: number;
  ownerId: number;
  groupId: number;
  mode: string;
  size: number;
  content: Buffer;
}
import { createReadStream } from "fs";
import { createArchiveStream } from "../lib";

const archiveStream = createArchiveStream();
const rs = createReadStream("test.deb");
rs.pipe(archiveStream);

archiveStream.on("data", (x: IArchiveEntry) => console.log(x));
  • WriteStream
export interface WriteArchiveEntry
  extends Omit<IArchiveEntry, "content" | "size"> {
  size?: number; //10
  content: Buffer | ArrayBufferLike | Readable;
}
import { createWriteStream } from "fs";
import { createUnArchiveStream, WriteArchiveEntry } from "../lib";

const unArchiveStream = createUnArchiveStream();
const ws = createWriteStream("test.deb");
unArchiveStream.pipe(ws);

unArchiveStream.write({
  name: "test.log",
  mtime: 0,
  ownerId: 0,
  groupId: 0,
  mode: "644",
  content: Buffer.from("test\n"),
} as WriteArchiveEntry);
  • Handle
import { Archive } from "../lib";
const archive = await Archive.open("tests/example.deb", {
  //   noEndCheck: true,
});
console.log(archive.entries);
/**  @type {ArchiveEntry};*/
const data = archive.entries.find((item) => item.name == "control.tar.zst");
console.log(await archive.read(data!));

Reference:

Ar_(Unix) - Wikipedia

LICENSE

MIT LICENSE

Package Sidebar

Install

npm i archive-stream

Weekly Downloads

1

Version

0.0.4

License

MIT

Unpacked Size

15.5 kB

Total Files

6

Last publish

Collaborators

  • system233