// DOM APIs, for completeness if (typeof setTimeout !== 'undefined') exports.setTimeout = function() { return setTimeout.apply(window, arguments); }; if (typeof clearTimeout !== 'undefined') exports.clearTimeout = function() { clearTimeout.apply(window, arguments); }; if (typeof setInterval !== 'undefined') exports.setInterval = function() { return setInterval.apply(window, arguments); }; if (typeof clearInterval !== 'undefined') exports.clearInterval = function() { clearInterval.apply(window, arguments); }; // TODO: Change to more effiecient list approach used in Node.js // For now, we just implement the APIs using the primitives above. exports.enroll = function(item, delay) { item._timeoutID = setTimeout(item._onTimeout, delay); }; exports.unenroll = function(item) { clearTimeout(item._timeoutID); }; exports.active = function(item) { // our naive impl doesn't care (correctness is still preserved) }; exports.setImmediate = require('process/browser.js').nextTick;