Skip to content

joeyguo/js-sourcemap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

js-sourcemap

js-sourcemap generator and consumer

Install

npm install js-sourcemap

or use CDN

Usage

generator

import { generator } from 'js-sourcemap';
// use cdn, window.js_sourcemap.generator

var src = `function test(){console.log("js-sourcemap")};`;
var dist = `function test(){
    console.log('js-sourcemap')
}`

var sourcemap = generator(src, dist);

console.log(sourcemap);

consumer

import { consumer } from 'js-sourcemap';
// use cdn, window.js_sourcemap.consumer

var smConsumer = consumer(sourcemap);

// get generated loc by original position
var loc = smConsumer.getGenerated({
    line: lineNum,
    column: columnNum
})

// get original loc by generated position
var loc2 = smConsumer.getOriginal({
    line: lineNum2,
    column: columnNum2
})

Thanks to

  • acorn
  • source-map

About

js-sourcemap generator and consumer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published