summaryrefslogtreecommitdiff
path: root/node_modules/source-map/lib/base64-vlq.js
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2023-11-05 17:23:37 +0800
committerlittleblack111 <littleblack11111@gmail.com>2023-11-05 17:23:37 +0800
commit2cdf0cb352ab6a2d0f8cb25120e4ebc92c5316e3 (patch)
tree6b088c99810bd013f17b80522c936ca6dfc09858 /node_modules/source-map/lib/base64-vlq.js
parentf8ee6ef722e6c560c4a1c879e04dbdf0b01f0316 (diff)
removed autoprefix hover as it will have a high chance of making hover stopped working
Diffstat (limited to 'node_modules/source-map/lib/base64-vlq.js')
-rw-r--r--node_modules/source-map/lib/base64-vlq.js51
1 files changed, 40 insertions, 11 deletions
diff --git a/node_modules/source-map/lib/base64-vlq.js b/node_modules/source-map/lib/base64-vlq.js
index fc1049c8..612b4040 100644
--- a/node_modules/source-map/lib/base64-vlq.js
+++ b/node_modules/source-map/lib/base64-vlq.js
@@ -35,7 +35,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-const base64 = require("./base64");
+var base64 = require('./base64');
// A single base 64 digit can contain 6 bits of data. For the base 64 variable
// length quantities we use in the source map spec, the first bit is the sign,
@@ -49,16 +49,16 @@ const base64 = require("./base64");
// V V
// 101011
-const VLQ_BASE_SHIFT = 5;
+var VLQ_BASE_SHIFT = 5;
// binary: 100000
-const VLQ_BASE = 1 << VLQ_BASE_SHIFT;
+var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
// binary: 011111
-const VLQ_BASE_MASK = VLQ_BASE - 1;
+var VLQ_BASE_MASK = VLQ_BASE - 1;
// binary: 100000
-const VLQ_CONTINUATION_BIT = VLQ_BASE;
+var VLQ_CONTINUATION_BIT = VLQ_BASE;
/**
* Converts from a two-complement value to a value where the sign bit is
@@ -78,10 +78,9 @@ function toVLQSigned(aValue) {
* 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
* 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
*/
-// eslint-disable-next-line no-unused-vars
function fromVLQSigned(aValue) {
- const isNegative = (aValue & 1) === 1;
- const shifted = aValue >> 1;
+ var isNegative = (aValue & 1) === 1;
+ var shifted = aValue >> 1;
return isNegative
? -shifted
: shifted;
@@ -91,10 +90,10 @@ function fromVLQSigned(aValue) {
* Returns the base 64 VLQ encoded value.
*/
exports.encode = function base64VLQ_encode(aValue) {
- let encoded = "";
- let digit;
+ var encoded = "";
+ var digit;
- let vlq = toVLQSigned(aValue);
+ var vlq = toVLQSigned(aValue);
do {
digit = vlq & VLQ_BASE_MASK;
@@ -109,3 +108,33 @@ exports.encode = function base64VLQ_encode(aValue) {
return encoded;
};
+
+/**
+ * Decodes the next base 64 VLQ value from the given string and returns the
+ * value and the rest of the string via the out parameter.
+ */
+exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
+ var strLen = aStr.length;
+ var result = 0;
+ var shift = 0;
+ var continuation, digit;
+
+ do {
+ if (aIndex >= strLen) {
+ throw new Error("Expected more digits in base 64 VLQ value.");
+ }
+
+ digit = base64.decode(aStr.charCodeAt(aIndex++));
+ if (digit === -1) {
+ throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
+ }
+
+ continuation = !!(digit & VLQ_CONTINUATION_BIT);
+ digit &= VLQ_BASE_MASK;
+ result = result + (digit << shift);
+ shift += VLQ_BASE_SHIFT;
+ } while (continuation);
+
+ aOutParam.value = fromVLQSigned(result);
+ aOutParam.rest = aIndex;
+};