Skip to content

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

License

Notifications You must be signed in to change notification settings

smallhelm/estree-loc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published