Skip to content

Commit

Permalink
Merge pull request #16 from jlank/buffer-fix
Browse files Browse the repository at this point in the history
Fixed buffer checking
  • Loading branch information
jlank committed May 14, 2013
2 parents 7ee375d + 235649c commit e06fa93
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions jsontoxml.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ var xml_header = function(standalone) {

module.exports = function(obj,options){

if(typeof obj == 'string' || isBuffer(obj)) {
var Buffer = this.Buffer || function Buffer () {};

if(typeof obj == 'string' || obj instanceof Buffer) {
try{
obj = JSON.parse(obj.toString());
} catch(e){
Expand Down Expand Up @@ -179,9 +181,3 @@ function cdata(str){
if(str) return "<![CDATA["+str.replace(/]]>/g,'')+']]>';
return "<![CDATA[]]>";
};

function isBuffer(b){
if(typeof Buffer == 'undefined') return false;
return (b instanceof Buffer);
}

0 comments on commit e06fa93

Please sign in to comment.