Skip to content

Instantly share code, notes, and snippets.

@Lcfvs
Created March 23, 2019 10:07
Show Gist options
  • Select an option

  • Save Lcfvs/bfcb17ad3daeb69642f71728a8726bfb to your computer and use it in GitHub Desktop.

Select an option

Save Lcfvs/bfcb17ad3daeb69642f71728a8726bfb to your computer and use it in GitHub Desktop.
/**
* Usage:
* function fn([{a, b}, out], c) {
* out.c = c
* out.d = a + b + c
* }
*
* const obj = {a: 1, b: 2}
* io(fn, obj, 3)
* console.log(obj) // obj = {a: 1, b: 2, c: 3, d: 6}
*/
export default function io (fn, input, ...args) {
return fn.call(this, [input, input], ...args)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment