Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

ivis-mizuguchi ce83af7f52 git-annex in jovyan@jupyter-ivis-5frino-5fmizuguchi-40rdm-2enii-2eac-2ejp--ivis-2dm:~/ před 2 roky
..
.yarn-metadata.json ce83af7f52 git-annex in jovyan@jupyter-ivis-5frino-5fmizuguchi-40rdm-2enii-2eac-2ejp--ivis-2dm:~/ před 2 roky
.yarn-tarball.tgz ce83af7f52 git-annex in jovyan@jupyter-ivis-5frino-5fmizuguchi-40rdm-2enii-2eac-2ejp--ivis-2dm:~/ před 2 roky
LICENSE.md ce83af7f52 git-annex in jovyan@jupyter-ivis-5frino-5fmizuguchi-40rdm-2enii-2eac-2ejp--ivis-2dm:~/ před 2 roky
README.md ce83af7f52 git-annex in jovyan@jupyter-ivis-5frino-5fmizuguchi-40rdm-2enii-2eac-2ejp--ivis-2dm:~/ před 2 roky
index.js ce83af7f52 git-annex in jovyan@jupyter-ivis-5frino-5fmizuguchi-40rdm-2enii-2eac-2ejp--ivis-2dm:~/ před 2 roky
package.json ce83af7f52 git-annex in jovyan@jupyter-ivis-5frino-5fmizuguchi-40rdm-2enii-2eac-2ejp--ivis-2dm:~/ před 2 roky

README.md

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.