Skip to main content
Module

x/aitertools/mod.ts>assertStreamStartsWith

Well-tested utility functions dealing with async iterables
Go to Latest
function assertStreamStartsWith
import { assertStreamStartsWith } from "https://deno.land/x/aitertools@0.5.0/mod.ts";

Makes an assertion that the beginning elements of the actual iterable are in common with the elements of the expected array.

import { assertStreamStartsWith } from "./testing.ts";
import { count } from "./infinite.ts";

Deno.test("your test name", async () => {
  const stream = count(0, 5);
  await assertStreamStartsWith(stream, [0, 5, 10, 15]);
});

Type Parameters

T

The type of the elements in the actual async iterable and the expected array.

Parameters

actual: AsyncIterable<T>

The async iterable to compare. It can be either finite or infinite.

expected: T[]

The array that contains the expected beginning elements.

optional
msg: string

Optional string message to display if the assertion fails.

Returns

Promise<void>