nano-rows

1.0.3 • Public • Published

Gitter NPM version Build status Test coverage Dependency Status License Downloads

nano-rows

Text rows indexer. Calculates text coords (row/col) by character index.

var Rows = require('nano-rows');
 
var index = new Rows(fs.readFile('source.txt', 'utf8'), 'source.txt');
 
try {
    console.log(index.get_label(index.indexOf('blah')), '"blah" position');
} catch (e) {
    console.log('no "blah" found');
}

API

Constructor: Rows(text, name)

  • text String
  • name String -- text name

rows.get_coords(offset)

Returns [ row, col ] for the character offset.

rows.get_label(offset)

Returns text like "{text-name}({row},{col})".

Readme

Keywords

Package Sidebar

Install

npm i nano-rows

Weekly Downloads

0

Version

1.0.3

License

MIT

Last publish

Collaborators

  • holixus