Skip to content

v1.3.0

Choose a tag to compare

@sergeysova sergeysova released this 18 Jul 21:37
· 9 commits to master since this release

Timeout chaining

const timeout = require('timeout.js');

timeout(300, 'data')
.then(data => timeout(100, data))
.then(timeout.make(100)) // simple
.then(data => {
  assert(data === 'data');
})
.catch(error => console.error(error));


// create timeout with predefined time
const out = timeout.make(200);

out().then(() => element.hide());


// with data
const waitFor = timeout.make(500);

waitFor({ user: 123 })
.then(user => request('/user', user))
.then(response => console.log(response.user))
.catch(error => debug(error));

// make timeout with predefined data
const waitData = timeout.make(100, 'data');

waitData()
.then(data => data === 'data');


// override

waitData('foo')
.then(data => data === 'foo');