Skip to main content
Module

x/streamtools/pop_test.ts

🦕 This is a Deno module that provides utilities for handling Streams API.
Latest
File
import { assertEquals } from "@std/assert";import { pop } from "./pop.ts";
Deno.test("pop", async (t) => { await t.step( "returns the next item in the stream or null if the stream is closed", async () => { const stream = new ReadableStream<number>({ start(controller) { controller.enqueue(1); controller.enqueue(2); controller.enqueue(3); controller.close(); }, }); assertEquals(await pop(stream), 1); assertEquals(await pop(stream), 2); assertEquals(await pop(stream), 3); assertEquals(await pop(stream), null); }, );});