Socket
Socket
Sign inDemoInstall

sourcemap-codec

Package Overview
Dependencies
1
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.3.1 to 1.4.0

dist/types/sourcemap-codec.d.ts

4

CHANGELOG.md
# sourcemap-codec changelog
## 1.4.0
* Add TypeScript declarations ([#70](https://github.com/Rich-Harris/sourcemap-codec/pull/70))
## 1.3.1

@@ -4,0 +8,0 @@

333

dist/sourcemap-codec.es.js
var charToInteger = {};
var integerToChar = {};
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split( '' ).forEach( function ( char, i ) {
charToInteger[ char ] = i;
integerToChar[ i ] = char;
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split('').forEach(function (char, i) {
charToInteger[char] = i;
integerToChar[i] = char;
});
function decode$1 ( string ) {
var result = [],
len = string.length,
i,
hasContinuationBit,
shift = 0,
value = 0,
integer,
shouldNegate;
for ( i = 0; i < len; i += 1 ) {
integer = charToInteger[ string[i] ];
if ( integer === undefined ) {
throw new Error( 'Invalid character (' + string[i] + ')' );
}
hasContinuationBit = integer & 32;
integer &= 31;
value += integer << shift;
if ( hasContinuationBit ) {
shift += 5;
} else {
shouldNegate = value & 1;
value >>= 1;
result.push( shouldNegate ? -value : value );
// reset
value = shift = 0;
}
}
return result;
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$1 ( value ) {
var result, i;
if ( typeof value === 'number' ) {
result = encodeInteger( value );
} else {
result = '';
for ( i = 0; i < value.length; i += 1 ) {
result += encodeInteger( value[i] );
}
}
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 = '', clamped;
if ( num < 0 ) {
num = ( -num << 1 ) | 1;
} else {
num <<= 1;
}
do {
clamped = num & 31;
num >>= 5;
if ( num > 0 ) {
clamped |= 32;
}
result += integerToChar[ clamped ];
} while ( num > 0 );
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;
}
function decodeSegments ( encodedSegments ) {
var i = encodedSegments.length;
var segments = new Array( i );
while ( i-- ) { segments[i] = decode$1( encodedSegments[i] ); }
return segments;
function decodeSegments(encodedSegments) {
var i = encodedSegments.length;
var segments = new Array(i);
while (i--)
segments[i] = decode(encodedSegments[i]);
return segments;
}
function decode$$1 ( mappings ) {
var sourceFileIndex = 0; // second field
var sourceCodeLine = 0; // third field
var sourceCodeColumn = 0; // fourth field
var nameIndex = 0; // fifth field
var lines = mappings.split( ';' );
var numLines = lines.length;
var decoded = new Array( numLines );
var i;
var j;
var line;
var generatedCodeColumn;
var decodedLine;
var segments;
var segment;
var result;
for ( i = 0; i < numLines; i += 1 ) {
line = lines[i];
generatedCodeColumn = 0; // first field - reset each time
decodedLine = [];
segments = decodeSegments( line.split( ',' ) );
for ( j = 0; j < segments.length; j += 1 ) {
segment = segments[j];
if ( !segment.length ) {
break;
}
generatedCodeColumn += segment[0];
result = [ generatedCodeColumn ];
decodedLine.push( result );
if ( segment.length === 1 ) {
// only one field!
continue;
}
sourceFileIndex += segment[1];
sourceCodeLine += segment[2];
sourceCodeColumn += segment[3];
result.push( sourceFileIndex, sourceCodeLine, sourceCodeColumn );
if ( segment.length === 5 ) {
nameIndex += segment[4];
result.push( nameIndex );
}
}
decoded[i] = decodedLine;
}
return decoded;
function decode$1(mappings) {
var sourceFileIndex = 0; // second field
var sourceCodeLine = 0; // third field
var sourceCodeColumn = 0; // fourth field
var nameIndex = 0; // fifth field
var lines = mappings.split(';');
var numLines = lines.length;
var decoded = new Array(numLines);
var i;
var j;
var line;
var generatedCodeColumn;
var decodedLine;
var segments;
var segment;
var result;
for (i = 0; i < numLines; i += 1) {
line = lines[i];
generatedCodeColumn = 0; // first field - reset each time
decodedLine = [];
segments = decodeSegments(line.split(','));
for (j = 0; j < segments.length; j += 1) {
segment = segments[j];
if (!segment.length) {
break;
}
generatedCodeColumn += segment[0];
result = [generatedCodeColumn];
decodedLine.push(result);
if (segment.length === 1) {
// only one field!
continue;
}
sourceFileIndex += segment[1];
sourceCodeLine += segment[2];
sourceCodeColumn += segment[3];
result.push(sourceFileIndex, sourceCodeLine, sourceCodeColumn);
if (segment.length === 5) {
nameIndex += segment[4];
result.push(nameIndex);
}
}
decoded[i] = decodedLine;
}
return decoded;
}
function encode$$1 ( decoded ) {
var offsets = {
generatedCodeColumn: 0,
sourceFileIndex: 0, // second field
sourceCodeLine: 0, // third field
sourceCodeColumn: 0, // fourth field
nameIndex: 0 // fifth field
};
return decoded.map( function (line) {
offsets.generatedCodeColumn = 0; // first field - reset each time
return line.map( encodeSegment ).join( ',' );
}).join( ';' );
function encodeSegment ( segment ) {
if ( !segment.length ) {
return segment;
}
var result = new Array( segment.length );
result[0] = segment[0] - offsets.generatedCodeColumn;
offsets.generatedCodeColumn = segment[0];
if ( segment.length === 1 ) {
// only one field!
return encode$1( result );
}
result[1] = segment[1] - offsets.sourceFileIndex;
result[2] = segment[2] - offsets.sourceCodeLine;
result[3] = segment[3] - offsets.sourceCodeColumn;
offsets.sourceFileIndex = segment[1];
offsets.sourceCodeLine = segment[2];
offsets.sourceCodeColumn = segment[3];
if ( segment.length === 5 ) {
result[4] = segment[4] - offsets.nameIndex;
offsets.nameIndex = segment[4];
}
return encode$1( result );
}
function encode$1(decoded) {
var offsets = {
generatedCodeColumn: 0,
sourceFileIndex: 0,
sourceCodeLine: 0,
sourceCodeColumn: 0,
nameIndex: 0 // fifth field
};
return decoded.map(function (line) {
offsets.generatedCodeColumn = 0; // first field - reset each time
return line.map(encodeSegment).join(',');
}).join(';');
function encodeSegment(segment) {
if (!segment.length) {
return '';
}
var result = new Array(segment.length);
result[0] = segment[0] - offsets.generatedCodeColumn;
offsets.generatedCodeColumn = segment[0];
if (segment.length === 1) {
// only one field!
return encode(result);
}
result[1] = segment[1] - offsets.sourceFileIndex;
result[2] = segment[2] - offsets.sourceCodeLine;
result[3] = segment[3] - offsets.sourceCodeColumn;
offsets.sourceFileIndex = segment[1];
offsets.sourceCodeLine = segment[2];
offsets.sourceCodeColumn = segment[3];
if (segment.length === 5) {
result[4] = segment[4] - offsets.nameIndex;
offsets.nameIndex = segment[4];
}
return encode(result);
}
}
export { decode$$1 as decode, encode$$1 as encode };
export { decode$1 as decode, encode$1 as encode };
//# sourceMappingURL=sourcemap-codec.es.js.map
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.sourcemapCodec = global.sourcemapCodec || {})));
(factory((global.sourcemapCodec = {})));
}(this, (function (exports) { 'use strict';

@@ -9,202 +9,155 @@

var integerToChar = {};
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split( '' ).forEach( function ( char, i ) {
charToInteger[ char ] = i;
integerToChar[ i ] = char;
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split('').forEach(function (char, i) {
charToInteger[char] = i;
integerToChar[i] = char;
});
function decode$1 ( string ) {
var result = [],
len = string.length,
i,
hasContinuationBit,
shift = 0,
value = 0,
integer,
shouldNegate;
for ( i = 0; i < len; i += 1 ) {
integer = charToInteger[ string[i] ];
if ( integer === undefined ) {
throw new Error( 'Invalid character (' + string[i] + ')' );
}
hasContinuationBit = integer & 32;
integer &= 31;
value += integer << shift;
if ( hasContinuationBit ) {
shift += 5;
} else {
shouldNegate = value & 1;
value >>= 1;
result.push( shouldNegate ? -value : value );
// reset
value = shift = 0;
}
}
return result;
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$1 ( value ) {
var result, i;
if ( typeof value === 'number' ) {
result = encodeInteger( value );
} else {
result = '';
for ( i = 0; i < value.length; i += 1 ) {
result += encodeInteger( value[i] );
}
}
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 = '', clamped;
if ( num < 0 ) {
num = ( -num << 1 ) | 1;
} else {
num <<= 1;
}
do {
clamped = num & 31;
num >>= 5;
if ( num > 0 ) {
clamped |= 32;
}
result += integerToChar[ clamped ];
} while ( num > 0 );
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;
}
function decodeSegments ( encodedSegments ) {
var i = encodedSegments.length;
var segments = new Array( i );
while ( i-- ) { segments[i] = decode$1( encodedSegments[i] ); }
return segments;
function decodeSegments(encodedSegments) {
var i = encodedSegments.length;
var segments = new Array(i);
while (i--)
segments[i] = decode(encodedSegments[i]);
return segments;
}
function decode$$1 ( mappings ) {
var sourceFileIndex = 0; // second field
var sourceCodeLine = 0; // third field
var sourceCodeColumn = 0; // fourth field
var nameIndex = 0; // fifth field
var lines = mappings.split( ';' );
var numLines = lines.length;
var decoded = new Array( numLines );
var i;
var j;
var line;
var generatedCodeColumn;
var decodedLine;
var segments;
var segment;
var result;
for ( i = 0; i < numLines; i += 1 ) {
line = lines[i];
generatedCodeColumn = 0; // first field - reset each time
decodedLine = [];
segments = decodeSegments( line.split( ',' ) );
for ( j = 0; j < segments.length; j += 1 ) {
segment = segments[j];
if ( !segment.length ) {
break;
}
generatedCodeColumn += segment[0];
result = [ generatedCodeColumn ];
decodedLine.push( result );
if ( segment.length === 1 ) {
// only one field!
continue;
}
sourceFileIndex += segment[1];
sourceCodeLine += segment[2];
sourceCodeColumn += segment[3];
result.push( sourceFileIndex, sourceCodeLine, sourceCodeColumn );
if ( segment.length === 5 ) {
nameIndex += segment[4];
result.push( nameIndex );
}
}
decoded[i] = decodedLine;
}
return decoded;
function decode$1(mappings) {
var sourceFileIndex = 0; // second field
var sourceCodeLine = 0; // third field
var sourceCodeColumn = 0; // fourth field
var nameIndex = 0; // fifth field
var lines = mappings.split(';');
var numLines = lines.length;
var decoded = new Array(numLines);
var i;
var j;
var line;
var generatedCodeColumn;
var decodedLine;
var segments;
var segment;
var result;
for (i = 0; i < numLines; i += 1) {
line = lines[i];
generatedCodeColumn = 0; // first field - reset each time
decodedLine = [];
segments = decodeSegments(line.split(','));
for (j = 0; j < segments.length; j += 1) {
segment = segments[j];
if (!segment.length) {
break;
}
generatedCodeColumn += segment[0];
result = [generatedCodeColumn];
decodedLine.push(result);
if (segment.length === 1) {
// only one field!
continue;
}
sourceFileIndex += segment[1];
sourceCodeLine += segment[2];
sourceCodeColumn += segment[3];
result.push(sourceFileIndex, sourceCodeLine, sourceCodeColumn);
if (segment.length === 5) {
nameIndex += segment[4];
result.push(nameIndex);
}
}
decoded[i] = decodedLine;
}
return decoded;
}
function encode$$1 ( decoded ) {
var offsets = {
generatedCodeColumn: 0,
sourceFileIndex: 0, // second field
sourceCodeLine: 0, // third field
sourceCodeColumn: 0, // fourth field
nameIndex: 0 // fifth field
};
return decoded.map( function (line) {
offsets.generatedCodeColumn = 0; // first field - reset each time
return line.map( encodeSegment ).join( ',' );
}).join( ';' );
function encodeSegment ( segment ) {
if ( !segment.length ) {
return segment;
}
var result = new Array( segment.length );
result[0] = segment[0] - offsets.generatedCodeColumn;
offsets.generatedCodeColumn = segment[0];
if ( segment.length === 1 ) {
// only one field!
return encode$1( result );
}
result[1] = segment[1] - offsets.sourceFileIndex;
result[2] = segment[2] - offsets.sourceCodeLine;
result[3] = segment[3] - offsets.sourceCodeColumn;
offsets.sourceFileIndex = segment[1];
offsets.sourceCodeLine = segment[2];
offsets.sourceCodeColumn = segment[3];
if ( segment.length === 5 ) {
result[4] = segment[4] - offsets.nameIndex;
offsets.nameIndex = segment[4];
}
return encode$1( result );
}
function encode$1(decoded) {
var offsets = {
generatedCodeColumn: 0,
sourceFileIndex: 0,
sourceCodeLine: 0,
sourceCodeColumn: 0,
nameIndex: 0 // fifth field
};
return decoded.map(function (line) {
offsets.generatedCodeColumn = 0; // first field - reset each time
return line.map(encodeSegment).join(',');
}).join(';');
function encodeSegment(segment) {
if (!segment.length) {
return '';
}
var result = new Array(segment.length);
result[0] = segment[0] - offsets.generatedCodeColumn;
offsets.generatedCodeColumn = segment[0];
if (segment.length === 1) {
// only one field!
return encode(result);
}
result[1] = segment[1] - offsets.sourceFileIndex;
result[2] = segment[2] - offsets.sourceCodeLine;
result[3] = segment[3] - offsets.sourceCodeColumn;
offsets.sourceFileIndex = segment[1];
offsets.sourceCodeLine = segment[2];
offsets.sourceCodeColumn = segment[3];
if (segment.length === 5) {
result[4] = segment[4] - offsets.nameIndex;
offsets.nameIndex = segment[4];
}
return encode(result);
}
}
exports.decode = decode$$1;
exports.encode = encode$$1;
exports.decode = decode$1;
exports.encode = encode$1;

@@ -211,0 +164,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

{
"name": "sourcemap-codec",
"version": "1.3.1",
"version": "1.4.0",
"description": "Encode/decode sourcemap mappings",
"main": "dist/sourcemap-codec.umd.js",
"module": "dist/sourcemap-codec.es.js",
"types": "dist/types/sourcemap-codec.d.ts",
"scripts": {
"test": "mocha",
"build": "rm -rf dist && rollup -c",
"build": "rm -rf dist && rollup -c && tsc",
"pretest": "npm run build",

@@ -33,3 +34,3 @@ "prepublish": "npm test",

"dependencies": {
"vlq": "^0.2.1"
"vlq": "^1.0.0"
},

@@ -44,11 +45,12 @@ "devDependencies": {

"remap-istanbul": "^0.9.5",
"rollup": "^0.41.6",
"rollup-plugin-buble": "^0.15.0",
"rollup-plugin-node-resolve": "^3.0.0"
"rollup": "^0.54.0",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-typescript": "^0.8.1",
"typescript": "^2.7.1"
},
"files": [
"src",
"dist",
"dist/*.js",
"dist/**/*.d.ts",
"README.md"
]
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc