f-utility
Version:
functional utilities
27 lines (24 loc) • 656 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.flip = undefined;
var _katsuCurry = require("katsu-curry");
/**
* take a function, flip the two parameters being passed to it, curry it
* @method flip
* @param {function} fn - a function
* @returns {*} the result of invoking function with two inverted parameters
* @public
* @example
* import {flip} from 'f-utility'
* const divide = (a, b) => a / b
* const ivideday = flip(divide)
* divide(1, 5) // 0.2
* ivideday(1, 5) // 5
*/
var flip = exports.flip = function flip(fn) {
return (0, _katsuCurry.curry)(function (a, b) {
return fn(b, a);
});
};
;