You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A wrapper for NodeJS AbortController class that makes interaction easier
Installation
$ npm i timer-abort-controller
This code snippet shows how it works
import{TimerAbortController}from'timer-abort-controller';consttimeToWait=1000;consttimeToResolve=2000;(asyncfunction(){constp=newPromise<string>((res)=>{setTimeout(()=>{res(`promise resolved after ${timeToResolve} milliseconds`);},timeToResolve);});try{constresult=awaitTimerAbortController.resolveInTime<string>(p,timeToWait);console.log(result);}catch(error){console.log(`promise aborted after ${timeToWait} milliseconds`);console.log(error);}})();