WIP - add extractor, generate snippet_data
This commit is contained in:
21
node_modules/vlq/CHANGELOG.md
generated
vendored
Normal file
21
node_modules/vlq/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
# changelog
|
||||
|
||||
## 0.2.3
|
||||
|
||||
* Add LICENSE to npm package
|
||||
|
||||
## 0.2.2
|
||||
|
||||
* Expose `pkg.module`, not `jsnext:main`
|
||||
|
||||
## 0.2.1
|
||||
|
||||
* Performance boost - vlq no longer checks that you've passed a number or an array into `vlq.encode()`, making it significantly faster
|
||||
|
||||
## 0.2.0
|
||||
|
||||
* Author as ES6 module, accessible to ES6-aware systems via the `jsnext:main` field in `package.json`
|
||||
|
||||
## 0.1.0
|
||||
|
||||
* First release
|
||||
7
node_modules/vlq/LICENSE
generated
vendored
Normal file
7
node_modules/vlq/LICENSE
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
Copyright (c) 2017 [these people](https://github.com/Rich-Harris/vlq/graphs/contributors)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
73
node_modules/vlq/README.md
generated
vendored
Normal file
73
node_modules/vlq/README.md
generated
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
# 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](http://en.wikipedia.org/wiki/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:
|
||||
|
||||
| Integer | VLQ |
|
||||
| :------------------ | :--------- |
|
||||
| 0 | A |
|
||||
| 1 | C |
|
||||
| -1 | D |
|
||||
| 123 | 2H |
|
||||
| 123456789 | qxmvrH |
|
||||
| 123456789123456789 | gxvh6sB |
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install vlq
|
||||
```
|
||||
|
||||
...or...
|
||||
|
||||
```bash
|
||||
bower install vlq
|
||||
```
|
||||
|
||||
...or grab the vlq.js file and include it with a `<script src='vlq.js'>` tag.
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
### Encoding
|
||||
|
||||
`vlq.encode` accepts an integer, or an array of integers, and returns a string:
|
||||
|
||||
```js
|
||||
vlq.encode( 123 ); // '2H';
|
||||
vlq.encode([ 123, 456, 789 ]); // '2HwcqxB'
|
||||
```
|
||||
|
||||
### Decoding
|
||||
|
||||
`vlq.decode` accepts a string and always returns an array:
|
||||
|
||||
```js
|
||||
vlq.decode( '2H' ); // [ 123 ]
|
||||
vlq.decode( '2HwcqxB' ); // [ 123, 456, 789 ]
|
||||
```
|
||||
|
||||
|
||||
## Using vlq.js with sourcemaps
|
||||
|
||||
[See here for an example of using vlq.js with sourcemaps.](https://github.com/Rich-Harris/vlq/tree/master/sourcemaps)
|
||||
|
||||
|
||||
## Credits
|
||||
|
||||
Adapted from [murzwin.com/base64vlq.html](http://murzwin.com/base64vlq.html) by Alexander Pavlov.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE).
|
||||
91
node_modules/vlq/dist/vlq.js
generated
vendored
Normal file
91
node_modules/vlq/dist/vlq.js
generated
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(factory((global.vlq = global.vlq || {})));
|
||||
}(this, (function (exports) { 'use strict';
|
||||
|
||||
var charToInteger = {};
|
||||
var integerToChar = {};
|
||||
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split( '' ).forEach( function ( char, i ) {
|
||||
charToInteger[ char ] = i;
|
||||
integerToChar[ i ] = char;
|
||||
});
|
||||
|
||||
function decode ( string ) {
|
||||
var result = [];
|
||||
var shift = 0;
|
||||
var value = 0;
|
||||
|
||||
for ( var i = 0; i < string.length; i += 1 ) {
|
||||
var integer = charToInteger[ string[i] ];
|
||||
|
||||
if ( integer === undefined ) {
|
||||
throw new Error( 'Invalid character (' + string[i] + ')' );
|
||||
}
|
||||
|
||||
var hasContinuationBit = integer & 32;
|
||||
|
||||
integer &= 31;
|
||||
value += integer << shift;
|
||||
|
||||
if ( hasContinuationBit ) {
|
||||
shift += 5;
|
||||
} else {
|
||||
var shouldNegate = value & 1;
|
||||
value >>= 1;
|
||||
|
||||
result.push( shouldNegate ? -value : value );
|
||||
|
||||
// reset
|
||||
value = shift = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function encode ( value ) {
|
||||
var result;
|
||||
|
||||
if ( typeof value === 'number' ) {
|
||||
result = encodeInteger( value );
|
||||
} else {
|
||||
result = '';
|
||||
for ( var i = 0; i < value.length; i += 1 ) {
|
||||
result += encodeInteger( value[i] );
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function encodeInteger ( num ) {
|
||||
var result = '';
|
||||
|
||||
if ( num < 0 ) {
|
||||
num = ( -num << 1 ) | 1;
|
||||
} else {
|
||||
num <<= 1;
|
||||
}
|
||||
|
||||
do {
|
||||
var clamped = num & 31;
|
||||
num >>= 5;
|
||||
|
||||
if ( num > 0 ) {
|
||||
clamped |= 32;
|
||||
}
|
||||
|
||||
result += integerToChar[ clamped ];
|
||||
} while ( num > 0 );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
exports.decode = decode;
|
||||
exports.encode = encode;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
61
node_modules/vlq/package.json
generated
vendored
Normal file
61
node_modules/vlq/package.json
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
{
|
||||
"_from": "vlq@^0.2.2",
|
||||
"_id": "vlq@0.2.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-DRibZL6DsNhIgYQ+wNdWDL2SL3bKPlVrRiBqV5yuMm++op8W4kGFtaQfCs4KEJn0wBZcHVHJ3eoywX8983k1ow==",
|
||||
"_location": "/vlq",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "vlq@^0.2.2",
|
||||
"name": "vlq",
|
||||
"escapedName": "vlq",
|
||||
"rawSpec": "^0.2.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^0.2.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/magic-string"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/vlq/-/vlq-0.2.3.tgz",
|
||||
"_shasum": "8f3e4328cf63b1540c0d67e1b2778386f8975b26",
|
||||
"_spec": "vlq@^0.2.2",
|
||||
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/magic-string",
|
||||
"author": {
|
||||
"name": "Rich Harris"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Rich-Harris/vlq/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Generate, and decode, base64 VLQ mappings for source maps and other uses",
|
||||
"devDependencies": {
|
||||
"eslint": "^3.19.0",
|
||||
"rollup": "^0.41.6"
|
||||
},
|
||||
"files": [
|
||||
"README.md",
|
||||
"LICENSE",
|
||||
"src/vlq.js",
|
||||
"dist/vlq.js"
|
||||
],
|
||||
"homepage": "https://github.com/Rich-Harris/vlq#readme",
|
||||
"license": "MIT",
|
||||
"main": "dist/vlq.js",
|
||||
"module": "src/vlq.js",
|
||||
"name": "vlq",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Rich-Harris/vlq.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rollup src/vlq.js -n vlq -f umd > dist/vlq.js",
|
||||
"lint": "eslint src",
|
||||
"prepublish": "npm test",
|
||||
"pretest": "npm run build",
|
||||
"test": "node test"
|
||||
},
|
||||
"version": "0.2.3"
|
||||
}
|
||||
78
node_modules/vlq/src/vlq.js
generated
vendored
Normal file
78
node_modules/vlq/src/vlq.js
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
var charToInteger = {};
|
||||
var integerToChar = {};
|
||||
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split( '' ).forEach( function ( char, i ) {
|
||||
charToInteger[ char ] = i;
|
||||
integerToChar[ i ] = char;
|
||||
});
|
||||
|
||||
export function decode ( string ) {
|
||||
var result = [];
|
||||
var shift = 0;
|
||||
var value = 0;
|
||||
|
||||
for ( var i = 0; i < string.length; i += 1 ) {
|
||||
var integer = charToInteger[ string[i] ];
|
||||
|
||||
if ( integer === undefined ) {
|
||||
throw new Error( 'Invalid character (' + string[i] + ')' );
|
||||
}
|
||||
|
||||
var hasContinuationBit = integer & 32;
|
||||
|
||||
integer &= 31;
|
||||
value += integer << shift;
|
||||
|
||||
if ( hasContinuationBit ) {
|
||||
shift += 5;
|
||||
} else {
|
||||
var shouldNegate = value & 1;
|
||||
value >>= 1;
|
||||
|
||||
result.push( shouldNegate ? -value : value );
|
||||
|
||||
// reset
|
||||
value = shift = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export function encode ( value ) {
|
||||
var result;
|
||||
|
||||
if ( typeof value === 'number' ) {
|
||||
result = encodeInteger( value );
|
||||
} else {
|
||||
result = '';
|
||||
for ( var i = 0; i < value.length; i += 1 ) {
|
||||
result += encodeInteger( value[i] );
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function encodeInteger ( num ) {
|
||||
var result = '';
|
||||
|
||||
if ( num < 0 ) {
|
||||
num = ( -num << 1 ) | 1;
|
||||
} else {
|
||||
num <<= 1;
|
||||
}
|
||||
|
||||
do {
|
||||
var clamped = num & 31;
|
||||
num >>= 5;
|
||||
|
||||
if ( num > 0 ) {
|
||||
clamped |= 32;
|
||||
}
|
||||
|
||||
result += integerToChar[ clamped ];
|
||||
} while ( num > 0 );
|
||||
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user