Codebase list node-has-binary / 518747d
fix(*): fix the case when toJSON() returns a Buffer (#6) Damien Arrachequesne authored 7 years ago GitHub committed 7 years ago
2 changed file(s) with 6 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
4444
4545 // see: https://github.com/Automattic/has-binary/pull/4
4646 if (obj.toJSON && typeof obj.toJSON === 'function') {
47 obj = obj.toJSON();
47 return hasBinary(obj.toJSON());
4848 }
4949
5050 for (var key in obj) {
2525
2626 it('should work with an object that contains a buffer', function () {
2727 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'); }};
2833 assert(hasBinary(ob));
2934 });
3035