btoa.js/index.js

18 lines
273 B
JavaScript
Raw Permalink Normal View History

2011-09-09 20:56:22 +00:00
(function () {
"use strict";
function btoa(str) {
var buffer;
if (str instanceof Buffer) {
buffer = str;
} else {
2018-03-28 04:44:53 +00:00
buffer = Buffer.from(str.toString(), 'binary');
}
return buffer.toString('base64');
2011-09-09 20:56:22 +00:00
}
module.exports = btoa;
}());