From aacae887e83c0fe8aef40b41210005e5c0a03871 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 8 Sep 2011 22:18:42 -0600 Subject: [PATCH] added atob --- index.js | 9 +++++++++ package.json | 18 ++++++++++++++++++ test.js | 14 ++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 index.js create mode 100644 package.json create mode 100644 test.js diff --git a/index.js b/index.js new file mode 100644 index 0000000..65bfaf5 --- /dev/null +++ b/index.js @@ -0,0 +1,9 @@ +(function () { + "use strict"; + + function atob(str) { + return new Buffer(str, 'utf8').toString('base64'); + } + + module.exports = atob; +}()); diff --git a/package.json b/package.json new file mode 100644 index 0000000..79b3c36 --- /dev/null +++ b/package.json @@ -0,0 +1,18 @@ +{ + "name" : "atob", + "homepage" : "https://github.com/coolaj86/node-browser-compat", + "description" : "atob for Node.JS (it's a one-liner)", + "repository" : { + "type": "git", + "url": "git://github.com/coolaj86/node-browser-compat.git" + }, + "keywords" : ["atob", "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..65fb01d --- /dev/null +++ b/test.js @@ -0,0 +1,14 @@ +(function () { + "use strict"; + + var atob = require('./index') + , expected = "SGVsbG8gV29ybGQ=" + , result + ; + + if (expected !== atob("Hello World")) { + return; + } + + console.log('[PASS] all tests pass'); +}());