Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Updates a mozilla AST(produced by acorn/esprima) with location info from a source map
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src
test
.gitignore
.jshintrc
.npmignore
Gruntfile.js
LICENSE-MIT
Makefile
README.mkd
package.json

README.mkd

sourcemap-to-ast

Updates a mozilla AST(produced by acorn/esprima) with location info from a source map

Installation

npm install --save sourcemap-to-ast

Usage

var acorn = require('acorn');
var coffee = require('coffee-script');
var sourceMapToAst = require('sourcemap-to-ast');

var compiled = coffee.compile('x =\n 1', {sourceMap: true});
var ast = acorn.parse(compiled.js, {locations: true});

var func = ast.body[0].expression.callee.object;
var funcBody = func.body.body;
var assignment = funcBody[1].expression;

sourceMapToAst(ast, compiled.v3SourceMap);

assignment.loc.start // {line: 1, column: 0}
assignment.loc.end // {line: 2, column: 1}
Something went wrong with that request. Please try again.