Socket
Socket
Sign inDemoInstall

atob

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.3 to 2.1.0

52

browser-atob.js
(function (w) {
"use strict";
var a2b = w.atob;
function findBest(atobNative) {
// normal window
if ('function' === typeof atobNative) { return atobNative; }
function atob(str) {
// normal window
if ('function' === typeof a2b) {
return a2b(str);
}
// browserify (web worker)
else if ('function' === typeof Buffer) {
return new Buffer(str, 'base64').toString('binary');
if ('function' === typeof Buffer) {
return function atobBrowserify(a) {
//!! Deliberately using an API that's deprecated in node.js because
//!! this file is for browsers and we expect them to cope with it.
//!! Discussion: github.com/node-browser-compat/atob/pull/9
return new Buffer(a, 'base64').toString('binary');
};
}
// ios web worker with base64js
else if ('object' === typeof w.base64js) {
if ('object' === typeof w.base64js) {
// bufferToBinaryString
// https://github.com/coolaj86/unibabel-js/blob/master/index.js#L50
var buf = w.base64js.b64ToByteArray(str);
// https://git.coolaj86.com/coolaj86/unibabel.js/blob/master/index.js#L50
return function atobWebWorker_iOS(a) {
var buf = w.base64js.b64ToByteArray(a);
return Array.prototype.map.call(buf, function (ch) {
return String.fromCharCode(ch);
}).join('');
};
}
return Array.prototype.map.call(buf, function (ch) {
return String.fromCharCode(ch);
}).join('');
}
// ios web worker without base64js
else {
throw new Error("you're probably in an ios webworker. please include use beatgammit's base64-js");
}
return function () {
// ios web worker without base64js
throw new Error("You're probably in an old browser or an iOS webworker." +
" It might help to include beatgammit's base64-js.");
};
}
w.atob = atob;
var atobBest = findBest(w.atob);
w.atob = atobBest;
if (typeof module !== 'undefined') {
module.exports = atob;
if ((typeof module === 'object') && module && module.exports) {
module.exports = atobBest;
}
}(window));
"use strict";
function atob(str) {
return new Buffer(str, 'base64').toString('binary');
return Buffer.from(str, 'base64').toString('binary');
}
module.exports = atob.atob = atob;
{
"name": "atob",
"homepage": "https://github.com/coolaj86/node-browser-compat",
"homepage": "https://git.coolaj86.com/coolaj86/atob.js.git",
"description": "atob for Node.JS and Linux / Mac / Windows CLI (it's a one-liner)",
"repository": {
"type": "git",
"url": "git://github.com/coolaj86/node-browser-compat/atob.git"
"url": "git://git.coolaj86.com/coolaj86/atob.js.git"
},

@@ -23,3 +23,3 @@ "keywords": [

"license": "(MIT OR Apache-2.0)",
"version": "2.0.3"
"version": "2.1.0"
}
atob
===
| **atob**
| [btoa](https://git.coolaj86.com/coolaj86/btoa.js)
| [unibabel.js](https://git.coolaj86.com/coolaj86/unibabel.js)
| Sponsored by [ppl](https://ppl.family)
Uses `Buffer` to emulate the exact functionality of the browser's atob.

@@ -15,6 +20,6 @@

var atob = require('atob');
var b64 = "SGVsbG8gV29ybGQ=";
var b64 = "SGVsbG8sIFdvcmxkIQ==";
var bin = atob(b64);
console.log(bin); // "Hello World"
console.log(bin); // "Hello, World!"
}());

@@ -25,3 +30,3 @@ ```

Check out [unibabel.js](https://github.com/coolaj86/unibabel-js)
Check out [unibabel.js](https://git.coolaj86.com/coolaj86/unibabel.js)

@@ -31,5 +36,6 @@ Changelog

* v2.1.0 address a few issues and PRs, update URLs
* v2.0.0 provide browser version for ios web workers
* v1.2.0 provide (empty) browser version
* v1.1.3 add MIT license (see [#4](https://github.com/node-browser-compat/atob/issues/4))
* v1.1.3 add MIT license
* v1.1.2 node only

@@ -40,8 +46,8 @@

Code copyright 2012-2015 AJ ONeal
Code copyright 2012-2018 AJ ONeal
Dual-licensed MIT and Apache-2.0
Docs copyright 2012-2015 AJ ONeal
Docs copyright 2012-2018 AJ ONeal
Docs released under [Creative Commons](https://github.com/node-browser-compat/atob/blob/master/LICENSE.DOCS).
Docs released under [Creative Commons](https://git.coolaj86.com/coolaj86/atob.js/blob/master/LICENSE.DOCS).

@@ -1,8 +0,7 @@

/*jshint strict:true node:true es5:true onevar:true laxcomma:true laxbreak:true eqeqeq:true immed:true latedef:true*/
(function () {
"use strict";
var atob = require('.')
, encoded = "SGVsbG8gV29ybGQ="
, unencoded = "Hello World"
var atob = require('.');
var encoded = "SGVsbG8sIFdvcmxkIQ=="
var unencoded = "Hello, World!";
/*

@@ -12,3 +11,2 @@ , encoded = "SGVsbG8sIBZM"

*/
;

@@ -15,0 +13,0 @@ if (unencoded !== atob(encoded)) {

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc