summaryrefslogtreecommitdiff
path: root/node_modules/source-map/lib/base64.js
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2023-10-14 20:57:16 +0800
committerlittleblack111 <littleblack11111@gmail.com>2023-10-14 20:57:16 +0800
commit924a88fab5466307aba0b76d36b30ab06b11dcb5 (patch)
tree088b6e0beeef92d55e2b2ca523af3501b27a2830 /node_modules/source-map/lib/base64.js
parenta240fe4a4810b7f0c678a8519832fa37afaad265 (diff)
updates
Diffstat (limited to 'node_modules/source-map/lib/base64.js')
-rw-r--r--node_modules/source-map/lib/base64.js53
1 files changed, 2 insertions, 51 deletions
diff --git a/node_modules/source-map/lib/base64.js b/node_modules/source-map/lib/base64.js
index 8aa86b30..b9ca3199 100644
--- a/node_modules/source-map/lib/base64.js
+++ b/node_modules/source-map/lib/base64.js
@@ -5,63 +5,14 @@
* http://opensource.org/licenses/BSD-3-Clause
*/
-var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
+const intToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
/**
* Encode an integer in the range of 0 to 63 to a single base 64 digit.
*/
-exports.encode = function (number) {
+exports.encode = function(number) {
if (0 <= number && number < intToCharMap.length) {
return intToCharMap[number];
}
throw new TypeError("Must be between 0 and 63: " + number);
};
-
-/**
- * Decode a single base 64 character code digit to an integer. Returns -1 on
- * failure.
- */
-exports.decode = function (charCode) {
- var bigA = 65; // 'A'
- var bigZ = 90; // 'Z'
-
- var littleA = 97; // 'a'
- var littleZ = 122; // 'z'
-
- var zero = 48; // '0'
- var nine = 57; // '9'
-
- var plus = 43; // '+'
- var slash = 47; // '/'
-
- var littleOffset = 26;
- var numberOffset = 52;
-
- // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
- if (bigA <= charCode && charCode <= bigZ) {
- return (charCode - bigA);
- }
-
- // 26 - 51: abcdefghijklmnopqrstuvwxyz
- if (littleA <= charCode && charCode <= littleZ) {
- return (charCode - littleA + littleOffset);
- }
-
- // 52 - 61: 0123456789
- if (zero <= charCode && charCode <= nine) {
- return (charCode - zero + numberOffset);
- }
-
- // 62: +
- if (charCode == plus) {
- return 62;
- }
-
- // 63: /
- if (charCode == slash) {
- return 63;
- }
-
- // Invalid base64 digit.
- return -1;
-};