diff options
Diffstat (limited to 'node_modules/atob')
-rw-r--r-- | node_modules/atob/README.md | 20 | ||||
-rw-r--r-- | node_modules/atob/bower.json | 3 | ||||
-rw-r--r-- | node_modules/atob/browser-atob.js | 52 | ||||
-rw-r--r-- | node_modules/atob/node-atob.js | 2 | ||||
-rw-r--r-- | node_modules/atob/package.json | 8 | ||||
-rw-r--r-- | node_modules/atob/test.js | 8 |
6 files changed, 52 insertions, 41 deletions
diff --git a/node_modules/atob/README.md b/node_modules/atob/README.md index b8cffda6a..e15ef86b0 100644 --- a/node_modules/atob/README.md +++ b/node_modules/atob/README.md @@ -1,6 +1,11 @@ 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. Note: Unicode may be handled incorrectly (like the browser). @@ -12,32 +17,33 @@ It turns base64-encoded <strong>a</strong>scii data back **to** <strong>b</stron "use strict"; var atob = require('atob'); - var b64 = "SGVsbG8gV29ybGQ="; + var b64 = "SGVsbG8sIFdvcmxkIQ=="; var bin = atob(b64); - console.log(bin); // "Hello World" + console.log(bin); // "Hello, World!" }()); ``` ### Need Unicode and Binary Support in the Browser? -Check out [unibabel.js](https://github.com/coolaj86/unibabel-js) +Check out [unibabel.js](https://git.coolaj86.com/coolaj86/unibabel.js) 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 LICENSE ======= -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). diff --git a/node_modules/atob/bower.json b/node_modules/atob/bower.json index f1e3f44eb..e3ef66e25 100644 --- a/node_modules/atob/bower.json +++ b/node_modules/atob/bower.json @@ -20,6 +20,5 @@ "bower_components", "test", "tests" - ], - "version": "2.0.3" + ] } diff --git a/node_modules/atob/browser-atob.js b/node_modules/atob/browser-atob.js index f5fc8bce3..af4f357bb 100644 --- a/node_modules/atob/browser-atob.js +++ b/node_modules/atob/browser-atob.js @@ -1,36 +1,44 @@ (function (w) { "use strict"; - var a2b = w.atob; - - function atob(str) { + function findBest(atobNative) { // normal window - if ('function' === typeof a2b) { - return a2b(str); - } + if ('function' === typeof atobNative) { return atobNative; } + + // 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); - - 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"); + // 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 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)); diff --git a/node_modules/atob/node-atob.js b/node_modules/atob/node-atob.js index 9c31eaa06..d7305a329 100644 --- a/node_modules/atob/node-atob.js +++ b/node_modules/atob/node-atob.js @@ -1,7 +1,7 @@ "use strict"; function atob(str) { - return new Buffer(str, 'base64').toString('binary'); + return Buffer.from(str, 'base64').toString('binary'); } module.exports = atob.atob = atob; diff --git a/node_modules/atob/package.json b/node_modules/atob/package.json index 3abcc28a6..79bfd9bad 100644 --- a/node_modules/atob/package.json +++ b/node_modules/atob/package.json @@ -1,10 +1,10 @@ { "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" }, "keywords": [ "atob", @@ -12,7 +12,7 @@ ], "author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com)", "engines": { - "node": ">= 0.4.0" + "node": ">= 4.5.0" }, "main": "node-atob.js", "browser": "browser-atob.js", @@ -20,5 +20,5 @@ "atob": "bin/atob.js" }, "license": "(MIT OR Apache-2.0)", - "version": "2.0.3" + "version": "2.1.2" } diff --git a/node_modules/atob/test.js b/node_modules/atob/test.js index e499dd574..bd80a4ea1 100644 --- a/node_modules/atob/test.js +++ b/node_modules/atob/test.js @@ -1,15 +1,13 @@ -/*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!"; /* , encoded = "SGVsbG8sIBZM" , unencoded = "Hello, 世界" */ - ; if (unencoded !== atob(encoded)) { console.log('[FAIL]', unencoded, atob(encoded)); |