diff --git a/bin/atob.js b/bin/atob.js index 5b008a7..a56ac2e 100644 --- a/bin/atob.js +++ b/bin/atob.js @@ -1,10 +1,6 @@ #!/usr/bin/env node -/*jshint strict:true node:true es5:true onevar:true laxcomma:true laxbreak:true eqeqeq:true immed:true latedef:true*/ -(function () { - "use strict"; +'use strict'; - var atob = require('../index') - ; - - console.log(atob(process.argv[2])); -}()); +var atob = require('../node-atob'); +var str = process.argv[2]; +console.log(atob(str)); diff --git a/browser-atob.js b/browser-atob.js new file mode 100644 index 0000000..d71b990 --- /dev/null +++ b/browser-atob.js @@ -0,0 +1,2 @@ +// do nothing window.atob already exists +// NOTE: iOS Web Worker and other weird environments may not have atob diff --git a/index.js b/index.js deleted file mode 100644 index e95f1e3..0000000 --- a/index.js +++ /dev/null @@ -1,9 +0,0 @@ -(function () { - "use strict"; - - function atob(str) { - return new Buffer(str, 'base64').toString('binary'); - } - - module.exports = atob; -}()); diff --git a/node-atob.js b/node-atob.js new file mode 100644 index 0000000..9c31eaa --- /dev/null +++ b/node-atob.js @@ -0,0 +1,7 @@ +"use strict"; + +function atob(str) { + return new Buffer(str, 'base64').toString('binary'); +} + +module.exports = atob.atob = atob; diff --git a/package.json b/package.json index eeea3a7..adebc2c 100644 --- a/package.json +++ b/package.json @@ -4,17 +4,18 @@ "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.git" + "url": "git://github.com/coolaj86/node-browser-compat/atob.git" }, "keywords": [ "atob", "browser" ], - "author": "AJ ONeal (http://coolaj86.info)", + "author": "AJ ONeal (https://coolaj86.com)", "engines": { "node": ">= 0.4.0" }, - "main": "index", + "main": "node-atob.js", + "browser": "browser-atob.js", "bin": { "atob": "bin/atob.js" },