UNPKG

t-comm

Version:

专业、稳定、纯粹的工具库

30 lines (26 loc) 660 B
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); /** * 延迟执行函数,等待下一个渲染帧 * 使用 setTimeout 延迟 33ms(约一帧的时间),返回 Promise * @returns {Promise<number>} - 返回 Promise,resolve 值为 1 * @example * ```ts * // 等待下一帧执行 * await nextTick(); * console.log('下一帧执行'); * * // 或使用 then * nextTick().then(() => { * console.log('下一帧执行'); * }); * ``` */ var nextTick = function nextTick() { return new Promise(function (resolve) { setTimeout(function () { resolve(1); }, 33); }); }; exports.nextTick = nextTick;