@@ -46,53 +46,35 @@ Unless otherwise noted, functions are all asynchronous and do not block
4646execution.
4747
4848
49- === Helpers
49+ === Global Objects
5050
51- These objects are available to all programs.
51+ +GLOBAL+ ::
52+ The global namespace object.
5253
53- +node.cwd()+::
54- Returns the current working directory of the process.
54+ +process+ ::
55+ The process object. Most stuff lives in here. See the "process object"
56+ section.
5557
56- +node.kill(pid, signal="SIGTERM")+ ::
57- Send a signal to a process. +pid+ is the process id and +signal+ is the
58- signal to send; for example, "SIGINT" or "SIGUSR1". See kill(2) for more
59- information.
58+ +require(path)+ ::
59+ See the modules section.
6060
61- +node.compile(source, scriptOrigin)+::
62- Just like +eval()+ except that you can specify a +scriptOrigin+ for better
63- error reporting.
61+ +require.paths+ ::
62+ The search path for absolute path arguments to +require()+.
6463
6564+__filename+ ::
6665The filename of the script being executed.
6766
6867+__module+ ::
69- A reference to the current module (of type +node .Module+). In particular
70- +__module.exports+ is the same as the +exports+ object. See +src/node .js+ for
68+ A reference to the current module (of type +process .Module+). In particular
69+ +__module.exports+ is the same as the +exports+ object. See +src/process .js+ for
7170more information.
7271
73- +require(path)+ ::
74- See the modules section.
75-
76- +require.paths+ ::
77- The search path for absolute path arguments to +require()+.
7872
79- +node.mixin([deep], target, object1, [objectN])+ ::
80- Extend one object with one or more others, returning the modified object.
81- If no target is specified, the +process+ namespace itself is extended.
82- Keep in mind that the target object will be modified, and will be returned
83- from +node.mixin()+.
84- +
85- If a boolean true is specified as the first argument, Node performs a deep
86- copy, recursively copying any objects it finds. Otherwise, the copy will
87- share structure with the original object(s).
88- +
89- Undefined properties are not copied. However, properties inherited from the
90- object's prototype will be copied over.
9173
9274=== The +process+ Object
9375
9476+process+ is the equivalent of +window+ in browser-side javascript. It is
95- the global scope. +process+ is an instance of +node .EventEmitter+.
77+ the global scope. +process+ is an instance of +process .EventEmitter+.
9678
9779[cols="1,2,10",options="header"]
9880|=========================================================
@@ -111,10 +93,6 @@ the global scope. +process+ is an instance of +node.EventEmitter+.
11193 signal names such as SIGINT, SIGUSR1, etc.
11294|=========================================================
11395
114- +process.exit(code=0)+::
115- Ends the process with the specified code. By default it exits with the
116- success code 0.
117-
11896+process.ARGV+ ::
11997An array containing the command line arguments.
12098
@@ -124,6 +102,35 @@ An object containing the user environment. See environ(7).
124102+process.pid+ ::
125103The PID of the process.
126104
105+ +process.exit(code=0)+::
106+ Ends the process with the specified code. By default it exits with the
107+ success code 0.
108+
109+ +process.cwd()+::
110+ Returns the current working directory of the process.
111+
112+ +process.kill(pid, signal="SIGTERM")+ ::
113+ Send a signal to a process. +pid+ is the process id and +signal+ is the
114+ signal to send; for example, "SIGINT" or "SIGUSR1". See kill(2) for more
115+ information.
116+
117+ +process.compile(source, scriptOrigin)+::
118+ Just like +eval()+ except that you can specify a +scriptOrigin+ for better
119+ error reporting.
120+
121+ +process.mixin([deep], target, object1, [objectN])+ ::
122+ Extend one object with one or more others, returning the modified object.
123+ If no target is specified, the +GLOBAL+ namespace itself is extended.
124+ Keep in mind that the target object will be modified, and will be returned
125+ from +process.mixin()+.
126+ +
127+ If a boolean true is specified as the first argument, Node performs a deep
128+ copy, recursively copying any objects it finds. Otherwise, the copy will
129+ share structure with the original object(s).
130+ +
131+ Undefined properties are not copied. However, properties inherited from the
132+ object's prototype will be copied over.
133+
127134=== System module
128135
129136These function are in +"/sys.js"+. Use +require("/sys.js")+ to access them.
@@ -161,7 +168,7 @@ sys.exec("ls /").addCallback(function (stdout, stderr) {
161168
162169Many objects in Node emit events: a TCP server emits an event each time
163170there is a connection, a child process emits an event when it exits. All
164- objects which emit events are are instances of +node .EventEmitter+.
171+ objects which emit events are are instances of +process .EventEmitter+.
165172
166173Events are represented by a camel-cased string. Here are some examples:
167174+"connection"+, +"receive"+, +"messageBegin"+.
@@ -173,7 +180,7 @@ Some asynchronous file operations return an +EventEmitter+ called a
173180_promise_. A promise emits just a single event when the operation is
174181complete.
175182
176- ==== +node .EventEmitter+
183+ ==== +process .EventEmitter+
177184
178185All EventEmitters emit the event +"newListener"+ when new listeners are
179186added.
@@ -204,9 +211,9 @@ manipulated, e.g. to remove listeners.
204211+emitter.emit(event, arg1, arg2, ...)+ ::
205212Execute each of the listeners in order with the supplied arguments.
206213
207- ==== +node .Promise+
214+ ==== +process .Promise+
208215
209- +node .Promise+ inherits from +node .eventEmitter+. A promise emits one of two
216+ +process .Promise+ inherits from +process .eventEmitter+. A promise emits one of two
210217events: +"success"+ or +"error"+. After emitting its event, it will not
211218emit anymore events.
212219
@@ -228,7 +235,7 @@ Adds a listener for the +"error"+ event. Returns the same promise object.
228235Adds a listener for the +"cancel"+ event. Returns the same promise object.
229236
230237+promise.emitSuccess(arg1, arg2, ...)+ ::
231- If you created the promise (by doing +new node .Promise()+) then call
238+ If you created the promise (by doing +new process .Promise()+) then call
232239+emitSuccess+ to emit the +"success"+ event with the given arguments.
233240+
234241(+promise.emit("success", arg1, arg2, ...)+ should also work, but doesn't at
@@ -292,7 +299,7 @@ program setup, not during busy server activity.
292299
293300=== Standard I/O
294301
295- Standard I/O is handled through a special object +node .stdio+. stdout and
302+ Standard I/O is handled through a special object +process .stdio+. stdout and
296303stdin are fully non-blocking (even when piping to files). stderr is
297304synchronous.
298305
@@ -303,22 +310,22 @@ synchronous.
303310| +"data"+ | +data+ | Made when stdin has received a chunk of data.
304311 Depending on the encoding that stdin was opened
305312 with, +data+ will be a string. This event will
306- only be emited after +node .stdio.open()+ has
313+ only be emited after +process .stdio.open()+ has
307314 been called.
308315| +"close"+ | | Made when stdin has been closed.
309316|=========================================================
310317
311- +node .stdio.open(encoding="utf8")+::
312- Open stdin. The program will not exit until +node .stdio.close()+ has been
318+ +process .stdio.open(encoding="utf8")+::
319+ Open stdin. The program will not exit until +process .stdio.close()+ has been
313320called or the +"close"+ event has been emitted.
314321
315- +node .stdio.write(data)+::
322+ +process .stdio.write(data)+::
316323Write data to stdout.
317324
318- +node .stdio.writeError(data)+::
325+ +process .stdio.writeError(data)+::
319326Write data to stderr. Synchronous.
320327
321- +node .stdio.close()+::
328+ +process .stdio.close()+::
322329Close stdin.
323330
324331
@@ -361,10 +368,10 @@ The module path is relative to the file calling +require()+. That is,
361368+circle.js+ must be in the same directory as +foo.js+ for +require()+ to
362369find it.
363370
364- Use +node .mixin()+ to include modules into the global namespace.
371+ Use +process .mixin()+ to include modules into the global namespace.
365372
366373----------------------------------------
367- node .mixin(process, require("circle.js"), require("/sys.js"));
374+ process .mixin(process, require("circle.js"), require("/sys.js"));
368375puts("The area of a cirlce of radius 4 is " + area(4));
369376----------------------------------------
370377
@@ -418,10 +425,10 @@ Stops a interval from triggering.
418425=== Child Processes
419426
420427Node provides a tridirectional +popen(3)+ facility through the class
421- +node .ChildProcess+. It is possible to stream data through the child's +stdin+,
428+ +process .ChildProcess+. It is possible to stream data through the child's +stdin+,
422429+stdout+, and +stderr+ in a fully non-blocking way.
423430
424- ==== +node .ChildProcess+
431+ ==== +process .ChildProcess+
425432
426433[cols="1,2,10",options="header"]
427434|=========================================================
@@ -444,12 +451,12 @@ Node provides a tridirectional +popen(3)+ facility through the class
444451 +"error"+ callbacks will no longer be made.
445452|=========================================================
446453
447- +node .createChildProcess(command, args=[], env=ENV)+::
454+ +process .createChildProcess(command, args=[], env=ENV)+::
448455Launches a new process with the given +command+, command line arguments, and
449456environmental variables. For example:
450457+
451458----------------------------------------
452- var ls = node .createChildProcess("ls", ["-lh", "/usr"]);
459+ var ls = process .createChildProcess("ls", ["-lh", "/usr"]);
453460ls.addListener("output", function (data) {
454461 puts(data);
455462});
@@ -485,7 +492,7 @@ File I/O is provided by simple wrappers around standard POSIX functions. To
485492use this module do +require("/posix.js")+.
486493
487494All POSIX wrappers have a similar form. They return a promise
488- (+node .Promise+). Example of deleting a file:
495+ (+process .Promise+). Example of deleting a file:
489496
490497------------------------------------------------------------------------------
491498var posix = require("/posix.js"),
@@ -574,7 +581,7 @@ sys.puts("stats: " + JSON.stringify(stats));
574581
575582
576583+posix.open(path, flags, mode)+::
577- See open(2). The constants like +O_CREAT+ are defined at +node .O_CREAT+.
584+ See open(2). The constants like +O_CREAT+ are defined at +process .O_CREAT+.
578585 - on success: +fd+ is given as the parameter.
579586 - on error: no parameters.
580587
0 commit comments