mirror of https://github.com/status-im/consul.git
20 lines
512 B
JavaScript
20 lines
512 B
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
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)
|
|
);
|
|
});
|
|
};
|
|
}
|