@lou.codes/iterables
Version:
🔁 Iterable and AsyncIterable utils
16 lines (15 loc) • 536 B
JavaScript
import { flip } from "@lou.codes/utils";
import { append } from "./append.js";
/**
* Prepends one iterable or asynchronous iterable to another.
*
* @category Asynchronous Generators
* @example
* ```typescript
* const prependNumbers = prepend([0, 1, 2, 3, 4]);
* prependNumbers(["foo", "bar"]); // [0, 1, 2, 3, 4, "foo", "bar"]
* ```
* @param initialIterable Iterable or asynchronous iterable to be appended.
* @returns Curried generator function with `initialIterable` set in context.
*/
export const prepend = flip(append);