import { isFunction } from '@vue/shared' ; let queue = [ ] ; const tickPromise = Promise . resolve ( ) ; private export function clear ( ) { queue = [ ] ; } param fn returns private export function has ( fn ) { return queue . includes ( fn ) ; } returns private export function size ( ) { return queue . length ; } private export function flush ( ) { for ( let i = 0 ; i < queue . length ; i ++ ) { queue [ i ] ( ) ; } clear ( ) ; } param fn export function nextTick ( fn ? ) { if ( fn != null && ! isFunction ( fn ) ) { throw new TypeError ( `nextTick expected a function or undefined, got ${ typeof fn }` ) ; } return fn ? tickPromise . then ( fn ) : tickPromise ; } param fn private export function push ( fn ) { if ( ! isFunction ( fn ) ) { throw new TypeError ( `Queue push expected a function, got ${ typeof fn }` ) ; } queue . length || nextTick ( flush ) ; has ( fn ) || queue . push ( fn ) ; }