https://github.com/smallhelm/estree-loc
Convert a string start and end indices to an estree loc objects.
https://github.com/smallhelm/estree-loc
Last synced: about 1 year ago
JSON representation
Convert a string start and end indices to an estree loc objects.
- Host: GitHub
- URL: https://github.com/smallhelm/estree-loc
- Owner: smallhelm
- License: mit
- Created: 2016-06-25T00:12:50.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-08-29T14:31:43.000Z (over 9 years ago)
- Last Synced: 2025-02-04T22:28:07.582Z (over 1 year ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# estree-loc
[](https://travis-ci.org/smallhelm/estree-loc)
Convert a string start and end indices to an estree loc objects.
```js
var EStreeLoc = require('estree-loc');
var src = 'one\n two\nthree ';
var toLoc = EStreeLoc(src, 'some-file.js');
var loc = toLoc(8, 17);
```
```js
{
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