simplest functional AOP style hook helper
hook around a function to alter input and output.
Very simple. only 20 lines. The example below is longer than the code.
//take an innocent functionreturn a + b//and add hooks to it.plus = Hooxplus//now you can control input and outputplushookvar value = fnapplynull argsmapMathroundreturn Mathmaxvalue 0console.logplus13// 4console.logplus0.8 -5// 0console.logplus0.9 0.9// 2
in Aspect Oriented Programming, this function would be called an around hook. I have not implemented pre, and post hooks yet, because this is currently sufficent for my purposes.