Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function hasBinary(data) {
}
}
} else if (obj && 'object' == typeof obj) {
if (obj.toJSON) {
if (obj.toJSON && 'function' == typeof obj.toJSON) {
obj = obj.toJSON();
}

Expand Down
4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ describe('has-binarydata', function(){
});

it('should work with an object that does not contain binary', function() {
var ob = {a: 'a', b: [], c: 1234};
var ob = {a: 'a', b: [], c: 1234, toJSON: '{\"a\": \"a\"}'};
assert(!hasBinary(ob));
});

it('should work with an object that contains a buffer', function() {
var ob = {a: 'a', b: new Buffer('abc'), c: 1234};
var ob = {a: 'a', b: new Buffer('abc'), c: 1234, toJSON: '{\"a\": \"a\"}'};
assert(hasBinary(ob));
});

Expand Down