leftpad-rs
Why bother making your own left padding function in like 2 minutes when you can instead download this awesome library that gives you the most
If you haven't already, first install Rust, since this package relies on a rust binary to deliver those indredulously quick leftpads.
Install this package like so:
npm install @leftpad-rs/core
To use it, simply write:
import { leftpad } from "@leftpad-rs/core";
console.log(leftpad("Hello World!", 5));
// Hello World!
The function takes in three arguments:
- input (required): The string to leftpad
- length (required): The number of spaces to leftpad by, must be a positive number
- pattern: The pattern to repeat by, default is a whitespace " ", can be any string