Skip to content

Instantly share code, notes, and snippets.

@Slackwise
Last active October 6, 2021 17:59
Show Gist options
  • Save Slackwise/338b029ac430b3af322c206ce485c139 to your computer and use it in GitHub Desktop.
Save Slackwise/338b029ac430b3af322c206ce485c139 to your computer and use it in GitHub Desktop.
Example advising function and use.
const advise = (fn, preFn = (...args) => args, postFn = (...args) => args) =>
(...args) =>
postFn(fn(...preFn(...args)));
add = (x, y) =>
x + y;
advisedAdd = advise(
add,
(x, y) => [x + 1, y + 1],
output => console.log(`Output is ${output}`)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment