atomic
makes a function atomic with timeout and abort signal
🔧 Install
· 🧩 Example
· 📜 API docs
· 🔥 Releases
· 💪🏼 Contribute
· 🖐️ Help
Install
$ npm i atomic
API
Table of Contents
atomic
src/index.ts:33-78
Makes a function atomic.
const fn = atomic(signal => async () => {
if (signal.aborted) return
}, 500)
fn()
fn()
fn()
await fn()
Parameters
signalClosure
function (signal: AbortSignal): function (...args: Array<any>): Promise<any> A function that receives the signal object
from an AbortController and returns the function to become atomic.maxTimeMs
number? Time in milliseconds to timeout the operation. Will also signal abort.
Returns any An atomic function
Contribute
Fork or
edit and submit a PR.
All contributions are welcome!
License
MIT © 2022
stagas