mirror of
https://github.com/zebrajr/node.git
synced 2025-12-07 12:20:50 +01:00
22 lines
329 B
JavaScript
22 lines
329 B
JavaScript
module.exports = dezalgo
|
|
|
|
var asap = require('asap')
|
|
|
|
function dezalgo (cb) {
|
|
var sync = true
|
|
asap(function () {
|
|
sync = false
|
|
})
|
|
|
|
return function zalgoSafe() {
|
|
var args = arguments
|
|
var me = this
|
|
if (sync)
|
|
asap(function() {
|
|
cb.apply(me, args)
|
|
})
|
|
else
|
|
cb.apply(me, args)
|
|
}
|
|
}
|