@types/convert-source-map

  • Version 1.5.2
  • Published
  • 7.17 kB
  • No dependencies
  • MIT license

Install

npm i @types/convert-source-map
yarn add @types/convert-source-map
pnpm add @types/convert-source-map

Overview

TypeScript definitions for convert-source-map

Index

Variables

variable commentRegex

const commentRegex: RegExp;
  • Returns a new regex used to find source map comments

variable mapFileCommentRegex

const mapFileCommentRegex: RegExp;
  • Returns a new regex used to find source map comments pointing to map files

Functions

function fromBase64

fromBase64: (base64: string) => SourceMapConverter;
  • Returns source map converter from given base64 encoded json string

function fromComment

fromComment: (comment: string) => SourceMapConverter;
  • Returns source map converter from given base64 encoded json string prefixed with //# sourceMappingURL=...

function fromJSON

fromJSON: (json: string) => SourceMapConverter;
  • Returns source map converter from given json string

function fromMapFileComment

fromMapFileComment: (
comment: string,
commentFileDir: string
) => SourceMapConverter;
  • Returns source map converter from given filename by parsing //# sourceMappingURL=filename. filename must point to a file that is found inside the mapFileDir. Most tools store this file right next to the generated file, i.e. the one containing the source map.

function fromMapFileSource

fromMapFileSource: (
content: string,
commentFileDir: string
) => SourceMapConverter | null;
  • Finds last sourcemap comment in file and returns source map converter or returns null if no source map comment was found. The sourcemap will be read from the map file found by parsing # sourceMappingURL=file comment. For more info see fromMapFileComment.

function fromObject

fromObject: (obj: any) => SourceMapConverter;
  • Returns source map converter from given object

function fromSource

fromSource: (content: string) => SourceMapConverter | null;
  • Finds last sourcemap comment in file and returns source map converter or returns null if no source map comment was found.

function generateMapFileComment

generateMapFileComment: (
file: string,
options?: { multiline?: boolean | undefined }
) => string;
  • Returns a comment that links to an external source map via file. By default, the comment is formatted like: //# sourceMappingURL=..., which you would normally see in a JS source file. When options.multiline == true, the comment is formatted like: /*# sourceMappingURL=... */, which you would find in a CSS source file.

function removeComments

removeComments: (src: string) => string;
  • Returns src with all source map comments removed

function removeMapFileComments

removeMapFileComments: (src: string) => string;
  • Returns src with all source map comments pointing to map files removed

Interfaces

interface SourceMapConverter

interface SourceMapConverter {}
  • Converts a source-map from/to different formats and allows adding/changing properties. (documentation based on project's README file)

property sourcemap

sourcemap: any;
  • The parsed sourcemap object

method addProperty

addProperty: (key: string, value: any) => SourceMapConverter;
  • Adds given property to the source map. Throws an error if property already exists

method getProperty

getProperty: (key: string) => any;
  • Gets given property of the source map

method setProperty

setProperty: (key: string, value: any) => SourceMapConverter;
  • Sets given property to the source map. If property doesn't exist it is added, otherwise its value is updated

method toBase64

toBase64: () => string;
  • Converts source map to base64 encoded json string

method toComment

toComment: (options?: { multiline?: boolean | undefined }) => string;
  • Converts source map to an inline comment that can be appended to the source-file. By default, the comment is formatted like: //# sourceMappingURL=..., which you would normally see in a JS source file. When options.multiline == true, the comment is formatted like: /*# sourceMappingURL=... */, which you would find in a CSS source file

method toJSON

toJSON: (space?: string | number) => string;
  • Converts source map to json string. If space is given (optional), this will be passed to JSON.stringify when the JSON string is generated

method toObject

toObject: () => any;
  • Returns a copy of the underlying source map

Package Files (1)

Dependencies (0)

No dependencies.

Dev Dependencies (0)

No dev dependencies.

Peer Dependencies (0)

No peer dependencies.

Badge

To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/convert-source-map.

  • Markdown
    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/convert-source-map)
  • HTML
    <a href="https://www.jsdocs.io/package/@types/convert-source-map"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>