* Checks whether an object has a safe Symbol.iterator — i.e. one that is * either own or inherited from a non-Object.prototype chain. This prevents * prototype-pollution attacks from injecting a fake iterator on * Object.prototype. * @param {object} obj * @returns {boolean}
(obj)
| 320 | * @returns {boolean} |
| 321 | */ |
| 322 | function hasSafeIterator (obj) { |
| 323 | const prototype = Object.getPrototypeOf(obj) |
| 324 | const ownIterator = Object.hasOwn(obj, Symbol.iterator) |
| 325 | return ownIterator || (prototype != null && prototype !== Object.prototype && typeof obj[Symbol.iterator] === 'function') |
| 326 | } |
| 327 | |
| 328 | /** |
| 329 | * @param {Blob|Buffer|import ('stream').Stream} body |
no outgoing calls
no test coverage detected