with-timeout
v0.0.7
Published
Promisified, boilerplate-free setTimeout
Downloads
8
Maintainers
Readme
with-timeout
Promisified, boilerplate-free setTimeout
Install
$ npm install --save with-timeout
Not using Node or a module bundler? Use a UMD build via the <script>
tag.
- https://unpkg.com/with-timeout/dist/with-timeout.js
- https://unpkg.com/with-timeout/dist/with-timeout.min.js
Usage
import withTimeout from 'with-timeout'
const fn = (firstName = 'Agent', lastName = 'Smith') =>
`Hello ${firstName} ${lastName}`
// After 500ms - 'Hello Agent Smith'
withTimeout(fn).then(console.log)
// After 1000ms - 'Hello Keanu Reeves'
withTimeout(fn, 1000, 'Keanu', 'Reeves').then(console.log)