Using the following code:
const assrt = function () {
try {
return chaiAssert.apply(null, arguments);
}
catch (e) {
return handleError(e);
}
};
v.assert = new Proxy(assrt, {
get: function (target, prop) {
if(typeof prop === 'symbol'){
// I don't know what to do with symbols, so return
return Reflect.get(...arguments);
}
// but here! we still get properties that don't exist
if(!chaiAssert[prop]){
return handleError(
new Error(`The assertion library used does not have '${prop}' property or method.`)
);
}
return function () {
try {
return chaiAssert[prop].apply(null, arguments);
}
catch (e) {
return handleError(e);
}
}
}
});
the error I get with this code is:
TypeError: Cannot convert a Symbol value to a string
and this occurs on the line:
new Error(`The assertion library used does not have '${prop}' property or method.`));
I have used Proxies before, and I have never seen Symbols being passed to the get method of the Proxy. Does anyone know how to circumvent this problem?
Why are Symbols being passed to the Proxy get function and how do I properly handle that?
Symbol(util.inspect.custom), and think there are others that get sent as well.if(typeof prop === 'symbol'){.