Files
frontend-app-learner-dashboard/src/utils/StrictDict.js
2022-05-25 14:27:26 -04:00

25 lines
545 B
JavaScript

/* eslint-disable no-console */
const strictGet = (target, name) => {
if (name === Symbol.toStringTag) {
return target;
}
if (name === '$$typeof') {
return typeof target;
}
if (name in target || name === '_reactFragment') {
return target[name];
}
console.log(name.toString());
console.error({ target, name });
const e = Error(`invalid property "${name.toString()}"`);
console.error(e.stack);
return undefined;
};
const StrictDict = (dict) => new Proxy(dict, { get: strictGet });
export default StrictDict;