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

react-async-hook

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

react-async-hook - npm Package Compare versions

Comparing version 3.3.0 to 3.3.1

1

dist/index.d.ts

@@ -21,2 +21,3 @@ export declare type AsyncState<R> = {

set: (value: AsyncState<R>) => void;
reset: () => void;
execute: (...args: Args) => Promise<R>;

@@ -23,0 +24,0 @@ currentPromise: Promise<R> | null;

@@ -119,2 +119,3 @@ 'use strict';

set: AsyncState.set,
reset: AsyncState.reset,
execute: executeAsyncOperation,

@@ -121,0 +122,0 @@ currentPromise: CurrentPromise.get(),

2

dist/react-async-hook.cjs.production.js

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

"use strict";var e=require("react");const t={loading:!0,result:void 0,error:void 0},r={initialState:()=>t,executeOnMount:!0,executeOnUpdate:!0,setLoading:e=>t,setResult:(e,t)=>({loading:!1,result:e,error:void 0}),setError:(e,t)=>({loading:!1,result:void 0,error:e})},s=(t,s,n)=>{const u=(e=>({...r,...e}))(n),o=(t=>{const[r,s]=e.useState(()=>t.initialState()),n=e.useCallback(()=>s(t.initialState()),[s,t]),u=e.useCallback(()=>s(t.setLoading(r)),[r,s]),o=e.useCallback(e=>s(t.setResult(e,r)),[r,s]),c=e.useCallback(e=>s(t.setError(e,r)),[r,s]);return{value:r,set:s,reset:n,setLoading:u,setResult:o,setError:c}})(u),c=(()=>{const t=e.useRef(!1);return e.useEffect(()=>(t.current=!0,()=>{t.current=!1}),[]),()=>t.current})(),a=(()=>{const t=e.useRef(null);return{set:e=>t.current=e,get:()=>t.current,is:e=>t.current===e}})(),i=e=>c()&&a.is(e),l=(...e)=>{const r=t(...e);if(r instanceof Promise)return a.set(r),o.setLoading(),r.then(e=>{i(r)&&o.setResult(e)},e=>{i(r)&&o.setError(e)}),r;{const e=r;return o.setResult(e),Promise.resolve(e)}},d=!c();return e.useEffect(()=>{d?u.executeOnMount&&l(...s):u.executeOnUpdate&&l(...s)},s),{...o.value,set:o.set,execute:l,currentPromise:a.get()}};function n(e,t,r){return s(e,t,r)}exports.useAsync=n,exports.useAsyncAbortable=((t,r,s)=>{const u=e.useRef();return n(async(...e)=>{u.current&&u.current.abort();const r=new AbortController;u.current=r;try{return await t(r.signal,...e)}finally{u.current===r&&(u.current=void 0)}},r,s)}),exports.useAsyncCallback=(e=>s(e,[],{executeOnMount:!1,executeOnUpdate:!1,initialState:()=>({loading:!1,result:void 0,error:void 0})}));
"use strict";var e=require("react");const t={loading:!0,result:void 0,error:void 0},r={initialState:()=>t,executeOnMount:!0,executeOnUpdate:!0,setLoading:e=>t,setResult:(e,t)=>({loading:!1,result:e,error:void 0}),setError:(e,t)=>({loading:!1,result:void 0,error:e})},s=(t,s,n)=>{const u=(e=>({...r,...e}))(n),o=(t=>{const[r,s]=e.useState(()=>t.initialState()),n=e.useCallback(()=>s(t.initialState()),[s,t]),u=e.useCallback(()=>s(t.setLoading(r)),[r,s]),o=e.useCallback(e=>s(t.setResult(e,r)),[r,s]),c=e.useCallback(e=>s(t.setError(e,r)),[r,s]);return{value:r,set:s,reset:n,setLoading:u,setResult:o,setError:c}})(u),c=(()=>{const t=e.useRef(!1);return e.useEffect(()=>(t.current=!0,()=>{t.current=!1}),[]),()=>t.current})(),a=(()=>{const t=e.useRef(null);return{set:e=>t.current=e,get:()=>t.current,is:e=>t.current===e}})(),i=e=>c()&&a.is(e),l=(...e)=>{const r=t(...e);if(r instanceof Promise)return a.set(r),o.setLoading(),r.then(e=>{i(r)&&o.setResult(e)},e=>{i(r)&&o.setError(e)}),r;{const e=r;return o.setResult(e),Promise.resolve(e)}},d=!c();return e.useEffect(()=>{d?u.executeOnMount&&l(...s):u.executeOnUpdate&&l(...s)},s),{...o.value,set:o.set,reset:o.reset,execute:l,currentPromise:a.get()}};function n(e,t,r){return s(e,t,r)}exports.useAsync=n,exports.useAsyncAbortable=((t,r,s)=>{const u=e.useRef();return n(async(...e)=>{u.current&&u.current.abort();const r=new AbortController;u.current=r;try{return await t(r.signal,...e)}finally{u.current===r&&(u.current=void 0)}},r,s)}),exports.useAsyncCallback=(e=>s(e,[],{executeOnMount:!1,executeOnUpdate:!1,initialState:()=>({loading:!1,result:void 0,error:void 0})}));
//# sourceMappingURL=react-async-hook.cjs.production.js.map

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

import{useRef as e,useEffect as t,useState as r,useCallback as n}from"react";const o={loading:!0,result:void 0,error:void 0},s={initialState:()=>o,executeOnMount:!0,executeOnUpdate:!0,setLoading:e=>o,setResult:(e,t)=>({loading:!1,result:e,error:void 0}),setError:(e,t)=>({loading:!1,result:void 0,error:e})},u=(o,u,i)=>{const c=(e=>({...s,...e}))(i),a=(e=>{const[t,o]=r(()=>e.initialState()),s=n(()=>o(e.initialState()),[o,e]),u=n(()=>o(e.setLoading(t)),[t,o]),i=n(r=>o(e.setResult(r,t)),[t,o]),c=n(r=>o(e.setError(r,t)),[t,o]);return{value:t,set:o,reset:s,setLoading:u,setResult:i,setError:c}})(c),l=(()=>{const r=e(!1);return t(()=>(r.current=!0,()=>{r.current=!1}),[]),()=>r.current})(),d=(()=>{const t=e(null);return{set:e=>t.current=e,get:()=>t.current,is:e=>t.current===e}})(),g=e=>l()&&d.is(e),v=(...e)=>{const t=o(...e);if(t instanceof Promise)return d.set(t),a.setLoading(),t.then(e=>{g(t)&&a.setResult(e)},e=>{g(t)&&a.setError(e)}),t;{const e=t;return a.setResult(e),Promise.resolve(e)}},x=!l();return t(()=>{x?c.executeOnMount&&v(...u):c.executeOnUpdate&&v(...u)},u),{...a.value,set:a.set,execute:v,currentPromise:d.get()}};function i(e,t,r){return u(e,t,r)}const c=(t,r,n)=>{const o=e();return i(async(...e)=>{o.current&&o.current.abort();const r=new AbortController;o.current=r;try{return await t(r.signal,...e)}finally{o.current===r&&(o.current=void 0)}},r,n)},a=e=>u(e,[],{executeOnMount:!1,executeOnUpdate:!1,initialState:()=>({loading:!1,result:void 0,error:void 0})});export{i as useAsync,c as useAsyncAbortable,a as useAsyncCallback};
import{useRef as e,useEffect as t,useState as r,useCallback as n}from"react";const o={loading:!0,result:void 0,error:void 0},s={initialState:()=>o,executeOnMount:!0,executeOnUpdate:!0,setLoading:e=>o,setResult:(e,t)=>({loading:!1,result:e,error:void 0}),setError:(e,t)=>({loading:!1,result:void 0,error:e})},u=(o,u,i)=>{const c=(e=>({...s,...e}))(i),a=(e=>{const[t,o]=r(()=>e.initialState()),s=n(()=>o(e.initialState()),[o,e]),u=n(()=>o(e.setLoading(t)),[t,o]),i=n(r=>o(e.setResult(r,t)),[t,o]),c=n(r=>o(e.setError(r,t)),[t,o]);return{value:t,set:o,reset:s,setLoading:u,setResult:i,setError:c}})(c),l=(()=>{const r=e(!1);return t(()=>(r.current=!0,()=>{r.current=!1}),[]),()=>r.current})(),d=(()=>{const t=e(null);return{set:e=>t.current=e,get:()=>t.current,is:e=>t.current===e}})(),g=e=>l()&&d.is(e),v=(...e)=>{const t=o(...e);if(t instanceof Promise)return d.set(t),a.setLoading(),t.then(e=>{g(t)&&a.setResult(e)},e=>{g(t)&&a.setError(e)}),t;{const e=t;return a.setResult(e),Promise.resolve(e)}},x=!l();return t(()=>{x?c.executeOnMount&&v(...u):c.executeOnUpdate&&v(...u)},u),{...a.value,set:a.set,reset:a.reset,execute:v,currentPromise:d.get()}};function i(e,t,r){return u(e,t,r)}const c=(t,r,n)=>{const o=e();return i(async(...e)=>{o.current&&o.current.abort();const r=new AbortController;o.current=r;try{return await t(r.signal,...e)}finally{o.current===r&&(o.current=void 0)}},r,n)},a=e=>u(e,[],{executeOnMount:!1,executeOnUpdate:!1,initialState:()=>({loading:!1,result:void 0,error:void 0})});export{i as useAsync,c as useAsyncAbortable,a as useAsyncCallback};
//# sourceMappingURL=react-async-hook.es.production.js.map

@@ -121,2 +121,3 @@ (function (global, factory) {

set: AsyncState.set,
reset: AsyncState.reset,
execute: executeAsyncOperation,

@@ -123,0 +124,0 @@ currentPromise: CurrentPromise.get(),

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):(e=e||self,t(e["react-async-hook"]={},e.React))}(this,function(e,t){"use strict";const r={loading:!0,result:void 0,error:void 0},n={initialState:()=>r,executeOnMount:!0,executeOnUpdate:!0,setLoading:e=>r,setResult:(e,t)=>({loading:!1,result:e,error:void 0}),setError:(e,t)=>({loading:!1,result:void 0,error:e})},s=(e,r,s)=>{const u=(e=>({...n,...e}))(s),o=(e=>{const[r,n]=t.useState(()=>e.initialState()),s=t.useCallback(()=>n(e.initialState()),[n,e]),u=t.useCallback(()=>n(e.setLoading(r)),[r,n]),o=t.useCallback(t=>n(e.setResult(t,r)),[r,n]),c=t.useCallback(t=>n(e.setError(t,r)),[r,n]);return{value:r,set:n,reset:s,setLoading:u,setResult:o,setError:c}})(u),c=(()=>{const e=t.useRef(!1);return t.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),()=>e.current})(),i=(()=>{const e=t.useRef(null);return{set:t=>e.current=t,get:()=>e.current,is:t=>e.current===t}})(),a=e=>c()&&i.is(e),l=(...t)=>{const r=e(...t);if(r instanceof Promise)return i.set(r),o.setLoading(),r.then(e=>{a(r)&&o.setResult(e)},e=>{a(r)&&o.setError(e)}),r;{const e=r;return o.setResult(e),Promise.resolve(e)}},d=!c();return t.useEffect(()=>{d?u.executeOnMount&&l(...r):u.executeOnUpdate&&l(...r)},r),{...o.value,set:o.set,execute:l,currentPromise:i.get()}};function u(e,t,r){return s(e,t,r)}e.useAsync=u,e.useAsyncAbortable=((e,r,n)=>{const s=t.useRef();return u(async(...t)=>{s.current&&s.current.abort();const r=new AbortController;s.current=r;try{return await e(r.signal,...t)}finally{s.current===r&&(s.current=void 0)}},r,n)}),e.useAsyncCallback=(e=>s(e,[],{executeOnMount:!1,executeOnUpdate:!1,initialState:()=>({loading:!1,result:void 0,error:void 0})}))});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):(e=e||self,t(e["react-async-hook"]={},e.React))}(this,function(e,t){"use strict";const r={loading:!0,result:void 0,error:void 0},n={initialState:()=>r,executeOnMount:!0,executeOnUpdate:!0,setLoading:e=>r,setResult:(e,t)=>({loading:!1,result:e,error:void 0}),setError:(e,t)=>({loading:!1,result:void 0,error:e})},s=(e,r,s)=>{const u=(e=>({...n,...e}))(s),o=(e=>{const[r,n]=t.useState(()=>e.initialState()),s=t.useCallback(()=>n(e.initialState()),[n,e]),u=t.useCallback(()=>n(e.setLoading(r)),[r,n]),o=t.useCallback(t=>n(e.setResult(t,r)),[r,n]),c=t.useCallback(t=>n(e.setError(t,r)),[r,n]);return{value:r,set:n,reset:s,setLoading:u,setResult:o,setError:c}})(u),c=(()=>{const e=t.useRef(!1);return t.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),()=>e.current})(),i=(()=>{const e=t.useRef(null);return{set:t=>e.current=t,get:()=>e.current,is:t=>e.current===t}})(),a=e=>c()&&i.is(e),l=(...t)=>{const r=e(...t);if(r instanceof Promise)return i.set(r),o.setLoading(),r.then(e=>{a(r)&&o.setResult(e)},e=>{a(r)&&o.setError(e)}),r;{const e=r;return o.setResult(e),Promise.resolve(e)}},d=!c();return t.useEffect(()=>{d?u.executeOnMount&&l(...r):u.executeOnUpdate&&l(...r)},r),{...o.value,set:o.set,reset:o.reset,execute:l,currentPromise:i.get()}};function u(e,t,r){return s(e,t,r)}e.useAsync=u,e.useAsyncAbortable=((e,r,n)=>{const s=t.useRef();return u(async(...t)=>{s.current&&s.current.abort();const r=new AbortController;s.current=r;try{return await e(r.signal,...t)}finally{s.current===r&&(s.current=void 0)}},r,n)}),e.useAsyncCallback=(e=>s(e,[],{executeOnMount:!1,executeOnUpdate:!1,initialState:()=>({loading:!1,result:void 0,error:void 0})}))});
//# sourceMappingURL=react-async-hook.umd.production.js.map
{
"name": "react-async-hook",
"version": "3.3.0",
"version": "3.3.1",
"description": "Async hook",

@@ -5,0 +5,0 @@ "author": "Sébastien Lorber",

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

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