Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@parcel/source-map

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@parcel/source-map

  • 2.0.0-nightly.88
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @parcel/source-map?

@parcel/source-map is a library for working with source maps, which are files that map from the transformed source code back to the original source code. This is useful for debugging and understanding the transformations applied to the code.

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

Creating a Source Map

This feature allows you to create a new source map and add mappings to it using VLQ (Variable Length Quantity) encoding.

const { SourceMap } = require('@parcel/source-map');
const map = new SourceMap();
map.addVLQMap({
  version: 3,
  file: 'out.js',
  sources: ['foo.js', 'bar.js'],
  names: ['src', 'maps', 'are', 'fun'],
  mappings: 'AA,AB;;ABCDE;' // VLQ encoded mappings
});
console.log(map.toBuffer());

Adding a Mapping

This feature allows you to add individual mappings to the source map, specifying the generated and original positions, the source file, and an optional name.

const { SourceMap } = require('@parcel/source-map');
const map = new SourceMap();
map.addMapping({
  generated: { line: 1, column: 5 },
  original: { line: 2, column: 10 },
  source: 'source.js',
  name: 'myFunction'
});
console.log(map.toBuffer());

Loading an Existing Source Map

This feature allows you to load an existing source map into the SourceMap object, enabling further manipulation or inspection.

const { SourceMap } = require('@parcel/source-map');
const existingMap = {
  version: 3,
  file: 'out.js',
  sources: ['foo.js', 'bar.js'],
  names: ['src', 'maps', 'are', 'fun'],
  mappings: 'AA,AB;;ABCDE;'
};
const map = new SourceMap();
map.addVLQMap(existingMap);
console.log(map.toBuffer());

Generating Source Map Buffer

This feature allows you to generate a buffer representation of the source map, which can be written to a file or used in other ways.

const { SourceMap } = require('@parcel/source-map');
const map = new SourceMap();
map.addMapping({
  generated: { line: 1, column: 5 },
  original: { line: 2, column: 10 },
  source: 'source.js',
  name: 'myFunction'
});
const buffer = map.toBuffer();
console.log(buffer);

Other packages similar to @parcel/source-map

FAQs

Package last updated on 09 Feb 2020

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