From 4a0f216fb4e8471b575c36fc5e516b1d20809eab Mon Sep 17 00:00:00 2001 From: Chakrit Wichian Date: Mon, 22 Jul 2013 14:34:21 +0700 Subject: [PATCH] Use setImmediate where available instead of nextTick. --- lib/jam.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/jam.js b/lib/jam.js index 128bf83..879c028 100644 --- a/lib/jam.js +++ b/lib/jam.js @@ -2,8 +2,12 @@ // lib/jam.js - Main JAM entrypoint module.exports = (function() { - var assert = require('assert') - , tick = process.nextTick; + var assert = require('assert'), tick = null; + + // find out what is our best option for next tick + tick = setImmediate || (process && process.nextTick) || function(func) { + setTimeout(func, 0); + }; // # INTERNAL HELPERS