Skip to content

A rust library for consuming JavaScript source maps with a focus on performance

License

Notifications You must be signed in to change notification settings

0rvar/js-source-mapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

js-source-mapper

A rust library for consuming JavaScript source maps with a focus on performance. Supports Source Map revision 3.

Build status Crates.io MIT licensed

Documentation

Usage

[dependencies]
js-source-mapper = "0.1.1"
extern crate js_source_mapper;

use js_source_mapper::{Cache, consume};

fn main() {
  let cache = consume(r#"{
    "version": 3,
    "file": "foo.js",
    "sources": ["source.js"],
    "names": ["name1", "name1", "name3"],
    "mappings": ";EAACA;;IAEEA;;MAEEE",
    "sourceRoot": "http://example.com"
  }"#).unwrap();

  let mapping = cache.mapping_for_generated_position(2, 2);
  assert!(mapping.original.line == 1);
  assert!(mapping.original.column == 1);
  assert!(mapping.source == "source.js".into());
  assert!(mapping.name == "name1".into());
}

Development

Fuzzing

To run cargo-fuzz on Windows, run the docker image specified in etc/docker. The following command is handy:

docker run --rm -v <full_path_to_project_root>:/project -w /project cargo-fuzz cargo fuzz run fuzzer_script_1

About

A rust library for consuming JavaScript source maps with a focus on performance

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages