use-abortable-fetch
Advanced tools
Comparing version
{ | ||
"name": "use-abortable-fetch", | ||
"version": "2.6.14", | ||
"version": "3.0.0", | ||
"main": "release/index.js", | ||
@@ -17,27 +17,31 @@ "umd:main": "release/index.umd.js", | ||
"type": "git", | ||
"url": "git@github.com:mauricedb/use-abortable-fetch.git" | ||
"url": "https://github.com/mauricedb/use-abortable-fetch.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/mauricedb/use-abortable-fetch/issues" | ||
}, | ||
"homepage": "https://github.com/mauricedb/use-abortable-fetch#readme", | ||
"author": "Maurice de Beijer <maurice.de.beijer@gmail.com>", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@testing-library/react": "10.4.9", | ||
"@testing-library/react": "11.1.1", | ||
"@types/content-type": "1.1.3", | ||
"@types/jest": "26.0.10", | ||
"@types/jest": "26.0.15", | ||
"@types/media-typer": "1.1.0", | ||
"@types/react": "16.9.48", | ||
"@types/react-dom": "16.9.8", | ||
"@typescript-eslint/eslint-plugin": "3.10.1", | ||
"@typescript-eslint/parser": "3.10.1", | ||
"eslint": "7.7.0", | ||
"eslint-config-prettier": "6.11.0", | ||
"eslint-plugin-react": "7.20.6", | ||
"eslint-plugin-react-hooks": "4.1.0", | ||
"jest": "26.4.2", | ||
"@types/react": "16.9.56", | ||
"@types/react-dom": "16.9.9", | ||
"@typescript-eslint/eslint-plugin": "4.7.0", | ||
"@typescript-eslint/parser": "4.7.0", | ||
"eslint": "7.13.0", | ||
"eslint-config-prettier": "6.15.0", | ||
"eslint-plugin-react": "7.21.5", | ||
"eslint-plugin-react-hooks": "4.2.0", | ||
"jest": "26.6.3", | ||
"jest-fetch-mock": "3.0.3", | ||
"microbundle": "0.12.3", | ||
"microbundle": "0.12.4", | ||
"parcel-bundler": "1.12.4", | ||
"prettier": "2.1.1", | ||
"react": "16.13.1", | ||
"react-dom": "16.13.1", | ||
"ts-jest": "26.3.0" | ||
"prettier": "2.1.2", | ||
"react": "17.0.1", | ||
"react-dom": "17.0.1", | ||
"ts-jest": "26.4.4" | ||
}, | ||
@@ -44,0 +48,0 @@ "peerDependencies": { |
# use-abortable-fetch | ||
[](https://travis-ci.org/mauricedb/use-abortable-fetch) [](https://greenkeeper.io/) | ||
[](https://travis-ci.org/mauricedb/use-abortable-fetch) | ||
@@ -5,0 +5,0 @@ React hook that does a fetch and aborts when the components is unloaded or a new fetch request is started. |
@@ -1,2 +0,2 @@ | ||
function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var r=require("react"),n=t(require("media-typer")),e=t(require("content-type"));"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator"))),module.exports=function(t,o){var u=r.useState({data:null,loading:0,error:null,controller:null}),i=u[0],a=u[1],l=r.useRef(!1);return r.useLayoutEffect(function(){return l.current=!0,function(){l.current=!1}},[]),r.useEffect(function(){var r=new AbortController;return t&&function(t,r,o,u){void 0===r&&(r={});try{var i=Object.assign({},r,{signal:o.signal}),a=null;Promise.resolve(function(r,l){try{var s=(u(function(t){return{data:null,loading:t.loading+1,error:null,controller:o}}),Promise.resolve(fetch(t,i)).then(function(t){function r(){if(!a.ok){var t=new Error(a.statusText);throw t.status=a.status,t}}var o=(a=t).headers.get("content-type"),i=function(){if(o){function t(){u(function(t){return Object.assign({},t,{data:r,loading:t.loading-1})})}var r=null,i=function(t){if(t){var r=e.parse(t),o=n.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(a.json()).then(function(t){r=t}):Promise.resolve(a.text()).then(function(t){r=t});return i&&i.then?i.then(t):t()}u(function(t){return Object.assign({},t,{loading:t.loading-1})})}();return i&&i.then?i.then(r):r()}))}catch(t){return l(t)}return s&&s.then?s.then(void 0,l):s}(0,function(t){var r="AbortError"!==t.name?t:null;u(function(t){return Object.assign({},t,{error:r,loading:a?t.loading:t.loading-1})})}))}catch(t){return Promise.reject(t)}}(t,o,r,function(t){l.current&&a(t)}),function(){return r.abort()}},[o,t]),{data:i.data,loading:!!i.loading,error:i.error,abort:function(){return i.controller&&i.controller.abort()}}}; | ||
function r(r){return r&&"object"==typeof r&&"default"in r?r.default:r}var n=require("react"),t=r(require("media-typer")),e=r(require("content-type"));function o(){return(o=Object.assign||function(r){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e])}return r}).apply(this,arguments)}module.exports=function(r,u){var i=n.useState({data:null,loading:0,error:null,controller:null}),a=i[0],l=i[1],f=n.useRef(!1);return n.useLayoutEffect(function(){return f.current=!0,function(){f.current=!1}},[]),n.useEffect(function(){var n=new AbortController;return r&&function(r,n,u,i){void 0===n&&(n={});try{var a=o({},n,{signal:u.signal}),l=null;Promise.resolve(function(n,f){try{var c=(i(function(r){return{data:null,loading:r.loading+1,error:null,controller:u}}),Promise.resolve(fetch(r,a)).then(function(r){function n(){if(!l.ok){var r=new Error(l.statusText);throw r.status=l.status,r}}var u=(l=r).headers.get("content-type"),a=function(){if(u){var r=function(){i(function(r){return o({},r,{data:n,loading:r.loading-1})})},n=null,a=function(r){if(r){var n=e.parse(r),o=t.parse(n.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}(u)?Promise.resolve(l.json()).then(function(r){n=r}):Promise.resolve(l.text()).then(function(r){n=r});return a&&a.then?a.then(r):r()}i(function(r){return o({},r,{loading:r.loading-1})})}();return a&&a.then?a.then(n):n()}))}catch(r){return f(r)}return c&&c.then?c.then(void 0,f):c}(0,function(r){var n="AbortError"!==r.name?r:null;i(function(r){return o({},r,{error:n,loading:l?r.loading:r.loading-1})})}))}catch(r){return Promise.reject(r)}}(r,u,n,function(r){f.current&&l(r)}),function(){return n.abort()}},[u,r]),{data:a.data,loading:!!a.loading,error:a.error,abort:function(){return a.controller&&a.controller.abort()}}}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("react"),require("media-typer"),require("content-type")):"function"==typeof define&&define.amd?define(["react","media-typer","content-type"],e):t.useAbortableFetch=e(t.react,t.mediaTyper,t.contentType)}(this,function(t,e,n){return e=e&&e.hasOwnProperty("default")?e.default:e,n=n&&n.hasOwnProperty("default")?n.default:n,"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator"))),function(r,o){var u=t.useState({data:null,loading:0,error:null,controller:null}),i=u[0],a=u[1],l=t.useRef(!1);return t.useLayoutEffect(function(){return l.current=!0,function(){l.current=!1}},[]),t.useEffect(function(){var t=new AbortController;return r&&function(t,r,o,u){void 0===r&&(r={});try{var i=Object.assign({},r,{signal:o.signal}),a=null;Promise.resolve(function(r,l){try{var f=(u(function(t){return{data:null,loading:t.loading+1,error:null,controller:o}}),Promise.resolve(fetch(t,i)).then(function(t){function r(){if(!a.ok){var t=new Error(a.statusText);throw t.status=a.status,t}}var o=(a=t).headers.get("content-type"),i=function(){if(o){function t(){u(function(t){return Object.assign({},t,{data:r,loading:t.loading-1})})}var r=null,i=function(t){if(t){var r=n.parse(t),o=e.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(a.json()).then(function(t){r=t}):Promise.resolve(a.text()).then(function(t){r=t});return i&&i.then?i.then(t):t()}u(function(t){return Object.assign({},t,{loading:t.loading-1})})}();return i&&i.then?i.then(r):r()}))}catch(t){return l(t)}return f&&f.then?f.then(void 0,l):f}(0,function(t){var e="AbortError"!==t.name?t:null;u(function(t){return Object.assign({},t,{error:e,loading:a?t.loading:t.loading-1})})}))}catch(t){return Promise.reject(t)}}(r,o,t,function(t){l.current&&a(t)}),function(){return t.abort()}},[o,r]),{data:i.data,loading:!!i.loading,error:i.error,abort:function(){return i.controller&&i.controller.abort()}}}}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("react"),require("media-typer"),require("content-type")):"function"==typeof define&&define.amd?define(["react","media-typer","content-type"],e):(t=t||self).useAbortableFetch=e(t.react,t.mediaTyper,t.contentType)}(this,function(t,e,n){function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}return e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e,n=n&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n,function(o,u){var i=t.useState({data:null,loading:0,error:null,controller:null}),a=i[0],l=i[1],f=t.useRef(!1);return t.useLayoutEffect(function(){return f.current=!0,function(){f.current=!1}},[]),t.useEffect(function(){var t=new AbortController;return o&&function(t,o,u,i){void 0===o&&(o={});try{var a=r({},o,{signal:u.signal}),l=null;Promise.resolve(function(o,f){try{var c=(i(function(t){return{data:null,loading:t.loading+1,error:null,controller:u}}),Promise.resolve(fetch(t,a)).then(function(t){function o(){if(!l.ok){var t=new Error(l.statusText);throw t.status=l.status,t}}var u=(l=t).headers.get("content-type"),a=function(){if(u){var t=function(){i(function(t){return r({},t,{data:o,loading:t.loading-1})})},o=null,a=function(t){if(t){var r=n.parse(t),o=e.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}(u)?Promise.resolve(l.json()).then(function(t){o=t}):Promise.resolve(l.text()).then(function(t){o=t});return a&&a.then?a.then(t):t()}i(function(t){return r({},t,{loading:t.loading-1})})}();return a&&a.then?a.then(o):o()}))}catch(t){return f(t)}return c&&c.then?c.then(void 0,f):c}(0,function(t){var e="AbortError"!==t.name?t:null;i(function(t){return r({},t,{error:e,loading:l?t.loading:t.loading-1})})}))}catch(t){return Promise.reject(t)}}(o,u,t,function(t){f.current&&l(t)}),function(){return t.abort()}},[u,o]),{data:a.data,loading:!!a.loading,error:a.error,abort:function(){return a.controller&&a.controller.abort()}}}}); | ||
//# sourceMappingURL=index.umd.js.map |
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
34
13.33%395
3.13%0
-100%75988
-28.79%5
25%