1.4.8 • Published 4 years ago

sourcemap-codec v1.4.8

Weekly downloads
5,146,007
License
MIT
Repository
github
Last release
4 years ago

sourcemap-codec

Encode/decode the mappings property of a sourcemap.

Why?

Sourcemaps are difficult to generate and manipulate, because the mappings property – the part that actually links the generated code back to the original source – is encoded using an obscure method called Variable-length quantity. On top of that, each segment in the mapping contains offsets rather than absolute indices, which means that you can't look at a segment in isolation – you have to understand the whole sourcemap.

This package makes the process slightly easier.

Installation

npm install sourcemap-codec

Usage

import { encode, decode } from 'sourcemap-codec';

var decoded = decode( ';EAEEA,EAAE,EAAC,CAAE;ECQY,UACC' );

assert.deepEqual( decoded, [
	// the first line (of the generated code) has no mappings,
	// as shown by the starting semi-colon (which separates lines)
	[],

	// the second line contains four (comma-separated) segments
	[
		// segments are encoded as you'd expect:
		// [ generatedCodeColumn, sourceIndex, sourceCodeLine, sourceCodeColumn, nameIndex ]

		// i.e. the first segment begins at column 2, and maps back to the second column
		// of the second line (both zero-based) of the 0th source, and uses the 0th
		// name in the `map.names` array
		[ 2, 0, 2, 2, 0 ],

		// the remaining segments are 4-length rather than 5-length,
		// because they don't map a name
		[ 4, 0, 2, 4 ],
		[ 6, 0, 2, 5 ],
		[ 7, 0, 2, 7 ]
	],

	// the final line contains two segments
	[
		[ 2, 1, 10, 19 ],
		[ 12, 1, 11, 20 ]
	]
]);

var encoded = encode( decoded );
assert.equal( encoded, ';EAEEA,EAAE,EAAC,CAAE;ECQY,UACC' );

License

MIT

web-desktop-helperarchetype-library@dinert/utilsvuedragdropuploadimagesnpm-najvece-sranje-sapperkilli8n-react-native-fast-image@nodesoccoop/angular-ncr-srcscloud-archive-s3@texttree/demo-bsa-reference-rclsvazzlegql_din_mod@saeon/ol-reacteverett-svelte@olivervorasai/sliderasterjscogoportutilsunblock-block-save-variables@saaspe/componentsoptimus-dcexpand-react-bridgesklif-ui-kitsklif-api@everything-registry/sub-chunk-2800@314oner_npm/universal-components-libraryp149-tablesklif-uicustome-package-amincotrader-dex-sdkcpcs6_loggerdataormdirectus-extension-filepreview-interface-sbndirectus-extension-delete-users-with-filescss-profilercomplugincss-to-js-sourcemap-corezzzxxxyyy321123escornes-react-bridgeevenietdolorevanutilsex-ikon-components-libraryeditorjs_forkedemr-tabulator-tableseasier_datatableeason_manager_uidskcoreneweslint-config-k3cman-angulareditor.js-custom-multiple-selectedfn-lib-examplefenceoutgarnish-uigenerate-codemicroend-componentmenus-hbr-sappermavectralitepie-datepicker-gabemagic-string-fixm2m-chartjs-plugin-crosshairmama-exportermamlulu-uinpmlaborumlaboremodenetworkjsx-quick-loaderjulien-easy-modalhexyun.helpershoangtvh-vue3-component-libraryicons-vue-testgrids-over-polygonhbr-sapperjarlektortestzsoltbmy-library-buttonmotley-sapperng-search-dropdownnka-gantt-task-reactngrx-undo-v2mydexappmyapp_rands_testmvc-scryptmoonwalkerswap-default-token-listsnumhandlernpool-cli-v2npool-cli-v3npool-cli-v4nuxt-undo-autoimportspetite-design2pickupbiz-npm-packagep147-tablep148-tablepaeckchen-sorcerypoc-cloudflare-middlewaretextio-sorcerytestapatldrawlignintinymce-plugin-toyteapackage-tatespoorman297summerseatestlsvelte-calculatorsvelte-repl-lib
1.4.8

4 years ago

1.4.7

4 years ago

1.4.6

5 years ago

1.4.5

5 years ago

1.4.4

5 years ago

1.4.3

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.1

7 years ago

1.3.0

8 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago