A Node.js utility to add consistent indentation to each line of a string with customizable options.
indent-string is a Node.js utility library that adds consistent indentation to each line of a string. It solves the problem of programmatically formatting multi-line text with customizable indentation characters and options for handling empty lines.
JavaScript and Node.js developers who need to format strings for code generation, CLI output, documentation, or any text-based content requiring structured indentation.
Developers choose indent-string for its simplicity, zero dependencies, and flexible API that handles edge cases like empty lines while maintaining minimal overhead.
Indent each line in a string
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The library has no external dependencies, ensuring minimal footprint and easy integration, as stated in the README's key features for performance-sensitive applications.
It allows specifying indentation count and characters, with examples in the README showing usage with spaces and custom symbols like hearts, offering flexibility for different formatting needs.
Includes an option to indent empty lines for visual consistency, a feature highlighted in the README's key features, which helps maintain clean output in formatted text.
The function has sensible defaults and a clean interface, making it easy to use, as demonstrated in the usage examples with straightforward parameter handling.
It only handles indentation; for tasks like dedenting or complex text manipulation, developers must use additional libraries like strip-indent or redent, as referenced in the README, increasing integration overhead.
For basic indentation needs, such as aligning a few lines, using template literals or string repeat methods might be simpler, making this library unnecessary for small-scale projects.