add-line-numbers
Adds line numbers to a source string, padding left and starting at the given offset.
Example
example.js
var addLineNumbers = var stdin =
Now run the following in bash:
node example.js < some-file.js
Resulting output:
1: var addLineNumbers = 2: var test = 3: 4:
Usage
str = addLineNumbers(str, start, delimiter)
Adds a number to the start of each line in the str
text.
start
(Number) number to start counting at, defaults to 1delimiter
(String) joins the number and line, defaults to": "
Returns the transformed string.
License
MIT, see LICENSE.md for details.