Open dkebler opened 4 years ago
just assuming one should pass all symbols through I did this.
let copyProps = (target, source) => {
Object.getOwnPropertyNames(source)
.concat(Object.getOwnPropertySymbols(source))
.forEach((prop) => {
if (typeof prop.match ==='function') {
if (prop.match(/^(?:initializer|constructor|prototype|arguments|caller|name|bind|call|apply|toString|length)$/))
return
}
Object.defineProperty(target, prop, Object.getOwnPropertyDescriptor(source, prop))
})
}
I am using the nodejs event emitter as a mixin and the in the latest version of nodejs 12.16 they haved added a Symbol property which breaks aggregation.
https://github.com/nodejs/node/pull/31788
if I add add a console.log(prop) to the forEach loop the output is below. You can see it throws an error when encountering a Symbol which is does have a match method because it is not a string.
I have no idea if these this new Symbol must be mixed in order for the Emitter class to work correctly but if so I have no idea of how to the do that properly.