Ahungry Around
Project page:
https://github.com/ahungry/ahungry-around
A nodejs library for easily and recursively wrapping an entire codebase in a custom Proxy handler (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
Goal
To help allow global invocations of Aspect Oriented Programming (AOP), such as profiling or logging etc.
Usage
See a sample in tests/test.js:
const AhungryAround = const HelloWorld = const Printer = let iter = 0let uiter = 0 const handler = { // A sample useful key value. const key = ` ` console const result = target return result } // Maybe you want a handler to just work on one class?const handler2 = { const key = ` ` console argumentsList = argumentsList let result = target return result } const a2 = handler2 'Uppercase'a2 const aa = handler 'Iterator'aa const hw = hwHelloWorld if iter !== 4 throw 'Test failure!' + iter
Which will produce output as such:
$ node ./tests/test.jsThis is the nth time calling handler, from flub ["Greetings"]GreetingsThis is the nth time calling handler, from log ["Greetings"]This is the nth time calling upcase handler, from log["Greetings"]GREETINGSThis is the nth time calling handler, from blub []blubThis is the nth time calling handler, from log ["blub"]This is the nth time calling upcase handler, from log ["blub"]BLUB
License
GPLv3