Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

uhttp

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uhttp - npm Package Compare versions

Comparing version 1.1.0 to 1.1.2

2

bower.json
{
"name": "uhttp",
"version": "1.1.0",
"version": "1.1.2",
"main": "src/uhttp.js",

@@ -5,0 +5,0 @@ "ignore": [

@@ -1,2 +0,2 @@

/*! uhttp v1.1.0 | (c) 2015 @flux159 | http://flux159.github.io/uhttp/ */
!function(a,b){"function"==typeof define&&define.amd?define(b):a.uhttp=b(a)}(this,function(a){"use strict";function b(a,b){this.name=a,this.data={},b||(b={}),this.timeout=b.timeout||0}function c(a){return null!==a&&"object"==typeof a}function d(a){return null!==a&&"string"==typeof a}function e(a){return"[object File]"===y.call(a)}function f(a){return"[object Blob]"===y.call(a)}function g(a){return"[object FormData]"===y.call(a)}function h(a){return a}function i(a){return a}function j(a){return!c(a)||e(a)||f(a)||g(a)?a:JSON.stringify(a)}function k(a){var b,c=a.responseText;try{b=JSON.parse(c)}catch(d){b=c}return b}function l(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 m(a){var b=d(a)?l(a):a;return b.protocol===A.protocol&&b.host===A.host}function n(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 o(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 p(a){document.cookie=a+"=; expires=Thu, 01 Jan 1970 00:00:01 GMT;"}function q(a){C=a,C.headers&&c(C.headers)||(C.headers={})}function r(){return C}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 window[d]=function(a){e.parentNode.removeChild(e),window[d]=void 0,b.then.call(b,a),b["finally"].call(b,a)},e.onerror=function(a){e.parentNode.removeChild(e),window[d]=void 0,b["catch"].call(b,a),b["finally"].call(b,a)},e.src=a.replace("JSON_CALLBACK",d),document.body.appendChild(e),c}function v(b,d,h,i){h||(h={});var j={then:function(){},"catch":function(){},"finally":function(){}},k={then:function(a){return j.then=a,k},"catch":function(a){return j["catch"]=a,k},"finally":function(a){return j["finally"]=a,a}},l={};if(s(l,{Accept:"application/json, text/plain, */*"}),("POST"===b||"PUT"===b||"PATCH"===b)&&(!c(i)||e(i)||f(i)||g(i)||s(l,{"Content-Type":D})),s(l,C.headers),c(h.headers)&&s(l,h.headers),m(d)){var o={},p=n(h.xsrfCookieName||C.xsrfCookieName||B.xsrfCookieName);p&&(o[h.xsrfHeaderName||C.xsrfHeaderName||B.xsrfHeaderName]=p,s(l,o))}var q={timeout:h.timeout||C.timeout,cache:h.cache||C.cache,withCredentials:h.withCredentials||C.withCredentials,progressHandler:h.progressHandler||C.progressHandler,transformRequest:h.transformRequest||C.transformRequest||B.transformRequest,transformResponse:h.transformResponse||C.transformResponse||B.transformResponse,transformRequestData:h.transformRequestData||C.transformRequestData||B.transformRequestData,transformResponseData:h.transformResponseData||C.transformResponseData||B.transformResponseData},r={headers:l,options:q,type:b,url:d};q.transformRequest(r);var u=r.options.cache;if("GET"===r.type&&u){var v;if(v="boolean"==typeof u?x.get("__default").get(d):"Cache"===u.constructor.name?u.get(d):u.cache.get(d))return setTimeout(function(){j.then.call(j,v)},1),k}var w=a.XMLHttpRequest||ActiveXObject,y=new w("MSXML2.XMLHTTP.3.0");return r.options.progressHandler&&y.upload&&(y.upload.onprogress=r.options.progressHandler),y.open(r.type,r.url,!0),t(y,r.headers),r.options.withCredentials&&(y.withCredentials=!0),y.onreadystatechange=function(){if(4===y.readyState){r.options.transformResponse(y);var a=r.options.transformResponseData(y);y.status>=200&&y.status<300||304===y.status?("GET"===b&&u&&("boolean"==typeof u?x.get("__default").set(d,a):"Cache"===u.constructor.name?u.set(d,a):u.cache.set(d,a,u.options)),j.then.call(j,a,y.status,y)):j["catch"].call(j,a,y.status,y),j["finally"].call(j,a,y.status,y)}},y.send(r.options.transformRequestData(i)),r.options.timeout>0&&setTimeout(function(){y&&y.abort()},r.options.timeout),k}b.prototype.remove=function(a){delete this.data[a]},b.prototype.clear=function(){this.data={}},b.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)}},b.prototype.get=function(a){return this.data[a]};var w=function(){function a(){var a={__default:new b("__default")};return{get:function(c,d){if(a[c])return a[c];var e=new b(c,d);return a[c]=e,e}}}var c=null;return{getFactory:function(){return c||(c=a()),c}}}(),x=w.getFactory(),y=Object.prototype.toString,z=document.createElement("a"),A=l(window.location.href),B={transformRequest:h,transformResponse:i,transformRequestData:j,transformResponseData:k,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN"},C={headers:{},timeout:0,withCredentials:!1},D="application/json;charset=utf-8",E={};return E.setGlobalOptions=q,E.getGlobalOptions=r,E.CacheFactory=x,E.getCookie=n,E.setCookie=o,E.deleteCookie=p,E.get=function(a,b){return v("GET",a,b)},E.head=function(a,b){return v("HEAD",a,b)},E.put=function(a,b,c){return c||(c=b,b=null),v("PUT",a,b,c)},E.patch=function(a,b,c){return c||(c=b,b=null),v("PATCH",a,b,c)},E.post=function(a,b,c){return c||(c=b,b=null),v("POST",a,b,c)},E["delete"]=function(a,b){return v("DELETE",a,b)},E.jsonp=function(a){return u(a)},E});
/*! uhttp v1.1.1 | (c) 2015 @flux159 | http://flux159.github.io/uhttp/ */
!function(a,b){"function"==typeof define&&define.amd?define(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,b.then.call(b,a),b["finally"].call(b,a)},e.onerror=function(a){e.parentNode.removeChild(e),v[d]=void 0,b["catch"].call(b,a),b["finally"].call(b,a)},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)}},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});

@@ -325,2 +325,3 @@ /**

methods = null; res = null;
});

@@ -334,2 +335,3 @@ });

methods['finally'].call(methods, e);
methods = null;
});

@@ -462,3 +464,4 @@

methods['finally'].call(methods, parsedResponse, transformedResponse.status, transformedResponse);
request = null; transformedResponse = null; parsedResponse = null; methods = null;
return;
}

@@ -497,2 +500,3 @@

methods['finally'].call(methods, parsedResponse, transformedResponse.status, transformedResponse);
request = null; transformedResponse = null; parsedResponse = null; methods = null;
});

@@ -504,2 +508,3 @@ });

methods['finally'].call(methods, e);
methods = null;
});

@@ -506,0 +511,0 @@

{
"name": "uhttp",
"description": "A micro ajax http library with a unified api for browsers and nodejs",
"version": "1.1.0",
"version": "1.1.2",
"repository": "https://github.com/Flux159/uhttp",

@@ -6,0 +6,0 @@ "homepage": "http://flux159.github.io/uhttp/",

@@ -29,2 +29,7 @@ # uhttp

Use server side by requiring in your files:
```javascript
var uhttp = require('uhttp');
```
#### uhttp.get(url, [,options])

@@ -31,0 +36,0 @@ Use uhttp.get() to make a GET request. You can use either "then... catch" callbacks to obtain the response.

@@ -12,6 +12,8 @@ /**

}
})(this, function(root) {
})(this, function() {
'use strict';
var thisWindow = window;
/**

@@ -151,3 +153,3 @@ * A basic cache that stores requests and responses. Supports timeouts as well

var originUrl = urlResolve(window.location.href);
var originUrl = urlResolve(thisWindow.location.href);

@@ -299,7 +301,9 @@ function urlIsSameOrigin(requestUrl) {

//Success callback
window[callbackId] = function(res) {
thisWindow[callbackId] = function(res) {
script.parentNode.removeChild(script);
window[callbackId] = undefined;
thisWindow[callbackId] = undefined;
script = null; callbackId = null;
methods.then.call(methods, res);
methods['finally'].call(methods, res);
methods = null;
};

@@ -310,5 +314,7 @@

script.parentNode.removeChild(script);
window[callbackId] = undefined;
thisWindow[callbackId] = undefined;
script = null; callbackId = null;
methods['catch'].call(methods, e);
methods['finally'].call(methods, e);
methods = null;
};

@@ -439,3 +445,3 @@

//Create XHR request
var XHR = root.XMLHttpRequest || ActiveXObject;
var XHR = thisWindow.XMLHttpRequest || ActiveXObject;
var request = new XHR('MSXML2.XMLHTTP.3.0');

@@ -480,2 +486,3 @@

methods['finally'].call(methods, parsedResponse, request.status, request);
config = null; methods = null; request = null; parsedResponse = null;
}

@@ -482,0 +489,0 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc