convert non-buffer objects first to strings
This commit is contained in:
		
							parent
							
								
									07082fdb4e
								
							
						
					
					
						commit
						8b15697a10
					
				@ -2,7 +2,16 @@
 | 
			
		||||
  "use strict";
 | 
			
		||||
 | 
			
		||||
  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;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user