Comparing version 1.2.1 to 1.2.2
{ | ||
"name": "uhttp", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"main": "src/uhttp.js", | ||
@@ -5,0 +5,0 @@ "ignore": [ |
@@ -1,2 +0,2 @@ | ||
/*! uhttp v1.1.5 | (c) 2015 @flux159 | http://flux159.github.io/uhttp/ */ | ||
!function(a,b){"undefined"!=typeof module?module.exports=b():a.uhttp=b(a)}(this,function(){"use strict";function a(a,b){this.name=a,this.data={},b||(b={}),this.timeout=b.timeout||0}function b(a){return null!==a&&"object"==typeof a}function c(a){return null!==a&&"string"==typeof a}function d(a){return"[object File]"===y.call(a)}function e(a){return"[object Blob]"===y.call(a)}function f(a){return"[object FormData]"===y.call(a)}function g(a){return a}function h(a){return a}function i(a){return!b(a)||d(a)||e(a)||f(a)?a:JSON.stringify(a)}function j(a){var b,c=a.responseText;try{b=JSON.parse(c)}catch(d){b=c}return b}function k(a){var b=a,c=document.documentMode;return c&&(z.setAttribute("href",b),b=z.href),z.setAttribute("href",b),{href:z.href,protocol:z.protocol?z.protocol.replace(/:$/,""):"",host:z.host,search:z.search?z.search.replace(/^\?/,""):"",hash:z.hash?z.hash.replace(/^#/,""):"",hostname:z.hostname,port:z.port,pathname:"/"===z.pathname.charAt(0)?z.pathname:"/"+z.pathname}}function l(a){var b=c(a)?k(a):a;return b.protocol===A.protocol&&b.host===A.host}function m(a){if(a){for(var b=a+"=",c=document.cookie.split(";"),d=0;d<c.length;d++){for(var e=c[d];" "===e.charAt(0);)e=e.substring(1);if(0===e.indexOf(b))return e.substring(b.length,e.length)}return""}return document.cookie}function n(a,b,c){if(c){var d=new Date;d.setTime(d.getTime()+24*c*60*60*1e3);var e="expires="+d.toUTCString();document.cookie=a+"="+b+"; "+e}else document.cookie=a+"="+b+"; "}function o(a){document.cookie=a+"=; expires=Thu, 01 Jan 1970 00:00:01 GMT;"}function p(a){C=a,C.headers&&b(C.headers)||(C.headers={})}function q(){return C}function r(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])}function s(a,b){for(var c in b)b.hasOwnProperty(c)&&a.setRequestHeader(c,b[c])}function t(a){var b={then:function(){},"catch":function(){},"finally":function(){}},c={then:function(a){return b.then=a,c},"catch":function(a){return b["catch"]=a,c},"finally":function(a){return b["finally"]=a,a}},d="uhttp_callback_"+(new Date).getTime()+"_"+Math.round(1e16*Math.random()).toString(36),e=document.createElement("script");return v[d]=function(a){e.parentNode.removeChild(e),v[d]=void 0,e=null,d=null,b.then.call(b,a),b["finally"].call(b,a),b=null},e.onerror=function(a){e.parentNode.removeChild(e),v[d]=void 0,e=null,d=null,b["catch"].call(b,a),b["finally"].call(b,a),b=null},e.src=a.replace("JSON_CALLBACK",d),document.body.appendChild(e),c}function u(a,c,g,h){g||(g={});var i={then:function(){},"catch":function(){},"finally":function(){}},j={then:function(a){return i.then=a,j},"catch":function(a){return i["catch"]=a,j},"finally":function(a){return i["finally"]=a,a}},k={};if(r(k,{Accept:"application/json, text/plain, */*"}),("POST"===a||"PUT"===a||"PATCH"===a)&&(!b(h)||d(h)||e(h)||f(h)||r(k,{"Content-Type":D})),r(k,C.headers),b(g.headers)&&r(k,g.headers),l(c)){var n={},o=m(g.xsrfCookieName||C.xsrfCookieName||B.xsrfCookieName);o&&(n[g.xsrfHeaderName||C.xsrfHeaderName||B.xsrfHeaderName]=o,r(k,n))}var p={timeout:g.timeout||C.timeout,cache:g.cache||C.cache,withCredentials:g.withCredentials||C.withCredentials,progressHandler:g.progressHandler||C.progressHandler,transformRequest:g.transformRequest||C.transformRequest||B.transformRequest,transformResponse:g.transformResponse||C.transformResponse||B.transformResponse,transformRequestData:g.transformRequestData||C.transformRequestData||B.transformRequestData,transformResponseData:g.transformResponseData||C.transformResponseData||B.transformResponseData},q={headers:k,options:p,type:a,url:c};p.transformRequest(q);var t=q.options.cache;if("GET"===q.type&&t){var u;if(u="boolean"==typeof t?x.get("__default").get(c):"Cache"===t.constructor.name?t.get(c):t.cache.get(c))return setTimeout(function(){i.then.call(i,u)},1),j}var w=v.XMLHttpRequest||ActiveXObject,y=new w("MSXML2.XMLHTTP.3.0");return q.options.progressHandler&&y.upload&&(y.upload.onprogress=q.options.progressHandler),y.open(q.type,q.url,!0),s(y,q.headers),q.options.withCredentials&&(y.withCredentials=!0),y.onreadystatechange=function(){if(4===y.readyState){q.options.transformResponse(y);var b=q.options.transformResponseData(y);y.status>=200&&y.status<300||304===y.status?("GET"===a&&t&&("boolean"==typeof t?x.get("__default").set(c,b):"Cache"===t.constructor.name?t.set(c,b):t.cache.set(c,b,t.options)),i.then.call(i,b,y.status,y)):i["catch"].call(i,b,y.status,y),i["finally"].call(i,b,y.status,y),q=null,i=null,y=null,b=null}},y.send(q.options.transformRequestData(h)),q.options.timeout>0&&setTimeout(function(){y&&y.abort()},q.options.timeout),j}var v=window;a.prototype.remove=function(a){delete this.data[a]},a.prototype.clear=function(){this.data={}},a.prototype.set=function(a,b,c){if(this.data[a]=b,c||(c={}),(c.timeout||this.timeout)>0){var d=this;setTimeout(function(){d.remove(a)},c.timeout||this.timeout)}},a.prototype.get=function(a){return this.data[a]};var w=function(){function b(){var b={__default:new a("__default")};return{get:function(c,d){if(b[c])return b[c];var e=new a(c,d);return b[c]=e,e}}}var c=null;return{getFactory:function(){return c||(c=b()),c}}}(),x=w.getFactory(),y=Object.prototype.toString,z=document.createElement("a"),A=k(v.location.href),B={transformRequest:g,transformResponse:h,transformRequestData:i,transformResponseData:j,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN"},C={headers:{},timeout:0,withCredentials:!1},D="application/json;charset=utf-8",E={};return E.setGlobalOptions=p,E.getGlobalOptions=q,E.CacheFactory=x,E.getCookie=m,E.setCookie=n,E.deleteCookie=o,E.get=function(a,b){return u("GET",a,b)},E.head=function(a,b){return u("HEAD",a,b)},E.put=function(a,b,c){return c||(c=b,b=null),u("PUT",a,b,c)},E.patch=function(a,b,c){return c||(c=b,b=null),u("PATCH",a,b,c)},E.post=function(a,b,c){return c||(c=b,b=null),u("POST",a,b,c)},E["delete"]=function(a,b){return u("DELETE",a,b)},E.jsonp=function(a){return t(a)},E}); | ||
/*! uhttp v1.2.2 | (c) 2015 @flux159 | http://flux159.github.io/uhttp/ */ | ||
!function(a,b){"undefined"!=typeof module?module.exports=b():a.uhttp=b(a)}(this,function(){"use strict";function a(a,b){this.name=a,this.data={},b||(b={}),this.timeout=b.timeout||0}function b(a){return null!==a&&"object"==typeof a}function c(a){return null!==a&&"string"==typeof a}function d(a){return"[object File]"===z.call(a)}function e(a){return"[object Blob]"===z.call(a)}function f(a){return"[object FormData]"===z.call(a)}function g(a){return a}function h(a){return a}function i(a){return!b(a)||d(a)||e(a)||f(a)?a:JSON.stringify(a)}function j(a){var b,c=a.responseText;try{b=JSON.parse(c)}catch(d){b=c}return b}function k(a){var b=a,c=document.documentMode;return c&&(A.setAttribute("href",b),b=A.href),A.setAttribute("href",b),{href:A.href,protocol:A.protocol?A.protocol.replace(/:$/,""):"",host:A.host,search:A.search?A.search.replace(/^\?/,""):"",hash:A.hash?A.hash.replace(/^#/,""):"",hostname:A.hostname,port:A.port,pathname:"/"===A.pathname.charAt(0)?A.pathname:"/"+A.pathname}}function l(a){var b=c(a)?k(a):a;return b.protocol===B.protocol&&b.host===B.host}function m(a){if(a){for(var b=a+"=",c=document.cookie.split(";"),d=0;d<c.length;d++){for(var e=c[d];" "===e.charAt(0);)e=e.substring(1);if(0===e.indexOf(b))return e.substring(b.length,e.length)}return""}return document.cookie}function n(a,b,c){if(c){var d=new Date;d.setTime(d.getTime()+24*c*60*60*1e3);var e="expires="+d.toUTCString();document.cookie=a+"="+b+"; "+e}else document.cookie=a+"="+b+"; "}function o(a){document.cookie=a}function p(a){document.cookie=a+"=; expires=Thu, 01 Jan 1970 00:00:01 GMT;"}function q(a){D=a,D.headers&&b(D.headers)||(D.headers={})}function r(){return D}function s(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])}function t(a,b){for(var c in b)b.hasOwnProperty(c)&&a.setRequestHeader(c,b[c])}function u(a){var b={then:function(){},"catch":function(){},"finally":function(){}},c={then:function(a){return b.then=a,c},"catch":function(a){return b["catch"]=a,c},"finally":function(a){return b["finally"]=a,a}},d="uhttp_callback_"+(new Date).getTime()+"_"+Math.round(1e16*Math.random()).toString(36),e=document.createElement("script");return w[d]=function(a){e.parentNode.removeChild(e),w[d]=void 0,e=null,d=null,b.then.call(b,a),b["finally"].call(b,a),b=null},e.onerror=function(a){e.parentNode.removeChild(e),w[d]=void 0,e=null,d=null,b["catch"].call(b,a),b["finally"].call(b,a),b=null},e.src=a.replace("JSON_CALLBACK",d),document.body.appendChild(e),c}function v(a,c,g,h){g||(g={});var i={then:function(){},"catch":function(){},"finally":function(){}},j={then:function(a){return i.then=a,j},"catch":function(a){return i["catch"]=a,j},"finally":function(a){return i["finally"]=a,a}},k={};if(s(k,{Accept:"application/json, text/plain, */*"}),("POST"===a||"PUT"===a||"PATCH"===a)&&(!b(h)||d(h)||e(h)||f(h)||s(k,{"Content-Type":E})),s(k,D.headers),b(g.headers)&&s(k,g.headers),l(c)){var n={},o=m(g.xsrfCookieName||D.xsrfCookieName||C.xsrfCookieName);o&&(n[g.xsrfHeaderName||D.xsrfHeaderName||C.xsrfHeaderName]=o,s(k,n))}var p={timeout:g.timeout||D.timeout,cache:g.cache||D.cache,withCredentials:g.withCredentials||D.withCredentials,progressHandler:g.progressHandler||D.progressHandler,transformRequest:g.transformRequest||D.transformRequest||C.transformRequest,transformResponse:g.transformResponse||D.transformResponse||C.transformResponse,transformRequestData:g.transformRequestData||D.transformRequestData||C.transformRequestData,transformResponseData:g.transformResponseData||D.transformResponseData||C.transformResponseData},q={headers:k,options:p,type:a,url:c};p.transformRequest(q);var r=q.options.cache;if("GET"===q.type&&r){var u;if(u="boolean"==typeof r?y.get("__default").get(c):"Cache"===r.constructor.name?r.get(c):r.cache.get(c))return setTimeout(function(){i.then.call(i,u)},1),j}var v=w.XMLHttpRequest||ActiveXObject,x=new v("MSXML2.XMLHTTP.3.0");return q.options.progressHandler&&x.upload&&(x.upload.onprogress=q.options.progressHandler),x.open(q.type,q.url,!0),t(x,q.headers),q.options.withCredentials&&(x.withCredentials=!0),x.onreadystatechange=function(){if(4===x.readyState){q.options.transformResponse(x);var b=q.options.transformResponseData(x);x.status>=200&&x.status<300||304===x.status?("GET"===a&&r&&("boolean"==typeof r?y.get("__default").set(c,b):"Cache"===r.constructor.name?r.set(c,b):r.cache.set(c,b,r.options)),i.then.call(i,b,x.status,x)):i["catch"].call(i,b,x.status,x),i["finally"].call(i,b,x.status,x),q=null,i=null,x=null,b=null}},x.send(q.options.transformRequestData(h)),q.options.timeout>0&&setTimeout(function(){x&&x.abort()},q.options.timeout),j}var w=window;a.prototype.remove=function(a){delete this.data[a]},a.prototype.clear=function(){this.data={}},a.prototype.set=function(a,b,c){if(this.data[a]=b,c||(c={}),(c.timeout||this.timeout)>0){var d=this;setTimeout(function(){d.remove(a)},c.timeout||this.timeout)}},a.prototype.get=function(a){return this.data[a]};var x=function(){function b(){var b={__default:new a("__default")};return{get:function(c,d){if(b[c])return b[c];var e=new a(c,d);return b[c]=e,e}}}var c=null;return{getFactory:function(){return c||(c=b()),c}}}(),y=x.getFactory(),z=Object.prototype.toString,A=document.createElement("a"),B=k(w.location.href),C={transformRequest:g,transformResponse:h,transformRequestData:i,transformResponseData:j,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN"},D={headers:{},timeout:0,withCredentials:!1},E="application/json;charset=utf-8",F={};return F.setGlobalOptions=q,F.getGlobalOptions=r,F.CacheFactory=y,F.getCookie=m,F.setCookie=n,F.setCookieFromString=o,F.deleteCookie=p,F.get=function(a,b){return v("GET",a,b)},F.head=function(a,b){return v("HEAD",a,b)},F.put=function(a,b,c){return c||(c=b,b=null),v("PUT",a,b,c)},F.patch=function(a,b,c){return c||(c=b,b=null),v("PATCH",a,b,c)},F.post=function(a,b,c){return c||(c=b,b=null),v("POST",a,b,c)},F["delete"]=function(a,b){return v("DELETE",a,b)},F.jsonp=function(a){return u(a)},F}); |
@@ -180,2 +180,6 @@ /** | ||
function setCookieFromString(cookieString) { | ||
document.cookie = cookieString; | ||
} | ||
/** | ||
@@ -578,2 +582,3 @@ * A function to delete a cookie from uhttp's fake document.cookie string | ||
exports.setCookie = setCookie; | ||
exports.setCookieFromString = setCookieFromString; | ||
exports.deleteCookie = deleteCookie; | ||
@@ -580,0 +585,0 @@ |
{ | ||
"name": "uhttp", | ||
"description": "A micro ajax http library with a unified api for browsers and nodejs", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"repository": "https://github.com/Flux159/uhttp", | ||
@@ -6,0 +6,0 @@ "homepage": "http://flux159.github.io/uhttp/", |
@@ -223,2 +223,10 @@ /** | ||
/** | ||
* Function to set cookie from a string (useful on server) | ||
* @param cookieString | ||
*/ | ||
function setCookieFromString(cookieString) { | ||
document.cookie = cookieString; | ||
} | ||
/** | ||
* A function to delete a cookie from the browser | ||
@@ -548,2 +556,3 @@ */ | ||
exports.setCookie = setCookie; | ||
exports.setCookieFromString = setCookieFromString; | ||
exports.deleteCookie = deleteCookie; | ||
@@ -550,0 +559,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
106052
1894