convert non-buffer objects first to strings

This commit is contained in:
AJ ONeal 2013-07-25 09:14:17 -07:00
parent 07082fdb4e
commit 8b15697a10
1 changed files with 10 additions and 1 deletions

View File

@ -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;