Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adamsiekierski/holdmabeer
Hold ma BEEER 🍺
https://github.com/adamsiekierski/holdmabeer
hold js node npm promise sleep timeout wait
Last synced: about 1 month ago
JSON representation
Hold ma BEEER 🍺
- Host: GitHub
- URL: https://github.com/adamsiekierski/holdmabeer
- Owner: AdamSiekierski
- License: mit
- Created: 2020-06-26T14:16:15.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-17T10:58:12.000Z (about 4 years ago)
- Last Synced: 2024-02-07T03:03:14.832Z (11 months ago)
- Topics: hold, js, node, npm, promise, sleep, timeout, wait
- Language: JavaScript
- Homepage: https://npmjs.com/package/holdmabeer
- Size: 61.5 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
Hold ma BEER!
Let your app do something important
`holdmabeer` is a simple package, that lets you create a `Promise`, that resolves after a specific time.
## Installation
```
npm install holdmabeer
```## Usage
`holdmabeer` exports a `hold` function, which accepts either a number or a string. When given a number, returns a `Promise` that resolves after given number of milliseconds. String can be although in two formats - seconds or milliseconds. For example `420ms` or `69s`
## Examples
**Just a simple promise, which resolves after 100 milliseconds**
```js
import { hold } from 'holdmabeer';hold(100).then(() => console.log('yummy'));
```or
```js
import { hold } from 'holdmabeer';hold('100ms').then(() => console.log('yummy'));
```**Promise, that resolves after 1 second**
```js
import { hold } from 'holdmabeer';hold('1s').then(() => console.log('yummy'));
```**You can also use it inside an asynchronous function**
```js
import { hold } from 'holdmabeer';(async () => {
await hold('3s');
console.log('noice');
})();
```Top-level `await` is coming to JavaScript, so in some time it could be used like this:
```js
import { hold } from 'holdmabeer';await hold('3s');
console.log('noice');
```## Contributing
- Do a fork of the repo
- `npm install`
- Apply your changes, be sure to use Prettier for code formatting
- Create a pull request
- Well, it merge time, baby## License
This project is licensed under the MIT License.
## Credits
- [ejer](https://github.com/datejer) - Idea
- [me](https://github.com/AdamSiekierski) - Code## Shameless plug
I'm an author of [Require Podcast](https://require.podcast.gq) - Polish podcast about webdevelopment! If you're Polish, be sure to check it out!