0.1.1 • Published 7 years ago

translocator v0.1.1

Weekly downloads
1
License
-
Repository
-
Last release
7 years ago

translocator build status

testling badge

Convert line-column locations to ranges and vice-versa.

var assert = require('assert');

var text = [
    'line0'
  , 'line1'
].join('\n');

var translocator = require('../')(text);

var locations = { start: { line: 0, column: 2 }, end: { line: 1, column: 3 } };
var range     = translocator.range(locations.start, locations.end)

console.dir({ range: range, subtext: text.slice(range[0], range[1]) });

assert.deepEqual(translocator.locations(range), locations);

// => { range: [ 2, 9 ], subtext: 'ne0\nlin' }

Installation

npm install translocator

API

generated with docme

License

MIT

0.1.1

7 years ago

0.1.0

7 years ago