diff --git a/README.md b/README.md index 88ae63c..073691d 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,40 @@ btoa === +| [atob](https://git.coolaj86.com/coolaj86/atob.js) +| **btoa** +| [unibabel.js](https://git.coolaj86.com/coolaj86/unibabel.js) +| Sponsored by [ppl](https://ppl.family) + A port of the browser's `btoa` function. -Uses `Buffer` to emulate the exact functionality of the browser's btoa (except that it supports unicode and the browser may not). +Uses `Buffer` to emulate the exact functionality of the browser's btoa +(except that it supports some unicode that the browser may not). It turns binary data __to__ base64-encoded ascii. - (function () { - "use strict"; - - var btoa = require('btoa') - , bin = "Hello, 世界" - , b64 = btoa(bin) - ; +```js +(function () { + "use strict"; - console.log(b64); // "SGVsbG8sIBZM" - }()); + var btoa = require('btoa'); + var bin = "Hello, 世界"; + var b64 = btoa(bin); -Note: Unicode may or may not be handled incorrectly. + console.log(b64); // "SGVsbG8sIBZM" +}()); +``` -Copyright and license +**Note**: Unicode may or may not be handled incorrectly. +This module is intended to provide exact compatibility with the browser. + +Copyright and License === -Code and documentation copyright 2012-2014 AJ ONeal Tech, LLC. +Code copyright 2012-2018 AJ ONeal -Code released under the [Apache license](https://github.com/node-browser-compat/btoa/blob/master/LICENSE). +Dual-licensed MIT and Apache-2.0 -Docs released under [Creative Commons](https://github.com/node-browser-compat/btoa/blob/master/LICENSE.DOCS). +Docs copyright 2012-2018 AJ ONeal + +Docs released under [Creative Commons](https://git.coolaj86.com/coolaj86/btoa.js/blob/master/LICENSE.DOCS). diff --git a/bin/btoa.js b/bin/btoa.js index 091d1df..a237ce2 100644 --- a/bin/btoa.js +++ b/bin/btoa.js @@ -1,10 +1,8 @@ #!/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"; - var btoa = require('../index') - ; + var btoa = require('../index'); console.log(btoa(process.argv[2])); }()); diff --git a/index.js b/index.js index b6026fb..34b8f15 100644 --- a/index.js +++ b/index.js @@ -7,7 +7,7 @@ if (str instanceof Buffer) { buffer = str; } else { - buffer = new Buffer(str.toString(), 'binary'); + buffer = Buffer.from(str.toString(), 'binary'); } return buffer.toString('base64'); diff --git a/package.json b/package.json index f61988d..f4bc447 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,16 @@ { "name": "btoa", - "homepage": "https://github.com/coolaj86/node-browser-compat", + "homepage": "https://git.coolaj86.com/coolaj86/btoa.js.git", "description": "btoa for Node.JS (it's a one-liner)", "repository": { "type": "git", - "url": "git://github.com/coolaj86/node-browser-compat.git" + "url": "git://git.coolaj86.com/coolaj86/btoa.js.git", }, "keywords": [ "btoa", "browser" ], - "author": "AJ ONeal (http://coolaj86.info)", + "author": "AJ ONeal (https://coolaj86.com)", "engines": { "node": ">= 0.4.0" }, @@ -18,6 +18,6 @@ "btoa": "bin/btoa.js" }, "main": "index", - "license": "Apache-2.0", - "version": "1.1.2" + "license": "(MIT OR Apache-2.0)", + "version": "1.2.0" }