From 6de6b3935ac9c5df39522a3004a11f72de3ca360 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 8 Sep 2011 22:18:42 -0600 Subject: [PATCH] added atob --- atob/index.js | 9 +++++++++ atob/package.json | 18 ++++++++++++++++++ atob/test.js | 14 ++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 atob/index.js create mode 100644 atob/package.json create mode 100644 atob/test.js diff --git a/atob/index.js b/atob/index.js new file mode 100644 index 0000000..65bfaf5 --- /dev/null +++ b/atob/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/atob/package.json b/atob/package.json new file mode 100644 index 0000000..79b3c36 --- /dev/null +++ b/atob/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/atob/test.js b/atob/test.js new file mode 100644 index 0000000..65fb01d --- /dev/null +++ b/atob/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'); +}());