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

use-abortable-fetch

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-abortable-fetch - npm Package Compare versions

Comparing version 2.6.0 to 2.6.2

2

package.json
{
"name": "use-abortable-fetch",
"version": "2.6.0",
"version": "2.6.2",
"main": "release/index.js",

@@ -5,0 +5,0 @@ "umd:main": "release/index.umd.js",

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

function n(n){return n&&"object"==typeof n&&"default"in n?n.default:n}var t=require("react"),e=n(require("media-typer")),r=n(require("content-type"));const o=function(){function n(){}return n.prototype.then=function(t,e){const r=new n,o=this.s;if(o){const n=1&o?t:e;if(n){try{u(r,1,n(this.v))}catch(n){u(r,2,n)}return r}return this}return this.o=function(n){try{const o=n.v;1&n.s?u(r,1,t?t(o):o):e?u(r,1,e(o)):u(r,2,o)}catch(n){u(r,2,n)}},r},n}();function u(n,t,e){if(!n.s){if(e instanceof o){if(!e.s)return void(e.o=u.bind(null,n,t));1&t&&(t=e.s),e=e.v}if(e&&e.then)return void e.then(u.bind(null,n,t),u.bind(null,n,2));n.s=t,n.v=e;const r=n.o;r&&r(n)}}const i={};!function(){function n(n){this._entry=n,this._pact=null,this._resolve=null,this._return=null,this._promise=null}function t(n){return{value:n,done:!0}}function e(n){return{value:n,done:!1}}n.prototype[Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator"))]=function(){return this},n.prototype._yield=function(n){return this._resolve(n&&n.then?n.then(e):e(n)),this._pact=new o},n.prototype.next=function(n){const e=this;return e._promise=new Promise(function(r){const l=e._pact;if(null===l){const n=e._entry;if(null===n)return r(e._promise);function s(n){e._resolve(n&&n.then?n.then(t):t(n)),e._pact=null,e._resolve=null}e._entry=null,e._resolve=r,n(e).then(s,function(n){if(n===i)s(e._return);else{const t=new o;e._resolve(t),e._pact=null,e._resolve=null,_resolve(t,2,n)}})}else e._pact=null,e._resolve=r,u(l,1,n)})},n.prototype.return=function(n){const e=this;return e._promise=new Promise(function(r){const o=e._pact;if(null===o)return null===e._entry?r(e._promise):(e._entry=null,r(n&&n.then?n.then(t):t(n)));e._return=n,e._resolve=r,e._pact=null,u(o,2,i)})},n.prototype.throw=function(n){const t=this;return t._promise=new Promise(function(e,r){const o=t._pact;if(null===o)return null===t._entry?e(t._promise):(t._entry=null,r(n));t._resolve=e,t._pact=null,u(o,2,n)})}}(),module.exports=function(n,o){var u=t.useState({data:null,loading:0,error:null,controller:null}),i=u[0],l=u[1],s=t.useRef(!1);return t.useLayoutEffect(function(){return s.current=!0,function(){s.current=!1}},[]),t.useEffect(function(){var t=new AbortController;return n&&(l(function(n){return{data:null,loading:n.loading+1,error:null,controller:t}}),function(n,t,o,u){void 0===t&&(t={});try{var i=Object.assign({},t,{signal:o});Promise.resolve(function(t,o){try{var l=Promise.resolve(fetch(n,i)).then(function(n){function t(){u(function(n){return Object.assign({},n,{data:i,loading:n.loading-1})})}if(!n.ok){var o=new Error(n.statusText);throw o.status=n.status,o}var i=null,l=function(n){if(n){var t=r.parse(n),o=e.parse(t.type);if("json"===o.subtype)return!0;if("json"===o.suffix)return!0;if(o.suffix&&/\bjson\b/i.test(o.suffix))return!0;if(o.subtype&&/\bjson\b/i.test(o.subtype))return!0}return!1}(n.headers.get("content-type"))?Promise.resolve(n.json()).then(function(n){i=n}):Promise.resolve(n.text()).then(function(n){i=n});return l&&l.then?l.then(t):t()})}catch(n){return o(n)}return l&&l.then?l.then(void 0,o):l}(0,function(n){var t="AbortError"!==n.name?n:null;u(function(n){return Object.assign({},n,{error:t,loading:n.loading-1})})}))}catch(n){return Promise.reject(n)}}(n,o,t.signal,function(n){s.current&&l(n)})),function(){return t.abort()}},[o,n]),{data:i.data,loading:!!i.loading,error:i.error,abort:function(){return i.controller&&i.controller.abort()}}};
function n(n){return n&&"object"==typeof n&&"default"in n?n.default:n}var t=require("react"),e=n(require("media-typer")),r=n(require("content-type"));const o=function(){function n(){}return n.prototype.then=function(t,e){const r=new n,o=this.s;if(o){const n=1&o?t:e;if(n){try{u(r,1,n(this.v))}catch(n){u(r,2,n)}return r}return this}return this.o=function(n){try{const o=n.v;1&n.s?u(r,1,t?t(o):o):e?u(r,1,e(o)):u(r,2,o)}catch(n){u(r,2,n)}},r},n}();function u(n,t,e){if(!n.s){if(e instanceof o){if(!e.s)return void(e.o=u.bind(null,n,t));1&t&&(t=e.s),e=e.v}if(e&&e.then)return void e.then(u.bind(null,n,t),u.bind(null,n,2));n.s=t,n.v=e;const r=n.o;r&&r(n)}}const i={};!function(){function n(n){this._entry=n,this._pact=null,this._resolve=null,this._return=null,this._promise=null}function t(n){return{value:n,done:!0}}function e(n){return{value:n,done:!1}}n.prototype[Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator"))]=function(){return this},n.prototype._yield=function(n){return this._resolve(n&&n.then?n.then(e):e(n)),this._pact=new o},n.prototype.next=function(n){const e=this;return e._promise=new Promise(function(r){const l=e._pact;if(null===l){const n=e._entry;if(null===n)return r(e._promise);function s(n){e._resolve(n&&n.then?n.then(t):t(n)),e._pact=null,e._resolve=null}e._entry=null,e._resolve=r,n(e).then(s,function(n){if(n===i)s(e._return);else{const t=new o;e._resolve(t),e._pact=null,e._resolve=null,_resolve(t,2,n)}})}else e._pact=null,e._resolve=r,u(l,1,n)})},n.prototype.return=function(n){const e=this;return e._promise=new Promise(function(r){const o=e._pact;if(null===o)return null===e._entry?r(e._promise):(e._entry=null,r(n&&n.then?n.then(t):t(n)));e._return=n,e._resolve=r,e._pact=null,u(o,2,i)})},n.prototype.throw=function(n){const t=this;return t._promise=new Promise(function(e,r){const o=t._pact;if(null===o)return null===t._entry?e(t._promise):(t._entry=null,r(n));t._resolve=e,t._pact=null,u(o,2,n)})}}(),module.exports=function(n,o){var u=t.useState({data:null,loading:0,error:null,controller:null}),i=u[0],l=u[1],s=t.useRef(!1);return t.useLayoutEffect(function(){return s.current=!0,function(){s.current=!1}},[]),t.useEffect(function(){var t=new AbortController;return n&&(l(function(n){return{data:null,loading:n.loading+1,error:null,controller:t}}),function(n,t,o,u){void 0===t&&(t={});try{var i=Object.assign({},t,{signal:o});Promise.resolve(function(t,o){try{var l=Promise.resolve(fetch(n,i)).then(function(n){function t(){if(!n.ok){var t=new Error(n.statusText);throw t.status=n.status,t}u(function(n){return Object.assign({},n,{loading:n.loading-1})})}var o=n.headers.get("content-type"),i=function(){if(o){function t(){u(function(n){return Object.assign({},n,{data:i})})}var i=null,l=function(n){if(n){var t=r.parse(n),o=e.parse(t.type);if("json"===o.subtype)return!0;if("json"===o.suffix)return!0;if(o.suffix&&/\bjson\b/i.test(o.suffix))return!0;if(o.subtype&&/\bjson\b/i.test(o.subtype))return!0}return!1}(o)?Promise.resolve(n.json()).then(function(n){i=n}):Promise.resolve(n.text()).then(function(n){i=n});return l&&l.then?l.then(t):t()}}();return i&&i.then?i.then(t):t()})}catch(n){return o(n)}return l&&l.then?l.then(void 0,o):l}(0,function(n){var t="AbortError"!==n.name?n:null;u(function(n){return Object.assign({},n,{error:t,loading:n.loading-1})})}))}catch(n){return Promise.reject(n)}}(n,o,t.signal,function(n){s.current&&l(n)})),function(){return t.abort()}},[o,n]),{data:i.data,loading:!!i.loading,error:i.error,abort:function(){return i.controller&&i.controller.abort()}}};
//# sourceMappingURL=index.js.map

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

!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("media-typer"),require("content-type")):"function"==typeof define&&define.amd?define(["react","media-typer","content-type"],t):n.useAbortableFetch=t(n.react,n.mediaTyper,n.contentType)}(this,function(n,t,e){t=t&&t.hasOwnProperty("default")?t.default:t,e=e&&e.hasOwnProperty("default")?e.default:e;const r=function(){function n(){}return n.prototype.then=function(t,e){const r=new n,u=this.s;if(u){const n=1&u?t:e;if(n){try{o(r,1,n(this.v))}catch(n){o(r,2,n)}return r}return this}return this.o=function(n){try{const u=n.v;1&n.s?o(r,1,t?t(u):u):e?o(r,1,e(u)):o(r,2,u)}catch(n){o(r,2,n)}},r},n}();function o(n,t,e){if(!n.s){if(e instanceof r){if(!e.s)return void(e.o=o.bind(null,n,t));1&t&&(t=e.s),e=e.v}if(e&&e.then)return void e.then(o.bind(null,n,t),o.bind(null,n,2));n.s=t,n.v=e;const u=n.o;u&&u(n)}}const u={};return function(){function n(n){this._entry=n,this._pact=null,this._resolve=null,this._return=null,this._promise=null}function t(n){return{value:n,done:!0}}function e(n){return{value:n,done:!1}}n.prototype[Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator"))]=function(){return this},n.prototype._yield=function(n){return this._resolve(n&&n.then?n.then(e):e(n)),this._pact=new r},n.prototype.next=function(n){const e=this;return e._promise=new Promise(function(i){const l=e._pact;if(null===l){const n=e._entry;if(null===n)return i(e._promise);function s(n){e._resolve(n&&n.then?n.then(t):t(n)),e._pact=null,e._resolve=null}e._entry=null,e._resolve=i,n(e).then(s,function(n){if(n===u)s(e._return);else{const t=new r;e._resolve(t),e._pact=null,e._resolve=null,_resolve(t,2,n)}})}else e._pact=null,e._resolve=i,o(l,1,n)})},n.prototype.return=function(n){const e=this;return e._promise=new Promise(function(r){const i=e._pact;if(null===i)return null===e._entry?r(e._promise):(e._entry=null,r(n&&n.then?n.then(t):t(n)));e._return=n,e._resolve=r,e._pact=null,o(i,2,u)})},n.prototype.throw=function(n){const t=this;return t._promise=new Promise(function(e,r){const u=t._pact;if(null===u)return null===t._entry?e(t._promise):(t._entry=null,r(n));t._resolve=e,t._pact=null,o(u,2,n)})}}(),function(r,o){var u=n.useState({data:null,loading:0,error:null,controller:null}),i=u[0],l=u[1],s=n.useRef(!1);return n.useLayoutEffect(function(){return s.current=!0,function(){s.current=!1}},[]),n.useEffect(function(){var n=new AbortController;return r&&(l(function(t){return{data:null,loading:t.loading+1,error:null,controller:n}}),function(n,r,o,u){void 0===r&&(r={});try{var i=Object.assign({},r,{signal:o});Promise.resolve(function(r,o){try{var l=Promise.resolve(fetch(n,i)).then(function(n){function r(){u(function(n){return Object.assign({},n,{data:i,loading:n.loading-1})})}if(!n.ok){var o=new Error(n.statusText);throw o.status=n.status,o}var i=null,l=function(n){if(n){var r=e.parse(n),o=t.parse(r.type);if("json"===o.subtype)return!0;if("json"===o.suffix)return!0;if(o.suffix&&/\bjson\b/i.test(o.suffix))return!0;if(o.subtype&&/\bjson\b/i.test(o.subtype))return!0}return!1}(n.headers.get("content-type"))?Promise.resolve(n.json()).then(function(n){i=n}):Promise.resolve(n.text()).then(function(n){i=n});return l&&l.then?l.then(r):r()})}catch(n){return o(n)}return l&&l.then?l.then(void 0,o):l}(0,function(n){var t="AbortError"!==n.name?n:null;u(function(n){return Object.assign({},n,{error:t,loading:n.loading-1})})}))}catch(n){return Promise.reject(n)}}(r,o,n.signal,function(n){s.current&&l(n)})),function(){return n.abort()}},[o,r]),{data:i.data,loading:!!i.loading,error:i.error,abort:function(){return i.controller&&i.controller.abort()}}}});
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("media-typer"),require("content-type")):"function"==typeof define&&define.amd?define(["react","media-typer","content-type"],t):n.useAbortableFetch=t(n.react,n.mediaTyper,n.contentType)}(this,function(n,t,e){t=t&&t.hasOwnProperty("default")?t.default:t,e=e&&e.hasOwnProperty("default")?e.default:e;const r=function(){function n(){}return n.prototype.then=function(t,e){const r=new n,u=this.s;if(u){const n=1&u?t:e;if(n){try{o(r,1,n(this.v))}catch(n){o(r,2,n)}return r}return this}return this.o=function(n){try{const u=n.v;1&n.s?o(r,1,t?t(u):u):e?o(r,1,e(u)):o(r,2,u)}catch(n){o(r,2,n)}},r},n}();function o(n,t,e){if(!n.s){if(e instanceof r){if(!e.s)return void(e.o=o.bind(null,n,t));1&t&&(t=e.s),e=e.v}if(e&&e.then)return void e.then(o.bind(null,n,t),o.bind(null,n,2));n.s=t,n.v=e;const u=n.o;u&&u(n)}}const u={};return function(){function n(n){this._entry=n,this._pact=null,this._resolve=null,this._return=null,this._promise=null}function t(n){return{value:n,done:!0}}function e(n){return{value:n,done:!1}}n.prototype[Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator"))]=function(){return this},n.prototype._yield=function(n){return this._resolve(n&&n.then?n.then(e):e(n)),this._pact=new r},n.prototype.next=function(n){const e=this;return e._promise=new Promise(function(i){const s=e._pact;if(null===s){const n=e._entry;if(null===n)return i(e._promise);function l(n){e._resolve(n&&n.then?n.then(t):t(n)),e._pact=null,e._resolve=null}e._entry=null,e._resolve=i,n(e).then(l,function(n){if(n===u)l(e._return);else{const t=new r;e._resolve(t),e._pact=null,e._resolve=null,_resolve(t,2,n)}})}else e._pact=null,e._resolve=i,o(s,1,n)})},n.prototype.return=function(n){const e=this;return e._promise=new Promise(function(r){const i=e._pact;if(null===i)return null===e._entry?r(e._promise):(e._entry=null,r(n&&n.then?n.then(t):t(n)));e._return=n,e._resolve=r,e._pact=null,o(i,2,u)})},n.prototype.throw=function(n){const t=this;return t._promise=new Promise(function(e,r){const u=t._pact;if(null===u)return null===t._entry?e(t._promise):(t._entry=null,r(n));t._resolve=e,t._pact=null,o(u,2,n)})}}(),function(r,o){var u=n.useState({data:null,loading:0,error:null,controller:null}),i=u[0],s=u[1],l=n.useRef(!1);return n.useLayoutEffect(function(){return l.current=!0,function(){l.current=!1}},[]),n.useEffect(function(){var n=new AbortController;return r&&(s(function(t){return{data:null,loading:t.loading+1,error:null,controller:n}}),function(n,r,o,u){void 0===r&&(r={});try{var i=Object.assign({},r,{signal:o});Promise.resolve(function(r,o){try{var s=Promise.resolve(fetch(n,i)).then(function(n){function r(){if(!n.ok){var t=new Error(n.statusText);throw t.status=n.status,t}u(function(n){return Object.assign({},n,{loading:n.loading-1})})}var o=n.headers.get("content-type"),i=function(){if(o){function r(){u(function(n){return Object.assign({},n,{data:i})})}var i=null,s=function(n){if(n){var r=e.parse(n),o=t.parse(r.type);if("json"===o.subtype)return!0;if("json"===o.suffix)return!0;if(o.suffix&&/\bjson\b/i.test(o.suffix))return!0;if(o.subtype&&/\bjson\b/i.test(o.subtype))return!0}return!1}(o)?Promise.resolve(n.json()).then(function(n){i=n}):Promise.resolve(n.text()).then(function(n){i=n});return s&&s.then?s.then(r):r()}}();return i&&i.then?i.then(r):r()})}catch(n){return o(n)}return s&&s.then?s.then(void 0,o):s}(0,function(n){var t="AbortError"!==n.name?n:null;u(function(n){return Object.assign({},n,{error:t,loading:n.loading-1})})}))}catch(n){return Promise.reject(n)}}(r,o,n.signal,function(n){l.current&&s(n)})),function(){return n.abort()}},[o,r]),{data:i.data,loading:!!i.loading,error:i.error,abort:function(){return i.controller&&i.controller.abort()}}}});
//# sourceMappingURL=index.umd.js.map

@@ -5,3 +5,2 @@ import { Dispatch, SetStateAction } from 'react';

import isJSON from './isJSON';
import { CustomConsole } from '@jest/console';

@@ -8,0 +7,0 @@ const fetchData = async <T>(

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

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