Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/capi/deps/std/archive.ts>Untar

[WIP] A framework for crafting interactions with Substrate chains
Latest
class Untar
import { Untar } from "https://deno.land/x/capi@v0.1.1-beta.1/deps/std/archive.ts";

A class to extract a tar archive

Examples

Example 1

import { Untar } from "https://deno.land/std@0.224.0/archive/untar.ts";
import { ensureFile } from "https://deno.land/std@0.224.0/fs/ensure_file.ts";
import { ensureDir } from "https://deno.land/std@0.224.0/fs/ensure_dir.ts";
import { copy } from "https://deno.land/std@0.224.0/streams/copy.ts";

const reader = await Deno.open("./out.tar", { read: true });
const untar = new Untar(reader);

for await (const entry of untar) {
  console.log(entry); // metadata

  if (entry.type === "directory") {
    await ensureDir(entry.fileName);
    continue;
  }

  await ensureFile(entry.fileName);
  const file = await Deno.open(entry.fileName, { write: true });
  // <entry> is a reader.
  await copy(entry, file);
}
reader.close();

Constructors

new
Untar(reader: Reader)

Properties

block: Uint8Array
reader: Reader

Methods

extract(): Promise<TarEntry | null>
[Symbol.asyncIterator](): AsyncIterableIterator<TarEntry>