| 3521 | var forEach = require("@sinonjs/commons").prototypes.array.forEach; |
| 3522 | |
| 3523 | function walkInternal(obj, iterator, context, originalObj, seen) { |
| 3524 | var proto, prop; |
| 3525 | |
| 3526 | if (typeof Object.getOwnPropertyNames !== "function") { |
| 3527 | // We explicitly want to enumerate through all of the prototype's properties |
| 3528 | // in this case, therefore we deliberately leave out an own property check. |
| 3529 | /* eslint-disable-next-line guard-for-in */ |
| 3530 | for (prop in obj) { |
| 3531 | iterator.call(context, obj[prop], prop, obj); |
| 3532 | } |
| 3533 | |
| 3534 | return; |
| 3535 | } |
| 3536 | |
| 3537 | forEach(Object.getOwnPropertyNames(obj), function(k) { |
| 3538 | if (seen[k] !== true) { |
| 3539 | seen[k] = true; |
| 3540 | var target = typeof Object.getOwnPropertyDescriptor(obj, k).get === "function" ? originalObj : obj; |
| 3541 | iterator.call(context, k, target); |
| 3542 | } |
| 3543 | }); |
| 3544 | |
| 3545 | proto = Object.getPrototypeOf(obj); |
| 3546 | if (proto) { |
| 3547 | walkInternal(proto, iterator, context, originalObj, seen); |
| 3548 | } |
| 3549 | } |
| 3550 | |
| 3551 | /* Walks the prototype chain of an object and iterates over every own property |
| 3552 | * name encountered. The iterator is called in the same fashion that Array.prototype.forEach |