https://github.com/blinet/awaitif
It's a package that makes await more useful and it's much more useful for ordering the conditions which requires time, so in this package you can use the conditions and if the given condition is true it will go to the next lines
https://github.com/blinet/awaitif
await await-async await-promises conditions if
Last synced: 6 months ago
JSON representation
It's a package that makes await more useful and it's much more useful for ordering the conditions which requires time, so in this package you can use the conditions and if the given condition is true it will go to the next lines
- Host: GitHub
- URL: https://github.com/blinet/awaitif
- Owner: blinet
- License: apache-2.0
- Created: 2022-06-01T02:48:19.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-06-24T02:44:41.000Z (over 3 years ago)
- Last Synced: 2025-04-03T07:16:27.778Z (6 months ago)
- Topics: await, await-async, await-promises, conditions, if
- Language: JavaScript
- Homepage:
- Size: 34.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# New Updates
```
Fix Some Bugs
and remove some unused code
- awif.condition = /*condition*/;```
## About
It's a package that makes await more useful and it's much more useful for ordering the conditions which requires time, so in this package you can use the conditions and if the given condition is true it will go to the next lines
- Speed
- Easy to use
- useful## Installation
```sh-session
npm install awaitif
yarn add awaitif
```## How to use
```js
const awaitif = require("awaitif");
const awif = new awaitif();
```> **Options**
```js
limit: 10000,
/**
* {default: 10000, type: Number}
*/
//limit is the time in milliseconds If time is ended and the process is not executed you will get an error```
> **Method and Properties**
```js
/**
* follow the process
*/
awif.continue();
/**
* This function puts it at the line that you do not want the compiler to cross before the condition is true
* @param {function} callback
*/
awif.finally();
```### Example
```js
const awaitif = require("awaitif");
//This function is just an example, no need to use it
function example() {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve("Hi");
}, 5000);
});
}
//main example
(async () => {
const awif = new awaitif();
example().then((res) => {
if (res === "Hi") {
awif.continue();
}
});
await awif.finally(function (err) {
//If you change the limit to 0,
//the callback will not work because there is no limit The condition must be true in order to continue// if the required limit is exceeded
// and the condition is false, you'll get this error
if (err) {
// If you want to follow the process and continue to the other lines put
// awif.continue();
return console.log(err);
}
});
//do something...
console.log("The condition is true or continue");
})();
```## Links
- [Twiter](https://twitter.com/onlyarth)
- [Github](https://github.com/4i8)## License
- [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0)
# awaitif