This version is old school.
Please find jQuery plugins on npm.
jQuery Postpone - Advanced timeout handling.
Whether you want a prettier way of writing timeouts in JavaScript, or advanced timing events; jQuery.postpone is something for you! In technical terms, it is an API extension for jQuery.Deferred that allows you to use the deferred mechanism in combination with setTimeout and setInterval.