UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

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