commit c3c29706f68528196af03ac3d025530be51a6776 Author: AJ ONeal Date: Fri Sep 9 14:56:22 2011 -0600 fixed mixup of atob / btoa diff --git a/index.js b/index.js new file mode 100644 index 0000000..8bfc1ad --- /dev/null +++ b/index.js @@ -0,0 +1,9 @@ +(function () { + "use strict"; + + function btoa(str) { + return new Buffer(str, 'utf8').toString('base64'); + } + + module.exports = btoa; +}()); diff --git a/package.json b/package.json new file mode 100644 index 0000000..4ff5854 --- /dev/null +++ b/package.json @@ -0,0 +1,18 @@ +{ + "name" : "btoa", + "homepage" : "https://github.com/coolaj86/node-browser-compat", + "description" : "btoa for Node.JS (it's a one-liner)", + "repository" : { + "type": "git", + "url": "git://github.com/coolaj86/node-browser-compat.git" + }, + "keywords" : ["btoa", "browser"], + "author" : "AJ ONeal (http://coolaj86.info)", + "engines" : { + "node": ">= 0.4.0" + }, + "dependencies" : { + }, + "main" : "index", + "version" : "1.0.0" +} diff --git a/test.js b/test.js new file mode 100644 index 0000000..e0122a2 --- /dev/null +++ b/test.js @@ -0,0 +1,15 @@ +(function () { + "use strict"; + + var btoa = require('./index') + , encoded = "SGVsbG8gV29ybGQ=" + , unencoded = "Hello World" + , result + ; + + if (encoded !== btoa(unencoded)) { + return; + } + + console.log('[PASS] all tests pass'); +}());