Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/robojones/x-time
setTimeout() with native promises
https://github.com/robojones/x-time
javascript nodejs promise settimeout timeout xtime
Last synced: 23 days ago
JSON representation
setTimeout() with native promises
- Host: GitHub
- URL: https://github.com/robojones/x-time
- Owner: robojones
- License: mit
- Created: 2016-12-04T11:15:41.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-16T14:51:52.000Z (almost 7 years ago)
- Last Synced: 2024-09-18T07:24:48.220Z (about 2 months ago)
- Topics: javascript, nodejs, promise, settimeout, timeout, xtime
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/x-time
- Size: 27.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# x-time
setTimeout() with native promises[![Build Status](https://travis-ci.org/robojones/x-time.svg?branch=master)](https://travis-ci.org/robojones/x-time)
[![Test Coverage](https://codeclimate.com/github/robojones/x-time/badges/coverage.svg)](https://codeclimate.com/github/robojones/x-time/coverage)[![bitHound Code](https://www.bithound.io/github/robojones/x-time/badges/code.svg)](https://www.bithound.io/github/robojones/x-time)
[![bitHound Overall Score](https://www.bithound.io/github/robojones/x-time/badges/score.svg)](https://www.bithound.io/github/robojones/x-time)
[![bitHound Dependencies](https://www.bithound.io/github/robojones/x-time/badges/dependencies.svg)](https://www.bithound.io/github/robojones/x-time/master/dependencies/npm)
[![bitHound Dev Dependencies](https://www.bithound.io/github/robojones/x-time/badges/devDependencies.svg)](https://www.bithound.io/github/robojones/x-time/master/dependencies/npm)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)## Installation
```
npm install x-time --save
```## Example
```javascript
const xTime = require('x-time')xTime(1000, 'one').then(value => {
console.log(`waited ${value} second`)
})
```You can also `await` the x-time promise:
```javascript
await xTime(1000)
```## Import in Typescript
The default import syntax of TypeScript does not work with this module because it exports a function directly.
You need to use the following syntax in order to get completions:```typescript
import xTime = require('x-time')
```## Function: xTime(time[, value])
- __time__ `` duration of timeout in ms
- __value__ `` value to resolve the promise withReturns a promise that gets resolved to the __value__ when the __time__ has passed.