@fdaciuk/ajax
Advanced tools
Comparing version 0.1.1 to 0.1.2
/**! | ||
* ajax - v0.1.1 | ||
* ajax - v0.1.2 | ||
* Ajax module in Vanilla JS | ||
* https://github.com/fdaciuk/ajax | ||
* Thu Mar 03 2016 19:17:46 GMT-0300 (BRT) | ||
* Fri Mar 04 2016 09:01:42 GMT-0300 (BRT) | ||
* MIT (c) Fernando Daciuk | ||
*/ | ||
!function(e,t){"use strict";"function"==typeof define&&define.amd?define("Ajax",t):"object"==typeof exports?exports=module.exports=t():e.Ajax=t()}(this,function(){"use strict";function e(){var e={},t={};return t.methods={then:function(){},"catch":function(){},always:function(){},done:function(){console.warn("`done` is deprecated and will be removed in v2.0.0. Use `then` instead.")},error:function(){console.warn("`error` is deprecated and will be removed in v2.0.0. Use `catch` instead.")}},e.get=function(e){return t.XHRConnection("GET",e,null)},e.post=function(e,n){return t.XHRConnection("POST",e,n)},e.put=function(e,n){return t.XHRConnection("PUT",e,n)},e["delete"]=function(e,n){return t.XHRConnection("DELETE",e,n)},t.XHRConnection=function(e,n,o){var r=new XMLHttpRequest,s="application/x-www-form-urlencoded";return r.open(e,n||"",!0),r.setRequestHeader("Content-Type",s),r.addEventListener("readystatechange",t.ready,!1),r.send(t.objectToQueryString(o)),t.promises()},t.ready=function(){var e=this;e.readyState===e.DONE&&(e.removeEventListener("readystatechange",t.ready,!1),t.methods.always.apply(t.methods,t.parseResponse(e)),e.status>=200&&e.status<300?(t.methods.then.apply(t.methods,t.parseResponse(e)),t.methods.done.apply(t.methods,t.parseResponse(e))):(t.methods["catch"].apply(t.methods,t.parseResponse(e)),t.methods.error.apply(t.methods,t.parseResponse(e))))},t.parseResponse=function(e){var t;try{t=JSON.parse(e.responseText)}catch(n){t=e.responseText}return[t,e]},t.promises=function(){var e={};return Object.keys(t.methods).forEach(function(n){e[n]=t.generatePromise.call(this,n)},this),e},t.generatePromise=function(e){return function(n){return t.methods[e]=n,this}},t.objectToQueryString=function(e){return t.isObject(e)?t.getQueryString(e):e},t.getQueryString=function(e){return Object.keys(e).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&")},t.isObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},e}return e}); | ||
!function(e,t){"use strict";"function"==typeof define&&define.amd?define("Ajax",t):"object"==typeof exports?exports=module.exports=t():e.Ajax=t()}(this,function(){"use strict";function e(){var e={},t={};return t.methods={then:function(){},"catch":function(){},always:function(){},done:function(){},error:function(){}},e.get=function(e){return t.XHRConnection("GET",e,null)},e.post=function(e,n){return t.XHRConnection("POST",e,n)},e.put=function(e,n){return t.XHRConnection("PUT",e,n)},e["delete"]=function(e,n){return t.XHRConnection("DELETE",e,n)},t.XHRConnection=function(e,n,o){var r=new XMLHttpRequest,s="application/x-www-form-urlencoded";return r.open(e,n||"",!0),r.setRequestHeader("Content-Type",s),r.addEventListener("readystatechange",t.ready,!1),r.send(t.objectToQueryString(o)),t.promises()},t.ready=function(){var e=this;e.readyState===e.DONE&&(e.removeEventListener("readystatechange",t.ready,!1),t.methods.always.apply(t.methods,t.parseResponse(e)),e.status>=200&&e.status<300?(t.methods.then.apply(t.methods,t.parseResponse(e)),t.methods.done.apply(t.methods,t.parseResponse(e))):(t.methods["catch"].apply(t.methods,t.parseResponse(e)),t.methods.error.apply(t.methods,t.parseResponse(e))))},t.parseResponse=function(e){var t;try{t=JSON.parse(e.responseText)}catch(n){t=e.responseText}return[t,e]},t.promises=function(){var e={};return Object.keys(t.methods).forEach(function(n){e[n]=t.generatePromise.call(this,n)},this),e},t.generatePromise=function(e){return function(n){return t.generateDeprecatedMessage(e),t.methods[e]=n,this}},t.generateDeprecatedMessage=function(e){var t="@fdaciuk/ajax: `%s` is deprecated and will be removed in v2.0.0. Use `%s` instead.";switch(e){case"done":console.warn(t,"done","then");break;case"error":console.warn(t,"error","catch")}},t.objectToQueryString=function(e){return t.isObject(e)?t.getQueryString(e):e},t.getQueryString=function(e){return Object.keys(e).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&")},t.isObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},e}return e}); |
{ | ||
"name": "@fdaciuk/ajax", | ||
"description": "Ajax module in Vanilla JS", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"main": "dist/ajax.min.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -43,6 +43,16 @@ # Ajax | ||
You can just add the following line to your HTML file: | ||
You may use a CDN to get the latest version. | ||
**CDNJS:** | ||
```console | ||
https://cdnjs.com/libraries/fdaciuk-ajax | ||
``` | ||
**GitHub:** | ||
Or you may just add the following line to your HTML file: | ||
```html | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/fdaciuk-ajax/0.1.1/ajax.min.js"></script> | ||
<script src="//cdn.rawgit.com/fdaciuk/ajax/v0.1.2/dist/ajax.min.js"></script> | ||
``` | ||
@@ -49,0 +59,0 @@ |
9075
218