UNPKG

@lancercomet/utils

Version:
23 lines (22 loc) 435 B
/** * 在下一个 Job 内执行函数. * * @export * @param {() => void} callback */ function nextJob(callback) { setTimeout(function () { typeof callback === 'function' && callback(); }, 1); } /** * 模拟线程阻塞. * * @param {number} time */ function sleep(time) { return new Promise(function (resolve) { setTimeout(resolve, time); }); } export { nextJob, sleep };