Socket
Socket
Sign inDemoInstall

Base64

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Base64 - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

69

base64.js

@@ -1,15 +0,22 @@

;(function () {
(function(f) {
var object = (
// #34: CommonJS
typeof exports === 'object' && exports !== null &&
typeof exports.nodeType !== 'number' ?
exports :
// #8: web workers
typeof self != 'undefined' ?
self :
// #31: ExtendScript
$.global
);
'use strict';
/* istanbul ignore else */
if (typeof exports === 'object' && exports != null &&
typeof exports.nodeType !== 'number') {
module.exports = f ();
} else if (typeof define === 'function' && define.amd != null) {
define ([], f);
} else {
var base64 = f ();
var global = typeof self !== 'undefined' ? self : $.global;
if (typeof global.btoa !== 'function') global.btoa = base64.btoa;
if (typeof global.atob !== 'function') global.atob = base64.atob;
}
} (function() {
'use strict';
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';

@@ -20,3 +27,3 @@

}
InvalidCharacterError.prototype = new Error;
InvalidCharacterError.prototype = new Error ();
InvalidCharacterError.prototype.name = 'InvalidCharacterError';

@@ -26,5 +33,4 @@

// [https://gist.github.com/999166] by [https://github.com/nignag]
object.btoa || (
object.btoa = function (input) {
var str = String(input);
function btoa(input) {
var str = String (input);
for (

@@ -36,9 +42,9 @@ // initialize result and counter

// check if d has no fractional digits
str.charAt(idx | 0) || (map = '=', idx % 1);
str.charAt (idx | 0) || (map = '=', idx % 1);
// "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
output += map.charAt(63 & block >> 8 - idx % 1 * 8)
output += map.charAt (63 & block >> 8 - idx % 1 * 8)
) {
charCode = str.charCodeAt(idx += 3/4);
charCode = str.charCodeAt (idx += 3 / 4);
if (charCode > 0xFF) {
throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");
throw new InvalidCharacterError ("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");
}

@@ -48,11 +54,10 @@ block = block << 8 | charCode;

return output;
});
}
// decoder
// [https://gist.github.com/1020396] by [https://github.com/atk]
object.atob || (
object.atob = function (input) {
var str = String(input).replace(/[=]+$/, ''); // #31: ExtendScript bad parse of /=
if (str.length % 4 == 1) {
throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");
function atob(input) {
var str = (String (input)).replace (/[=]+$/, ''); // #31: ExtendScript bad parse of /=
if (str.length % 4 === 1) {
throw new InvalidCharacterError ("'atob' failed: The string to be decoded is not correctly encoded.");
}

@@ -63,3 +68,3 @@ for (

// get next character
buffer = str.charAt(idx++);
buffer = str.charAt (idx++); // eslint-disable-line no-cond-assign
// character found in table? initialize bit storage and add its ascii value;

@@ -69,10 +74,12 @@ ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,

// convert the first 8 bits to one ascii character
bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0
bc++ % 4) ? output += String.fromCharCode (255 & bs >> (-2 * bc & 6)) : 0
) {
// try to find character in table (0-63, not found => -1)
buffer = chars.indexOf(buffer);
buffer = chars.indexOf (buffer);
}
return output;
});
}
}());
return {btoa: btoa, atob: atob};
}));
{
"name": "Base64",
"version": "1.0.2",
"version": "1.1.0",
"description": "Base64 encoding and decoding",

@@ -13,9 +13,8 @@ "author": "David Chambers <dc@davidchambers.me>",

"devDependencies": {
"debug": "3.2.x",
"eslint": "4.9.x",
"eslint": "5.15.x",
"istanbul": "0.4.x",
"mocha": "3.5.x",
"sanctuary-style": "2.0.x",
"uglify-js": "3.4.x",
"xyz": "3.0.x"
"mocha": "5.2.x",
"sanctuary-style": "3.0.x",
"uglify-js": "3.5.x",
"xyz": "4.0.x"
},

@@ -22,0 +21,0 @@ "files": [

@@ -5,3 +5,3 @@ # Base64.js

≈ 600 byte* polyfill for browsers which don't provide [`window.btoa`][1] and
≈ 700 byte* polyfill for browsers which don't provide [`window.btoa`][1] and
[`window.atob`][2].

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc