UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

24 lines (22 loc) 588 B
import { dfdlT } from "@monstermann/dfdl"; //#region src/string/prepend.ts /** * `prepend(target, source)` * * Prepends `string` or strings from `source` iterable to the beginning of `target` string. * * ```ts * prepend("world", "hello "); // "hello world" * prepend("world", ["hello", " "]); // "hello world" * ``` * * ```ts * pipe("world", prepend("hello ")); // "hello world" * pipe("world", prepend(["hello", " "])); // "hello world" * ``` */ const prepend = dfdlT((a, b) => { return (typeof b === "string" ? b : Array.from(b).join("")) + a; }, 2); //#endregion export { prepend };