| 1 | export function hasBinary(obj: any, toJSON?: boolean): boolean { |
| 2 | if (!obj || typeof obj !== "object") { |
| 3 | return false; |
| 4 | } |
| 5 | |
| 6 | if (obj instanceof ArrayBuffer || ArrayBuffer.isView(obj)) { |
| 7 | return true; |
| 8 | } |
| 9 | |
| 10 | if (Array.isArray(obj)) { |
| 11 | for (let i = 0, l = obj.length; i < l; i++) { |
| 12 | if (hasBinary(obj[i])) { |
| 13 | return true; |
| 14 | } |
| 15 | } |
| 16 | return false; |
| 17 | } |
| 18 | |
| 19 | for (const key in obj) { |
| 20 | if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) { |
| 21 | return true; |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | if (obj.toJSON && typeof obj.toJSON === "function" && !toJSON) { |
| 26 | return hasBinary(obj.toJSON(), true); |
| 27 | } |
| 28 | |
| 29 | return false; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Whether the client comes from the `redis` package |