flip-fn

v1.0.0
flips first two arguments to a function and calls the rest of the arguments in order
flip function functional helper higher-order

flip

Build Status

Takes function as argument and returns a new function that will call original function with first two arguments flipped. Higher order functions like this can be seen in languages like Elm and Haskell

use

function  x(a, b) {
  return a - b;
}

var flipX = flip(x);

x(2, 1) //returns 1
flipX(2, 1) //returns -1
npm i flip-fn

Metadata

  • MIT
  • Whatever
  • Conor Hastings
  • released 2/21/2016

Downloads

Maintainers