JSFiddle - React, Tailwind, and code Playground

by DazWilkin

HTML

<link rel="stylesheet" href="http://code.jquery.com/qunit/git/qunit.css">
<script src="http://code.jquery.com/qunit/git/qunit.js"></script>
<h1 id="qunit-header">partial</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup, will be hidden</div>

JavaScript

/*global $,jQuery,console*/
$(function() {

    "use strict";

    var add;

    // Overrides
    Function.prototype.curry = function() {
        // http://ejohn.org/blog/partial-functions-in-javascript/
        var fn = this,
            args = Array.prototype.slice.call(arguments);
        return function() {
            return fn.apply(this, args.concat(Array.prototype.slice.call(arguments)));
        };
    };
    Function.prototype.badpartial = function() {
        // http://ejohn.org/blog/partial-functions-in-javascript/
        var fn = this,
            args = Array.prototype.slice.call(arguments);
        return function() {
            var i, arg = 0;
            for (i = 0; i < args.length && arg < arguments.length; i = i + 1) {
                if (args[i] === undefined) {
                    args[i] = arguments[arg++];
                }
            }
            return fn.apply(this, args);
        };
    };
    Function.prototype.partial = function() {
        // http://www.opengamma.com/blog/2012/03/22/partial-application-in-javascript-revisited
        var method = this,
            orig = arguments,
            orig_len = orig.length,
            key, new_method = function() {
                var arguments_len = arguments.length,
                    args = [],
                    i = 0,
                    j = 0;
                if (!arguments_len) return method.apply(this, Array.prototype.slice.call(orig));
                for (; i < orig_len; i++)
                args.push(orig[i] === void 0 ? arguments[j++] : orig[i]);
                return method.apply(this, args.concat(Array.prototype.slice.call(arguments, j, arguments_len)));
            };
        // if the function instance has been extended, copy all of its properties
        for (key in method) if (method.hasOwnProperty(key)) new_method[key] = method[key];
        return new_method;
    };

    add = function(x, y) {
        return x + y;
    }

    test("Resig's partial", function() {
...