convert non-buffer objects first to strings
This commit is contained in:
parent
07082fdb4e
commit
8b15697a10
|
@ -2,7 +2,16 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function btoa(str) {
|
function btoa(str) {
|
||||||
return new Buffer(str.toString(), 'binary').toString('base64');
|
var buffer
|
||||||
|
;
|
||||||
|
|
||||||
|
if (str instanceof Buffer) {
|
||||||
|
buffer = str;
|
||||||
|
} else {
|
||||||
|
buffer = new Buffer(str.toString(), 'binary');
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer.toString('base64');
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = btoa;
|
module.exports = btoa;
|
||||||
|
|
Loading…
Reference in New Issue