Simple implementation of progressive timeout in JavaScript.
via NPM
npm install progressive-timeout --save
Define new instance of ProgressiveTimeout with providing calback function as first parametr and options object as second parametr. Options object should contain MIN, MAX and STEP properties. When the next tick reaches the MAX value, it becomes MAX.
import ProgressiveTimeout from 'progressive-timeout';
const OPTIONS = {
min: 500,
max: 20000,
step: 2000,
};
progressiveTimeout = new ProgressiveTimeout(callback, OPTIONS);
start()
progressiveTimeout.start(); // now timeout tick increase every 'step' ms
stop()
progressiveTimeout.stop(); // stop and clear timeout
- Yuriy Markov - Initial work - froziq
This project is licensed under the MIT license, Copyright (c) 2018 Yuriy. For more information see LICENSE
.