fix(*): fix the case when toJSON() returns a Buffer (#6)
Damien Arrachequesne authored 7 years ago
GitHub committed 7 years ago
44 | 44 |
|
45 | 45 |
// see: https://github.com/Automattic/has-binary/pull/4
|
46 | 46 |
if (obj.toJSON && typeof obj.toJSON === 'function') {
|
47 | |
obj = obj.toJSON();
|
|
47 |
return hasBinary(obj.toJSON());
|
48 | 48 |
}
|
49 | 49 |
|
50 | 50 |
for (var key in obj) {
|
25 | 25 |
|
26 | 26 |
it('should work with an object that contains a buffer', function () {
|
27 | 27 |
var ob = {a: 'a', b: new Buffer('abc'), c: 1234, toJSON: '{"a": "a"}'};
|
|
28 |
assert(hasBinary(ob));
|
|
29 |
});
|
|
30 |
|
|
31 |
it('should work with an object whose toJSON() returns a buffer', function () {
|
|
32 |
var ob = {a: 'a', b: [], c: 1234, toJSON: function () { return new Buffer('abc'); }};
|
28 | 33 |
assert(hasBinary(ob));
|
29 | 34 |
});
|
30 | 35 |
|