Skip to content

Instantly share code, notes, and snippets.

View wizardwerdna's full-sized avatar

Andrew Greenberg wizardwerdna

View GitHub Profile
@wizardwerdna
wizardwerdna / gist:5328792
Last active December 15, 2015 21:49
A plugin substitute for nextTick that avoids the "recursive nextTick" bug. After enqueue = require('./enqueue').enqueue, simply replace every call to nextTick in your program that might begin a recursive call, and replace "process.nextTick" with enqueue.
root = (exports ? this)
nextTick = process.nextTick
root.enqueue = do(queue=undefined)->
trampoline = ->
while next = queue.shift()
next()
queue = undefined
(f) ->