add-line-numbers

WebJar for add-line-numbers

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

add-line-numbers
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

add-line-numbers
WebJar for add-line-numbers
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/Jam3/add-line-numbers

Download add-line-numbers

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/add-line-numbers/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>add-line-numbers</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/add-line-numbers/
implementation 'org.webjars.npm:add-line-numbers:1.0.1'
// https://jarcasting.com/artifacts/org.webjars.npm/add-line-numbers/
implementation ("org.webjars.npm:add-line-numbers:1.0.1")
'org.webjars.npm:add-line-numbers:jar:1.0.1'
<dependency org="org.webjars.npm" name="add-line-numbers" rev="1.0.1">
  <artifact name="add-line-numbers" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='add-line-numbers', version='1.0.1')
)
libraryDependencies += "org.webjars.npm" % "add-line-numbers" % "1.0.1"
[org.webjars.npm/add-line-numbers "1.0.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : pad-left jar [1.0.2,2)

Project Modules

There are no modules declared in this project.

add-line-numbers

stable

Adds line numbers to a source string, padding left and starting at the given offset.

Example

example.js

var addLineNumbers = require('add-line-numbers')
var stdin = require('get-stdin')

stdin(function (body) {
  var src = addLineNumbers(body.toString())
  process.stdout.write(src + '\n')
})

Now run the following in bash:

node example.js < some-file.js

Resulting output:

 1: var addLineNumbers = require('./')
 2: var test = require('tape')
 3: 
 4: test('adds line numbers to a source string', function (t) {
 5:   t.equal(addLineNumbers([
 6:     'one',
 7:     'is second'
 8:   ].join('\r\n')), '1: one\n2: is second', 'return carriage')
 9: 
10:   t.equal(addLineNumbers([
11:     'one',
12:     'is second'
13:   ].join('\n'), 0), '0: one\n1: is second', 'start offset')
14: 
...

Usage

NPM

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 1
  • delimiter (String) joins the number and line, defaults to ": "

Returns the transformed string.

License

MIT, see LICENSE.md for details.

org.webjars.npm

Jam3

We create modern experiences for tomorrow’s brands

Versions

Version
1.0.1