Created
January 25, 2021 20:55
-
-
Save stephenhuh/3045372e163e4f830e53d234a02c73a0 to your computer and use it in GitHub Desktop.
dynamic fn names
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function decorateRBAC(fn) { | |
console.log('----start decorate-----'); | |
console.log(...arguments); | |
console.log('fn-name:', fn.name); | |
console.log('----end-----'); | |
return fn; | |
} | |
function withValidation(fn) { | |
const handlerName = fn.name; | |
console.log('--- start validation'); | |
console.log('handlerName', handlerName); | |
Object.defineProperty(handle, "handlerName", { value: handlerName }); | |
console.log('--- end validation---'); | |
function handle(event) { | |
console.log('got event!', event); | |
} | |
return handle; | |
} | |
const getOrders = () => { | |
return 'GOT ORDERS (NOT NAME)'; | |
} | |
decorateRBAC(withValidation(getOrders)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment