Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including estree-loc with all npm packages installed. Try it out:

var estreeLoc = require("estree-loc")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

estree-loc v2.0.0

Convert a string start and end indices to an estree loc objects.

estree-loc

build status

Convert a string start and end indices to an estree loc objects.

var EStreeLoc = require('estree-loc');

var src = 'one\n    two\nthree  ';

var toLoc = EStreeLoc(src, 'some-file.js');

var loc = toLoc(8, 17);
{
  source: 'some-file.js'
  start: {line: 2, column: 4},
  end: {line: 3, column: 5}
}

API

toLoc = EStreeLoc(src[, source])

Constructs the toLoc function. If you give it source file path it will add that to each loc.

loc = toLoc(start, end)

Returns the loc object for at the given start and end indices of the source code.

License

MIT

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free