Skip to content

Commit

Permalink
docs: reorganize docs (denoland#2658)
Browse files Browse the repository at this point in the history
  • Loading branch information
crowlKats committed Nov 25, 2022
1 parent 4d16c30 commit aba5017
Show file tree
Hide file tree
Showing 141 changed files with 4,513 additions and 6,592 deletions.
63 changes: 0 additions & 63 deletions archive/README.md

This file was deleted.

106 changes: 51 additions & 55 deletions archive/tar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,61 +33,6 @@
* Provides a `Tar` and `Untar` classes for compressing and decompressing
* arbitrary data.
*
* ## Examples
*
* ### Tar
*
* ```ts
* import { Tar } from "https://deno.land/std@$STD_VERSION/archive/tar.ts";
* import { Buffer } from "https://deno.land/std@$STD_VERSION/io/buffer.ts";
* import { copy } from "https://deno.land/std@$STD_VERSION/streams/conversion.ts";
*
* const tar = new Tar();
* const content = new TextEncoder().encode("Deno.land");
* await tar.append("deno.txt", {
* reader: new Buffer(content),
* contentSize: content.byteLength,
* });
*
* // Or specifying a filePath.
* await tar.append("land.txt", {
* filePath: "./land.txt",
* });
*
* // use tar.getReader() to read the contents.
*
* const writer = await Deno.open("./out.tar", { write: true, create: true });
* await copy(tar.getReader(), writer);
* writer.close();
* ```
*
* ### Untar
*
* ```ts
* import { Untar } from "https://deno.land/std@$STD_VERSION/archive/tar.ts";
* import { ensureFile } from "https://deno.land/std@$STD_VERSION/fs/ensure_file.ts";
* import { ensureDir } from "https://deno.land/std@$STD_VERSION/fs/ensure_dir.ts";
* import { copy } from "https://deno.land/std@$STD_VERSION/streams/conversion.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();
* ```
*
* @module
*/

Expand Down Expand Up @@ -368,6 +313,31 @@ interface TarEntry extends TarMeta {}

/**
* A class to create a tar archive
*
* @example
* ```ts
* import { Tar } from "https://deno.land/std@$STD_VERSION/archive/tar.ts";
* import { Buffer } from "https://deno.land/std@$STD_VERSION/io/buffer.ts";
* import { copy } from "https://deno.land/std@$STD_VERSION/streams/conversion.ts";
*
* const tar = new Tar();
* const content = new TextEncoder().encode("Deno.land");
* await tar.append("deno.txt", {
* reader: new Buffer(content),
* contentSize: content.byteLength,
* });
*
* // Or specifying a filePath.
* await tar.append("land.txt", {
* filePath: "./land.txt",
* });
*
* // use tar.getReader() to read the contents.
*
* const writer = await Deno.open("./out.tar", { write: true, create: true });
* await copy(tar.getReader(), writer);
* writer.close();
* ```
*/
export class Tar {
data: TarDataWithSource[];
Expand Down Expand Up @@ -592,6 +562,32 @@ class TarEntry implements Reader {

/**
* A class to extract a tar archive
*
* @example
* ```ts
* import { Untar } from "https://deno.land/std@$STD_VERSION/archive/tar.ts";
* import { ensureFile } from "https://deno.land/std@$STD_VERSION/fs/ensure_file.ts";
* import { ensureDir } from "https://deno.land/std@$STD_VERSION/fs/ensure_dir.ts";
* import { copy } from "https://deno.land/std@$STD_VERSION/streams/conversion.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();
* ```
*/
export class Untar {
reader: Reader;
Expand Down
Loading

0 comments on commit aba5017

Please sign in to comment.