mirror of https://gitee.com/openkylin/npm.git
23 lines
368 B
JavaScript
23 lines
368 B
JavaScript
var wrappy = require('wrappy')
|
|
module.exports = wrappy(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)
|
|
}
|
|
}
|