Skip to content

Instantly share code, notes, and snippets.

@jsmanifest
Created June 9, 2020 15:01
Show Gist options
  • Save jsmanifest/9aa2b8ff9ed010999fd0362d5c7ebb97 to your computer and use it in GitHub Desktop.
Save jsmanifest/9aa2b8ff9ed010999fd0362d5c7ebb97 to your computer and use it in GitHub Desktop.
function makeInjectContext(context) {
return function (callback) {
return function (...args) {
let result = callback(...args)
if (typeof result === 'function') {
// Call it again and inject additional options
result = result(context)
}
return result
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment