Skip to content

Instantly share code, notes, and snippets.

@alpercitak
Created March 6, 2022 16:18
Show Gist options
  • Save alpercitak/bb123ead2fd6ad25f00a4439a066bd2e to your computer and use it in GitHub Desktop.
Save alpercitak/bb123ead2fd6ad25f00a4439a066bd2e to your computer and use it in GitHub Desktop.
intercept function - call another function with original result & parameters
const add = (key, fn) => {
fn = (() => {
let original_fn = fn;
return (...params) => {
const original_result = original_fn.apply(this, params);
return another_func(...original_result);
};
})();
};
add("method1", (id) => [`/users/${id}`])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment