@promises/sleep
Sleep is package from Promises library
Use
Module
$ npm install --save @promises/sleep
import {
default as sleep
} from '@promises/sleep';
Browser
<script src="https://unpkg.com/@promises/sleep/bundle.umd.min.js"></script>
let {
sleep
} = P;
Examples
let promise: Promise<string> = Promise.resolve<string>('foo');
sleep(promise, 3000).then((result: string) => {
console.log(result); // result => 'foo'
});
Functional programming
Module
$ npm install --save @promises/sleep
import {
__,
default as sleep
} from '@promises/sleep/fp';
Browser
<script src="https://unpkg.com/@promises/sleep/fp/bundle.umd.min.js"></script>
let {
__,
sleep
} = PF;
Examples
let promise: Promise<string> = Promise.resolve<string>('foo');
sleep(3000, promise).then((result: string) => {
console.log(result); // result => 'foo'
});
Wrapper
Module
$ npm install --save @promises/sleep
import Promises from '@promises/core';
import '@promises/sleep/add';
Or
import Promises from '@promises/sleep/add';
Browser
<script src="https://unpkg.com/@promises/core/bundle.umd.min.js"></script>
<script src="https://unpkg.com/@promises/sleep/add/bundle.umd.min.js"></script>
let {
Promises
} = P;
Examples
let promises: Promises<string> = Promises.resolve<string>('foo');
promises.sleep(3000).then((result: string) => {
console.log(result); // result => 'foo'
});
Compatibility
These modules are written in typescript and available in ES5 and ES6 standard, the requirements are a global Promise (native or polyfill).
License
Copyright © 2017 Yisrael Eliav, Licensed under the MIT license.