Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report

@jridgewell/trace-mapping 0.3.22

Trace the original position through a source map
Package summary
Share
0
issues
0
licenses
Package created
18 Jan 2022
Version published
19 Jan 2024
Maintainers
1
Total deps
0
Direct deps
0
License
MIT
Generating a report...
Hold on while we generate a fresh audit report for this package.

Frequently Asked Questions

What does @jridgewell/trace-mapping do?

The @jridgewell/trace-mapping package serves as a powerful tool for developers working with JavaScript source maps. This package aids in tracing the original location in a source file from the line and column of an output file via a source map. For those already acquainted with the source-map package's SourceMapConsumer, they will find this package delivers similar functionalities like originalPositionFor and generatedPositionFor API without the necessity of WASM.

How do you use @jridgewell/trace-mapping?

To utilize @jridgewell/trace-mapping, you first need to install the package via npm using the command npm install @jridgewell/trace-mapping. Then, you can import the required functions from @jridgewell/trace-mapping in your script.

Here is an example of its usage:

import {
  TraceMap,
  originalPositionFor,
  generatedPositionFor,
  sourceContentFor,
} from '@jridgewell/trace-mapping';

const tracer = new TraceMap({
  version: 3,
  sources: ['input.js'],
  sourcesContent: ['content of input.js'],
  names: ['foo'],
  mappings: 'KAyCIA',
});

// Lines start at line 1, columns at column 0.
const traced = originalPositionFor(tracer, { line: 1, column: 5 });
//...

You can also use it for sectioned sourcemaps by utilizing the AnyMap helper:

import { AnyMap } from '@jridgewell/trace-mapping';

const sectioned = new AnyMap({
  version: 3,
  sections: [
    // Your sections here...
  ],
});

const traced = originalPositionFor(sectioned, {
  line: 2,
  column: 0,
});
//...

Where are the @jridgewell/trace-mapping docs?

The documentation for the @jridgewell/trace-mapping package isn't hosted on a dedicated site but is instead available directly on the package's GitHub page. Here you'll find detailed explanations of the package's functionalities, requirements, and usage examples.