Giter Site home page Giter Site logo

adamsiekierski / holdmabeer Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 0.0 63 KB

Hold ma BEEER ๐Ÿบ

Home Page: https://npmjs.com/package/holdmabeer

License: MIT License

JavaScript 61.31% TypeScript 38.69%
promise hold wait timeout sleep js node npm

holdmabeer's Introduction

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

import { hold } from 'holdmabeer';

hold(100).then(() => console.log('yummy'));

or

import { hold } from 'holdmabeer';

hold('100ms').then(() => console.log('yummy'));

Promise, that resolves after 1 second

import { hold } from 'holdmabeer';

hold('1s').then(() => console.log('yummy'));

You can also use it inside an asynchronous function

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:

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

Shameless plug

I'm an author of Require Podcast - Polish podcast about webdevelopment! If you're Polish, be sure to check it out!

holdmabeer's People

Contributors

adamsiekierski avatar datejer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.