UNPKG

asyncerator

Version:

Provide supporting types for AsyncIterable/AsyncIterableIterators, promisified stream.pipeline implementation, and Array-like utility operators, sources and sinks.

23 lines (18 loc) 488 B
// operator/after.ts /* * Copyright (c) 2021-2024 Check Digit, LLC * * This code is licensed under the MIT license (see LICENSE.txt for details). */ import type { Asyncerator } from '../asyncerator'; import type { Operator } from './index'; /** * Emit a value after stream completes. * @param value */ export default function <Input>(value: Input): Operator<Input, Input> { return async function* (iterator: Asyncerator<Input>) { yield* iterator; yield value; }; }