File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed
Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -2,19 +2,17 @@ import { isFunction } from '.'
22
33/**
44 * @description 延迟 wait 毫秒后调用 func。 调用时,任何附加的参数会传给func。
5- * @param {Function } func 要延迟的函数
6- * @param {number } wait 要延迟的毫秒数
7- * @param {...* } [args] 会在调用时传入到 func 的参数。
8- * @returns {number } 返回计时器 id
95 */
106
11- export function delay (
12- func : ( ...args : any [ ] ) => any ,
13- wait = 0 ,
14- ...args : any [ ]
15- ) : ReturnType < typeof setTimeout > {
7+ export function delay ( func : ( ...args : any [ ] ) => any , wait = 0 , ...args : any [ ] ) {
168 if ( ! isFunction ( func ) ) {
179 throw new TypeError ( 'Expected a function' )
1810 }
1911 return setTimeout ( func , wait , ...args )
2012}
13+
14+ export function later ( delay = 0 ) : Promise < void > {
15+ return new Promise ( ( resolve ) => {
16+ setTimeout ( resolve , delay )
17+ } )
18+ }
You can’t perform that action at this time.
0 commit comments