btoa.js/index.js

18 lines
270 B
JavaScript
Raw 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 {
2021-09-01 14:38:47 +00:00
buffer = Buffer.from(String(str), 'binary');
}
return buffer.toString('base64');
2011-09-09 20:56:22 +00:00
}
module.exports = btoa;
}());