mirror of
https://github.com/nodejs/node.git
synced 2026-12-05 14:08:45 -05:00
PR-URL: https://github.com/nodejs/node/pull/44162 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Feng Yu <F3n67u@outlook.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
10 lines
402 B
JavaScript
10 lines
402 B
JavaScript
/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
let promise
|
|
|
|
module.exports = typeof queueMicrotask === 'function'
|
|
? queueMicrotask.bind(typeof window !== 'undefined' ? window : global)
|
|
// reuse resolved promise, and allocate it lazily
|
|
: cb => (promise || (promise = Promise.resolve()))
|
|
.then(cb)
|
|
.catch(err => setTimeout(() => { throw err }, 0))
|