You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
389 B

var LIMIT = process.maxTickDepth / 2 || 1000
, factory = function () {
var count = 0
return function (callback) {
if (count >= LIMIT){
global.setImmediate(callback)
count = 0
} else
process.nextTick(callback)
count++
}
}
module.exports = global.setImmediate ? factory : function () { return process.nextTick }