debitoor / safe-json-stringify

A wrapper for JSON.stringify that handles circular references and prevent defined getters from throwing errors.
https://www.npmjs.com/package/safe-json-stringify
56 stars 16 forks source link

Properties that are not enumerable and have circular reference is #13

Closed szwalkowski closed 3 years ago

szwalkowski commented 3 years ago

Hi, some errors are having properties that are not enumerable. Yet can be circular. https://stackoverflow.com/questions/18277890/why-cant-i-see-the-keys-of-an-error-object

While method decirc is iterating over Object.keys - that is not going to output those. Is there anything against using "Object.getOwnPropertyNames()" ?

      var keys = Object.getOwnPropertyNames(val)
      for (i = 0; i < keys.length; i++) {
        var key = keys[i]
        decirc(val[key], key, stack, val)
      }