davidmarkclements / rfdc

Really Fast Deep Clone
MIT License
643 stars 25 forks source link

Working with errors #22

Open maciej-sielski opened 3 years ago

maciej-sielski commented 3 years ago

Hi guys, I have a problem with copying objects that contain Error objects. serializing Error causes to completely loosing its properties.

When you look at cloneProto function I think you could change the for clause to fetch property names

const props = Object.getOwnPropertyNames(o); for (const k of props) {

We loose name but at least we have message and stack. What do you think?

maciej-sielski commented 3 years ago

Please excuse my ignorance. for in has to stay in order to iterate over object's prototype properties. So the question remaining is can we ADD iteration over Object.getOwnPropertyNames(o); ?

titanism commented 10 months ago

Hi there @maciej-sielski, you could use parse-err package for Errors. See https://www.npmjs.com/package/parse-err and https://github.com/cabinjs/parse-err