Skip to content
Open
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
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ function hasBinary (obj) {
}

// see: https://github.com/Automattic/has-binary/pull/4
if (obj.toJSON && typeof obj.toJSON === 'function') {
return hasBinary(obj.toJSON());
if (obj.toJSON && typeof obj.toJSON === 'function' && arguments.length === 1) {
return hasBinary(obj.toJSON(), true);
}

for (var key in obj) {
Expand Down
5 changes: 5 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ describe('has-binarydata', function () {
assert(hasBinary(ob));
});

it('should work with an object by calling toJSON() once', function () {
var ob = { toJSON: function () { return this; } };
assert(!hasBinary(ob));
});

it('should work with null', function () {
assert(!hasBinary(null));
});
Expand Down