convert non-buffer objects first to strings
This commit is contained in:
parent
f76c0404fb
commit
f0250c3cb3
11
index.js
11
index.js
|
@ -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