cs (similar to combineStrings)
The cs (combine strings) function joins an array of strings with a configurable separator. By default it joins with a space. Pass false to concatenate without any separator.
Signature
function cs(str: string[], join?: string | false): string
Parameters
str: An array of strings to combine.join: The separator string, orfalseto concatenate directly. Defaults to" "(space).
Return Value
Returns the combined string.
Usage
import { cs, s } from "ts-better-console";
// Join with space (default)
console.log(cs(["Hello", "World"]));
// => "Hello World"
// Concatenate without separator
console.log(cs(["Hello", "World"], false));
// => "HelloWorld"
// Custom separator
console.log(cs(["a", "b", "c"], " | "));
// => "a | b | c"
// Combine styled strings
console.log(cs([s("Error:", { color: "red", styles: ["bold"] }),"Something went wrong",]));
Want to support this project?
If you find ts-better-console useful and want to support its development, consider starring the GitHub repository or buying me a coffee! Your support helps me dedicate more time to improving the library and adding new features.
Want to contribute to this project?
Contributions are welcome! If you're interested in improving the library, fixing bugs, or adding new features, feel free to check out the GitHub repository and submit a pull request. Whether you're a seasoned developer or new to open source, your contributions can make a difference!