From 8a14d930a2488fa1df608f72fb31a14f52087d11 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Mon, 21 Mar 2016 11:12:02 -0600 Subject: [PATCH] doc: reference {set,clear}Immediate in Globals setImmediate/clearImmediate are globals, but not mentioned in the Globals documentation section. --- doc/api/globals.markdown | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doc/api/globals.markdown b/doc/api/globals.markdown index 9ee5e48983730a..55a989459bd19c 100644 --- a/doc/api/globals.markdown +++ b/doc/api/globals.markdown @@ -50,6 +50,10 @@ console.log(__filename); `__filename` isn't actually a global but rather local to each module. +## clearImmediate(immediateObject) + +Stops an `immediateObject`, as created by [`setImmediate`][], from triggering. + ## clearInterval(t) Stop a timer that was previously created with [`setInterval()`][]. The callback @@ -162,6 +166,21 @@ left untouched. Use the internal `require()` machinery to look up the location of a module, but rather than loading the module, just return the resolved filename. +## setImmediate(callback[, arg][, ...]) + +To schedule the "immediate" execution of `callback` after I/O events' +callbacks and before timers set by [`setTimeout`][] and [`setInterval`][] are +triggered. Returns an `immediateObject` for possible use with +[`clearImmediate`][]. Additional optional arguments may be passed to the +callback. + +Callbacks for immediates are queued in the order in which they were created. +The entire callback queue is processed every event loop iteration. If an +immediate is queued from inside an executing callback, that immediate won't fire +until the next event loop iteration. + +If `callback` is not a function `setImmediate()` will throw immediately. + ## setInterval(cb, ms) Run callback `cb` repeatedly every `ms` milliseconds. Note that the actual