17 lines
506 B
TypeScript
17 lines
506 B
TypeScript
import { Readable } from "stream";
|
|
import test from "ava";
|
|
import { expect } from "chai";
|
|
import mhysa from "../src";
|
|
const { last } = mhysa();
|
|
|
|
test("last() resolves to the last chunk streamed by the given readable stream", async t => {
|
|
const source = new Readable({ objectMode: true });
|
|
const lastPromise = last(source);
|
|
source.push("ab");
|
|
source.push("cd");
|
|
source.push("ef");
|
|
source.push(null);
|
|
const lastChunk = await lastPromise;
|
|
expect(lastChunk).to.equal("ef");
|
|
});
|