2.0.4 • Published 3 years ago

vlq v2.0.4

Weekly downloads
1,582,706
License
MIT
Repository
github
Last release
3 years ago

vlq.js

Convert integers to a Base64-encoded VLQ string, and vice versa. No dependencies, works in node.js or browsers, supports AMD.

Why would you want to do that?

Sourcemaps are the most likely use case. Mappings from original source to generated content are encoded as a sequence of VLQ strings.

What is a VLQ string?

A variable-length quantity is a compact way of encoding large integers in text (i.e. in situations where you can't transmit raw binary data). An integer represented as digits will always take up more space than the equivalent VLQ representation:

IntegerVLQ
0A
1C
-1D
1232H
123456789qxmvrH

Installation

npm install vlq

Usage

Encoding

vlq.encode accepts an integer, or an array of integers, and returns a string:

vlq.encode(123); // '2H';
vlq.encode([123, 456, 789]); // '2HwcqxB'

Decoding

vlq.decode accepts a string and always returns an array:

vlq.decode('2H'); // [123]
vlq.decode('2HwcqxB'); // [123, 456, 789]

Limitations

Since JavaScript bitwise operators work on 32 bit integers, the maximum value this library can handle is 2^30 - 1, or 1073741823.

Using vlq.js with sourcemaps

See here for an example of using vlq.js with sourcemaps.

Credits

Adapted from murzwin.com/base64vlq.html by Alexander Pavlov.

License

MIT.

easy-select-rnreact-native-bluetooth2killi8n-react-native-fast-imagereact-native-template-rfbasecloud-archive-s3airscanairscan-examplereact-native-esc-pos-sahaab@borisovart/atol-kkt-moduledeneme323112@ntt_app/react-native-custom-notificationreact-native-custom-text-hwjames@artemis69/rollup-plugin-yoptareact-native-covid-sdkreact-native-printer-brothersrn-pdf-reader-offlinereact-native-shekhar-bridge-testwilscanner@oiti/documentoscopy-react-nativequoc-testreact-native-slider-kfluminos-ui-core@everything-registry/sub-chunk-3064jawwy-sdkjawwy_gamification_releasereact-native-sphereuisphereuijawwy_libraryreact-native-credit-card-pkgp149-tablereact-native-jawwy_samplereact-native-chenaarereqtesifycssreact-native-responsive-sizedemo-test-scrndogandev-simple-toastcss-profilerecrinpayutestingcss-serverfawaterak-online-paymentfawatrak-online-paymentflow-nodeflow-remove-typesfmsl3.0.0jawwy_library_newjawy_library_v1gamification-jawwy-libraryframework_test_library_sixdee_new_jawwyfund-metro-source-mapfund-metro-symbolicatereact-native-experts-sdktest_lib_module_aarfluent.adflow.reactnativesdkfluent.adflow.reactnativesdk-alphafhir2gamification-integration-newframework_test_library_sixdeeframework_test_library_sixdee_newframework_test_library_sixdee_new_newzeo-collectkhaled-salem-custom-components@geeky-apo/react-native-advanced-clipboardgenz-native-elementsgaurav-react-native-loopvue-dev-clonevluevs-fix-source-mapsvs-fix-sourcemapsgenerator-bootstrap-boilerplate-templategriffin-ui-librarygrunt-starlightjrennsoh88-react-native-scroll-indicatorjt-packagejt-vitejt-webpackwifi_configuration_packageipsumnonwc-starterkitvision-camera-plugin-face-detectorvision-camera-plugin-scan-facesvision-camera-base64-resizedvite-plugin-bundlesize@giteeteam/apps-runtime-vm@graines-digitales/nice-handsome-buttonmggauhar@jfilipe-sparta/react-native-module_2native-modal-damage-vehicle@meerasolution/react-native-ms-upi-paymentnew-awesome-4321native-date-picker-modulenative-google-loginnative-kakao-loginnative-apple-login@mapbox/flow-remove-types@hemith/react-native-tnkjordy-frijters-test-lib@idas1/ui-component-lib
2.0.3

3 years ago

2.0.2

3 years ago

2.0.4

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.1

5 years ago

1.0.0

6 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.0

10 years ago