Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/damartripamungkas/node-interval-return
โ A lightweight Node.js module that returns a promise-based interval, simplifying the execution of recurring tasks with flexible and reliable asynchronous control. Ideal for developers looking to manage intervals in a clean and efficient way.
https://github.com/damartripamungkas/node-interval-return
interval-return javascript nodejs set-interval set-interval-return setinterval setinterval-return timer timers
Last synced: 28 days ago
JSON representation
โ A lightweight Node.js module that returns a promise-based interval, simplifying the execution of recurring tasks with flexible and reliable asynchronous control. Ideal for developers looking to manage intervals in a clean and efficient way.
- Host: GitHub
- URL: https://github.com/damartripamungkas/node-interval-return
- Owner: damartripamungkas
- License: mit
- Created: 2023-11-14T02:33:44.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-16T17:59:04.000Z (about 1 month ago)
- Last Synced: 2024-10-18T16:59:13.639Z (about 1 month ago)
- Topics: interval-return, javascript, nodejs, set-interval, set-interval-return, setinterval, setinterval-return, timer, timers
- Language: TypeScript
- Homepage: https://npmjs.com/package/node-interval-return
- Size: 108 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
NODE-INTERVAL-RETURN
### ๐ Description :
This package is designed to run `setInterval` with several features. It includes functionalities such as returning a promise, executing a specific task first, stopping the interval, and automatically stopping the interval in the background if a return is triggered.
### ๐ป Step to install :
```
npm install node-interval-return
```### โ๏ธ Example :
full example see [here](./test)
```javascript
const { recursiveReturn, interval, intervalReturn } = require(`node-interval-return`)// function recursiveReturn
await recursiveReturn((repeat, resolve, reject, state) => {
console.log(`test recursiveReturn(), random: ${Math.random()}`)
if (state.counter == 3) {
return resolve(true)
}repeat(1000)
state.counter += 1
})// function intervalReturn
await intervalReturn(1000, true, (resolve, reject, state) => {
console.log(`test intervalReturn(), random: ${Math.random()}`)
if (state.counter == 3) {
return resolve(true)
}state.counter += 1
})// function interval
const resInterval = interval(1000, true, (stop, state) => {
console.log(`test interval, random: ${Math.random()}`)
if (state.counter == 3) {
return stop()
}state.counter += 1
})
```### ๐งพ Pre-Requisistes :
```
- node.js / bun.js / deno.js
- (optional) typescript
- (optional) commonJS
- (optional) ESM
```### ๐ License :
Licensed see [here](./LICENSE).