JSFiddle - React, Tailwind, and code Playground

by Gajus Kuizinas

JavaScript

/**
 * Transforms a function that takes multiple arguments into a
 * function that takes just the last argument of the original function.
 *
 * @param {Function}
 * @param {...*}
 */
var curry = function (method) {
    var args = Array.prototype.slice.call(arguments, 1);

    return function (callback) {
        args.push(callback);

        return method.apply({}, args);
    };
};