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

@swan-io/request

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swan-io/request - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

2

dist/Request.js

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

var t=require("@swan-io/boxed");function e(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(e=function(){return!!t})()}function r(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function n(t){return n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},n(t)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}function u(t){var r="function"==typeof Map?new Map:void 0;return u=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,u)}function u(){return function(t,r,n){if(e())return Reflect.construct.apply(null,arguments);var u=[null];u.push.apply(u,r);var i=new(t.bind.apply(t,u));return n&&o(i,n.prototype),i}(t,arguments,n(this).constructor)}return u.prototype=Object.create(t.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),o(u,t)},u(t)}var i=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,"Request to "+e+" failed")||this).url=void 0,r.url=e,r}return r(e,t),e}(/*#__PURE__*/u(Error)),s=/*#__PURE__*/function(t){function e(e,r){var n;return null==r?((n=t.call(this,"Request to "+e+" timed out")||this).url=void 0,n.timeout=void 0):((n=t.call(this,"Request to "+e+" timed out (> "+r+"ms)")||this).url=void 0,n.timeout=void 0),n.url=e,n.timeout=r,function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(n)}return r(e,t),e}(/*#__PURE__*/u(Error)),l=/*#__PURE__*/function(t){function e(e,r,n){var o;return(o=t.call(this,"Request to "+e+" gave status "+r)||this).url=void 0,o.status=void 0,o.response=void 0,o.url=e,o.status=r,o.response=n,o}return r(e,t),e}(/*#__PURE__*/u(Error)),a=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,"Request to "+e+" gave an empty response")||this).url=void 0,r.url=e,r}return r(e,t),e}(/*#__PURE__*/u(Error)),c={make:function(e){var r=e.url,n=e.method,o=void 0===n?"GET":n,u=e.responseType,l=e.body,a=e.headers,c=e.withCredentials,p=void 0!==c&&c,f=e.onLoadStart,d=e.onProgress,v=e.timeout;return t.Future.make(function(e){var n=new XMLHttpRequest;n.withCredentials=p,n.open(o,r,!0),null!=u&&(n.responseType=u),null!=v&&(n.timeout=v),null!=a&&t.Dict.entries(a).forEach(function(t){return n.setRequestHeader(t[0],t[1])});var c=function(){y(),e(t.Result.Error(new i(r)))},E=function(){y(),e(t.Result.Error(new s(r,v)))},h=function(){y();var o=n.status,u=t.Option.fromNullable(n.response);e(t.Result.Ok({url:r,status:o,ok:o>=200&&o<300,response:u,xhr:n}))},y=function(){n.removeEventListener("error",c),n.removeEventListener("load",h),n.removeEventListener("timeout",E),null!=f&&n.removeEventListener("loadstart",f),null!=d&&n.removeEventListener("progress",d)};return n.addEventListener("error",c),n.addEventListener("load",h),n.addEventListener("timeout",E),null!=f&&n.addEventListener("loadstart",f),null!=d&&n.addEventListener("progress",d),n.send(l),function(){y(),n.abort()}})}};exports.BadStatusError=l,exports.EmptyResponseError=a,exports.NetworkError=i,exports.Request=c,exports.TimeoutError=s,exports.badStatusToError=function(e){return e.ok?t.Result.Ok(e):t.Result.Error(new l(e.url,e.status,e.response.toUndefined()))},exports.emptyToError=function(t){return t.response.toResult(new a(t.url))};
var t=require("@swan-io/boxed");function e(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(e=function(){return!!t})()}function r(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,n(t,e)}function o(t){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},o(t)}function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}function u(t){var r="function"==typeof Map?new Map:void 0;return u=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,u)}function u(){return function(t,r,o){if(e())return Reflect.construct.apply(null,arguments);var u=[null];u.push.apply(u,r);var s=new(t.bind.apply(t,u));return o&&n(s,o.prototype),s}(t,arguments,o(this).constructor)}return u.prototype=Object.create(t.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),n(u,t)},u(t)}function s(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var i=/*#__PURE__*/function(t){function e(r){var o;return(o=t.call(this,"Request to "+r+" failed")||this).url=void 0,Object.setPrototypeOf(s(o),e.prototype),o.name="NetworkError",o.url=r,o}return r(e,t),e}(/*#__PURE__*/u(Error)),a=/*#__PURE__*/function(t){function e(r,o){var n;return null==o?((n=t.call(this,"Request to "+r+" timed out")||this).url=void 0,n.timeout=void 0):((n=t.call(this,"Request to "+r+" timed out (> "+o+"ms)")||this).url=void 0,n.timeout=void 0),Object.setPrototypeOf(s(n),e.prototype),n.name="TimeoutError",n.url=r,n.timeout=o,s(n)}return r(e,t),e}(/*#__PURE__*/u(Error)),l=/*#__PURE__*/function(t){function e(e,r,o){var n;return(n=t.call(this,"Request to "+e+" gave status "+r)||this).url=void 0,n.status=void 0,n.response=void 0,n.url=e,n.status=r,n.response=o,n}return r(e,t),e}(/*#__PURE__*/u(Error)),c=/*#__PURE__*/function(t){function e(r){var o;return(o=t.call(this,"Request to "+r+" gave an empty response")||this).url=void 0,Object.setPrototypeOf(s(o),e.prototype),o.name="EmptyResponseError",o.url=r,o}return r(e,t),e}(/*#__PURE__*/u(Error)),p={make:function(e){var r=e.url,o=e.method,n=void 0===o?"GET":o,u=e.responseType,s=e.body,l=e.headers,c=e.withCredentials,p=void 0!==c&&c,f=e.onLoadStart,d=e.onProgress,v=e.timeout;return t.Future.make(function(e){var o=new XMLHttpRequest;o.withCredentials=p,o.open(n,r,!0),null!=u&&(o.responseType=u),null!=v&&(o.timeout=v),null!=l&&t.Dict.entries(l).forEach(function(t){return o.setRequestHeader(t[0],t[1])});var c=function(){m(),e(t.Result.Error(new i(r)))},y=function(){m(),e(t.Result.Error(new a(r,v)))},E=function(){m();var n=o.status,u=t.Option.fromNullable(o.response);e(t.Result.Ok({url:r,status:n,ok:n>=200&&n<300,response:u,xhr:o}))},m=function(){o.removeEventListener("error",c),o.removeEventListener("load",E),o.removeEventListener("timeout",y),null!=f&&o.removeEventListener("loadstart",f),null!=d&&o.removeEventListener("progress",d)};return o.addEventListener("error",c),o.addEventListener("load",E),o.addEventListener("timeout",y),null!=f&&o.addEventListener("loadstart",f),null!=d&&o.addEventListener("progress",d),o.send(s),function(){m(),o.abort()}})}};exports.BadStatusError=l,exports.EmptyResponseError=c,exports.NetworkError=i,exports.Request=p,exports.TimeoutError=a,exports.badStatusToError=function(e){return e.ok?t.Result.Ok(e):t.Result.Error(new l(e.url,e.status,e.response.toUndefined()))},exports.emptyToError=function(t){return t.response.toResult(new c(t.url))};
//# sourceMappingURL=Request.js.map

@@ -0,1 +1,7 @@

# 1.0.3
## Changes
- Add informations on errors
# 1.0.2

@@ -2,0 +8,0 @@

{
"name": "@swan-io/request",
"version": "1.0.2",
"version": "1.0.3",
"description": "Wrapper for XMLHttpRequest with better data-structures",

@@ -5,0 +5,0 @@ "main": "dist/Request.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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