fixed mixup of atob / btoa

This commit is contained in:
AJ ONeal 2011-09-09 14:56:22 -06:00
commit c3c29706f6
3 changed files with 42 additions and 0 deletions

9
index.js Normal file
View File

@ -0,0 +1,9 @@
(function () {
"use strict";
function btoa(str) {
return new Buffer(str, 'utf8').toString('base64');
}
module.exports = btoa;
}());

18
package.json Normal file
View File

@ -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 <coolaj86@gmail.com> (http://coolaj86.info)",
"engines" : {
"node": ">= 0.4.0"
},
"dependencies" : {
},
"main" : "index",
"version" : "1.0.0"
}

15
test.js Normal file
View File

@ -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');
}());