You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
consul/ui-v2/app/utils/promisedTimeout.js

15 lines
429 B

export default function(P = Promise, timeout = setTimeout) {
// var interval;
return function(milliseconds, cb = function() {}) {
// clearInterval(interval);
// const cb = typeof _cb !== 'function' ? (i) => { clearInterval(interval);interval = i; } : _cb;
return new P((resolve, reject) => {
cb(
timeout(function() {
resolve(milliseconds);
}, milliseconds)
);
});
};
}