create-error-types
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -12,14 +12,34 @@ import{isErrorName,createCustomError}from"./types.js"; | ||
return new Proxy(state,{get:getProxyProp.bind(undefined,onCreate)}); | ||
return new Proxy(state,getProxyHooks(onCreate)); | ||
}; | ||
const getProxyHooks=function(onCreate){ | ||
return Object.fromEntries( | ||
HOOK_NAMES.map((hookName)=>[ | ||
hookName, | ||
getProxyProp.bind(undefined,onCreate,hookName)])); | ||
const getProxyProp=function(onCreate,target,propName,receiver){ | ||
}; | ||
const HOOK_NAMES=["get","has","getOwnPropertyDescriptor"]; | ||
const getProxyProp=function( | ||
onCreate, | ||
methodName, | ||
target, | ||
propName, | ||
...args) | ||
{ | ||
createIfUnset({onCreate,target,propName,args}); | ||
return Reflect[methodName](target,propName,...args); | ||
}; | ||
const createIfUnset=function({onCreate,target,propName,args}){ | ||
if(!(propName in target)&&isErrorName(propName)){ | ||
const ErrorType=createCustomError(propName,onCreate); | ||
Reflect.set(target,propName,ErrorType,receiver); | ||
Reflect.set(target,propName,ErrorType,...args); | ||
} | ||
return Reflect.get(target,propName,receiver); | ||
}; | ||
//# sourceMappingURL=proxy.js.map |
{ | ||
"name": "create-error-types", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "exports": "./build/src/main.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28303
201