yanatan16 / nanoajax

An ajax library you need a microscope to see
MIT License
246 stars 42 forks source link

No uncompressed version? #12

Closed jenstornell closed 9 years ago

jenstornell commented 9 years ago

This works great! However there seems to be a nanoajax.min.js but no nanoajax.js?

I prefer compressing the js files myself when merging the js to one compact file.

jenstornell commented 9 years ago

In case you do not update it anymore, here is an unminified version:

! function(e, t) {
    function n() {
        if (t.XMLHttpRequest) return new t.XMLHttpRequest;
        try {
            return new t.ActiveXObject("MSXML2.XMLHTTP.3.0")
        } catch (e) {}
        throw new Error("no xmlhttp request able to be created")
    }

    function r(e, t, n) {
        e[t] = e[t] || n
    }
    t.nanoajax = e, e.ajax = function(e, t) {
        "string" == typeof e && (e = {
            url: e
        });
        var a = e.headers || {}, o = e.body,
            u = e.method || (o ? "POST" : "GET"),
            i = e.withCredentials || !1,
            s = n();
        s.onreadystatechange = function() {
            4 == s.readyState && t(s.status, s.responseText, s)
        }, o && (r(a, "X-Requested-With", "XMLHttpRequest"), r(a, "Content-Type", "application/x-www-form-urlencoded")), s.open(u, e.url, !0), s.withCredentials = i;
        for (var c in a) s.setRequestHeader(c, a[c]);
        s.send(o)
    }
}({}, function() {
    return this
}());
loup-brun commented 9 years ago

Have a look at index.js

jenstornell commented 9 years ago

I searched for nanoajax in index.js but it could not be found so I guess it does not work?

loup-brun commented 9 years ago

Well, if you look at the make file, the minifier wraps index.js with nanoajax, so I guess you can wrap it yourself, naming it however you like.

yanatan16 commented 9 years ago

@jenstornell index.js is the unminified version you are looking for. It is written as a CommonJS module, which is compatible with many tools, notably browserify.

In make, we call uglifyjs with the --wrap nanoajax argument, which wraps our CommonJS module in one large function and assigns exports to window.nanoajax.

To use this package, you can do a few things:

yanatan16 commented 9 years ago

If this solves your problem, go ahead and close the issue.

yanatan16 commented 9 years ago

Please reopen if you have further issues.