super fast string index-to-line/column and line/column-to-index translation
GPL-3.0 License
var stringPos = require('coffee-register');
var sample = "abc\n\n123\n \ndef";
stringPos(sample, 0) //-> {line:1, column:0}
stringPos(sample, 2) //-> {line:1, column:2}
stringPos(sample, 4) //-> {line:2, column:0}
stringPos(sample, 7) //-> {line:3, column:2}
stringPos.toIndex(sample, {line:1, column:0}) //-> 0
stringPos.toIndex(sample, {line:1, column:2}) //-> 2
stringPos.toIndex(sample, {line:2, column:0}) //-> 4
stringPos.toIndex(sample, {line:3, column:2}) //-> 7
MIT Daniel Kalen