nano-rows
v1.0.3
Published
Text rows indexer. Calculates text coords (row/col) by character index
Downloads
5
Readme
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})".