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.3 to 1.0.4

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,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))};
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(r,o,n){var u;return(u=t.call(this,"Request to "+r+" gave status "+o)||this).url=void 0,u.status=void 0,u.response=void 0,Object.setPrototypeOf(s(u),e.prototype),u.name="BadStatusError",u.url=r,u.status=o,u.response=n,u}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.4
## Changes
- Add informations on errors
# 1.0.3

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

{
"name": "@swan-io/request",
"version": "1.0.3",
"version": "1.0.4",
"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