承诺候补名单 应用的基于承诺的等待列表。 用法 import WaitList from 'promise-waitlist' ; const waitList = new WaitList ( ) ; const entry = waitList . waitFor ( 'event' ) ; setTimeout ( ( ) => { waitList . resolve ( 'event' , value ) ; // returns `true` if promise was resolved } , 1000 ) ; console . log ( await entry ) ; // 42 条目也可以取消: entry . cancel ( /* optional error here */ ) ; 可以通过提供超时参数(以毫秒为单位)来限制等待时间: wait