JSFiddle - React, Tailwind, and code Playground

by Aaron Zhang

JavaScript

(function (angular) {
    var class2type = {};

    var toString = class2type.toString;

    var hasOwn = class2type.hasOwnProperty;
    var r20 = /%20/g;

    angular.forEach("Boolean Number String Function Array Date RegExp Object Error".split(" "), function (name, i) {
        class2type["[object " + name + "]"] = name.toLowerCase();
    });

    function jqType(obj) {
        if (obj == null) {
            return obj + "";
        }
        // Support: Android < 4.0, iOS < 6 (functionish RegExp)
        return typeof obj === "object" || typeof obj === "function" ? class2type[toString.call(obj)] || "object" : typeof obj;
    }

    function jqIsWindow(obj) {
        return obj != null && obj === obj.window;
    }

    function jqIsPlainObject(obj) {
        // Not plain objects:
        // - Any object or value whose internal [[Class]] property is not "[object Object]"
        // - DOM nodes
        // - window
        if (jqType(obj) !== "object" || obj.nodeType || jqIsWindow(obj)) {
            return false;
        }

        if (obj.constructor && !hasOwn.call(obj.constructor.prototype, "isPrototypeOf")) {
            return false;
        }

        // If the function hasn't returned already, we're confident that
        // |obj| is a plain object, created by {} or constructed with new Object
        return true;
    }

    function buildParams(prefix, obj, traditional, add) {
        var name;

        if (angular.isArray(obj)) {
            // Serialize array item.
            angular.forEach(obj, function (v, i) {
                if (traditional || rbracket.test(prefix)) {
                    // Treat each array item as a scalar.
                    add(prefix, v);

                } else {
                    // Item is non-scalar (array or object), encode its numeric index.
                    buildParams(prefix + "[" + (typeof v === "object" ? i : "") + "]", v, traditional, add);
                }
            });

        } else if (!traditional &&...