Socket
Socket
Sign inDemoInstall

@cspotcode/source-map-consumer

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cspotcode/source-map-consumer

Generates and consumes source maps


Version published
Weekly downloads
572K
decreased by-21.04%
Maintainers
1
Weekly downloads
 
Created

What is @cspotcode/source-map-consumer?

@cspotcode/source-map-consumer is a JavaScript library that allows you to work with source maps. Source maps are files that map from the transformed source to the original source, enabling better debugging and error reporting by showing the original source code.

What are @cspotcode/source-map-consumer's main functionalities?

Basic Usage

This code demonstrates how to create a SourceMapConsumer instance with a raw source map object and log the sources.

const { SourceMapConsumer } = require('@cspotcode/source-map-consumer');
const rawSourceMap = { /* raw source map object */ };
SourceMapConsumer.with(rawSourceMap, null, consumer => {
  console.log(consumer.sources);
});

Mapping a Generated Position to an Original Position

This code shows how to map a position in the generated code back to the original source position.

const { SourceMapConsumer } = require('@cspotcode/source-map-consumer');
const rawSourceMap = { /* raw source map object */ };
SourceMapConsumer.with(rawSourceMap, null, consumer => {
  const pos = consumer.originalPositionFor({ line: 2, column: 10 });
  console.log(pos);
});

Mapping an Original Position to a Generated Position

This code demonstrates how to map a position in the original source code to the corresponding position in the generated code.

const { SourceMapConsumer } = require('@cspotcode/source-map-consumer');
const rawSourceMap = { /* raw source map object */ };
SourceMapConsumer.with(rawSourceMap, null, consumer => {
  const pos = consumer.generatedPositionFor({ source: 'source.js', line: 2, column: 10 });
  console.log(pos);
});

Iterating Over Mappings

This code shows how to iterate over all mappings in the source map.

const { SourceMapConsumer } = require('@cspotcode/source-map-consumer');
const rawSourceMap = { /* raw source map object */ };
SourceMapConsumer.with(rawSourceMap, null, consumer => {
  consumer.eachMapping(mapping => {
    console.log(mapping);
  });
});

Other packages similar to @cspotcode/source-map-consumer

FAQs

Package last updated on 21 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc