1.4.8 • Published 5 years ago

sourcemap-codec v1.4.8

Weekly downloads
5,146,007
License
MIT
Repository
github
Last release
5 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-2800p149-tablesklif-uisvelte-repl-libwinx-form-winxvue-button-test1webcheteapackage-tatespoorman297testapasvavatarsvelte-component-libsvelte-calculatortextio-sorceryvite_vue3_ts_ssssdddddyyyyvs-tree-plusvue-dev-clone@donapot/mylibtest@dimcheify/dimui@docpocalypse/code-live@dishuostec/sapper@cryptocode99/token-lists@cush/sorcery@cush/magic-string@cute-apocalypse/react-tree@dinert/component@c0ldra1n/sapper@percent/percent-api-hookscauseway-concrete-stylesjarlejulien-easy-modaljsx-quick-loaderk0ng_d1nosaur_quenak0ng_d1nosaur_quenbk0ng_d1nosaur_quenck0ng_d1nosaur_quendk0ng_d1nosaur_quenek0ng_d1nosaur_quenfk0ng_d1nosaur_quengk0ng_d1nosaur_quenhk0ng_d1nosaur_quenik0ng_d1nosaur_quenjk0ng_d1nosaur_quenkk0ng_d1nosaur_quennk0ng_d1nosaur_quenok0ng_d1nosaur_quenpk0ng_d1nosaur_quenqk0ng_d1nosaur_quenrk0ng_d1nosaur_quenlk0ng_d1nosaur_quenmk0ng_d1nosaur_quensk0ng_d1nosaur_quentk0ng_d1nosaur_quenuk0ng_d1nosaur_quenvk0ng_d1nosaur_quenwk0ng_d1nosaur_quenxk0ng_d1nosaur_quenyk0ng_d1nosaur_quenzsushi-sdk-ftmvue-credozzzxxxyyy321123stripe-money-formatstyle-guide-mainspacex_cycl3_roamospacex_cycl3_roampspacex_cycl3_roamqspacex_cycl3_roamrspacex_cycl3_roamsspacex_cycl3_roamtspacex_cycl3_roamuspacex_cycl3_roamvspacex_cycl3_roamwspacex_cycl3_roamxspacex_cycl3_roamyspacex_cycl3_roamzspacex_j4vaa_c3qmspacex_j4vad_c3qmspacex_j4vae_c3qmspacex_j4vaf_c3qm
1.4.8

5 years ago

1.4.7

5 years ago

1.4.6

6 years ago

1.4.5

6 years ago

1.4.4

7 years ago

1.4.3

7 years ago

1.4.2

7 years ago

1.4.1

7 years ago

1.4.0

7 years ago

1.3.1

8 years ago

1.3.0

9 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago