lib/flip.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.flip = flip;
/**
* Returns a function that is like the original function,
* only the first two arguments are flipped.
*
* @since v0.1.0
* @param {Function} fn
* @return {Function}
* @example
* const merge = (a, b) => [].concat(a, b)
* flip(merge)(1, 2) // => [2, 1]
*/
function flip(fn) {
return function (y, x) {
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
return fn(x, y, args);
};
}