MCPcopy Create free account
hub / github.com/denoland/std / createReadable

Function createReadable

tar/tar_stream_test.ts:77–98  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

75Deno.test("TarStream() supports byte streams", async () => {
76 const mtime = Date.now() / 1000 | 0;
77 async function createReadable(): Promise<ReadableStream<Uint8Array_>> {
78 return ReadableStream
79 .from<TarStreamInput>([
80 { type: "directory", path: "./potato", options: { mtime } }, // 512
81 {
82 type: "file",
83 path: "./potato/text.txt",
84 size: 12,
85 readable: ReadableStream
86 .from([new TextEncoder().encode("Hello World!")]),
87 options: { mtime },
88 }, // 1024
89 {
90 type: "file",
91 path: "./potato/deno.json",
92 size: (await Deno.stat("deno.json")).size,
93 readable: (await Deno.open("deno.json")).readable,
94 options: { mtime },
95 }, // 512 + ceil(size / 512) * 512
96 ]) // 1024
97 .pipeThrough(new TarStream());
98 }
99
100 const expected = await new Response(await createReadable()).bytes();
101 for (let i = 1; i <= 1025; ++i) {

Callers 1

tar_stream_test.tsFile · 0.85

Calls 2

statMethod · 0.65
fromMethod · 0.45

Tested by

no test coverage detected