@@ -251,20 +251,20 @@ Closes the underlying file descriptor. Stream will not emit any more events.
251
251
252
252
A ** writable stream** has the following methods, members, and events.
253
253
254
- ### Event 'drain'
254
+ ### Event: 'drain'
255
255
256
256
` function () { } `
257
257
258
258
Emitted after a ` write() ` method was called that returned ` false ` to
259
259
indicate that it is safe to write again.
260
260
261
- ### Event 'error'
261
+ ### Event: 'error'
262
262
263
263
` function (exception) { } `
264
264
265
265
Emitted on error with the exception ` e ` .
266
266
267
- ### Event 'close'
267
+ ### Event: 'close'
268
268
269
269
` function () { } `
270
270
@@ -400,6 +400,7 @@ Example of listening for `SIGINT`:
400
400
An easy way to send the ` SIGINT ` signal is with ` Control-C ` in most terminal
401
401
programs.
402
402
403
+
403
404
### process.stdout
404
405
405
406
A writable stream to ` stdout ` .
@@ -508,13 +509,6 @@ Returns the current working directory of the process.
508
509
509
510
An object containing the user environment. See environ(7).
510
511
511
- // print process.env
512
- var sys = require('sys');
513
-
514
- Object.getOwnPropertyNames(process.env).forEach(function (val, index, array) {
515
- sys.puts(index + ': ' + val + '=' + process.env[val]);
516
- });
517
-
518
512
519
513
520
514
### process.evalcx(code, sandbox, filename)
@@ -741,65 +735,21 @@ Example of inspecting all properties of the `sys` object:
741
735
To schedule execution of ` callback ` after ` delay ` milliseconds. Returns a
742
736
` timeoutId ` for possible use with ` clearTimeout() ` .
743
737
744
- var sys = require('sys'),
745
- start = new Date(),
746
- timer = setTimeout(function () {
747
- sys.puts('Timer fired after ' + (Date.now() - start) + 'ms');
748
- }, 1000);
749
-
750
- sys.puts('Started timer.');
751
-
752
- Optionally, you can pass arguments to the callback.
753
-
754
- var sys = require('sys'),
755
- start = new Date(),
756
- timer = setTimeout(function (start_time, message) {
757
- sys.puts(message + (Date.now() - start_time) + 'ms');
758
- }, 1000, start, 'Timer fired after ');
759
-
760
- sys.puts('Started timer.');
761
-
762
- These two examples generate the same output.
763
-
764
738
### clearTimeout(timeoutId)
765
739
766
740
Prevents a timeout from triggering.
767
741
768
- var sys = require('sys'),
769
- start = new Date(),
770
- timer1 = setTimeout(function () {
771
- sys.puts('Timer fired after ' + (Date.now() - start) + 'ms');
772
- }, 5000),
773
- timer2 = setTimeout(function () {
774
- sys.puts('This is taking too long. Stopping timer1.');
775
- clearTimeout(timer1);
776
- }, 1000);
777
-
778
- sys.puts('Started timers.');
779
-
780
742
### setInterval(callback, delay, [ arg, ...] )
781
743
782
- To schedule the repeated execution of ` callback ` every ` delay ` milliseconds. Returns a ` intervalId ` for possible use with ` clearInterval() ` .
744
+ To schedule the repeated execution of ` callback ` every ` delay ` milliseconds.
745
+ Returns a ` intervalId ` for possible use with ` clearInterval() ` .
783
746
784
747
Optionally, you can also pass arguments to the callback.
785
748
786
749
### clearInterval(intervalId)
787
750
788
751
Stops a interval from triggering.
789
752
790
- var sys = require('sys'),
791
- start = new Date(),
792
- count = 10,
793
- timer = setInterval(function () {
794
- count -= 1;
795
- sys.puts('Timer fired after ' + (Date.now() - start) + 'ms ' + count + ' remaining.');
796
- if (count === 0) {
797
- clearInterval(timer);
798
- }
799
- }, 100);
800
-
801
- sys.puts('Started timer.');
802
-
803
753
804
754
## Child Processes
805
755
@@ -816,7 +766,7 @@ Child processes always have three streams associated with them. `child.stdin`,
816
766
817
767
` ChildProcess ` is an EventEmitter.
818
768
819
- ### Event 'exit'
769
+ ### Event: 'exit'
820
770
821
771
` function (code) {} `
822
772
@@ -1694,9 +1644,9 @@ chunked, this will send the terminating `'0\r\n\r\n'`.
1694
1644
This object is created when making a request with ` http.Client ` . It is
1695
1645
passed to the ` 'response' ` event of the request object.
1696
1646
1697
- The response implements the stream interface.
1647
+ The response implements the ** readable stream** interface.
1698
1648
1699
- ### Event 'data'
1649
+ ### Event: 'data'
1700
1650
1701
1651
` function (chunk) {} `
1702
1652
@@ -1829,24 +1779,25 @@ and passed to the user through the `'connection'` event of a server.
1829
1779
1830
1780
` function () { } `
1831
1781
1832
- Call once the stream is established after a call to ` createConnection() ` or
1833
- ` connect() ` .
1782
+ Emitted when a stream connection successfully is established.
1783
+ See ` connect() ` .
1784
+
1834
1785
1835
1786
### Event: 'data'
1836
1787
1837
1788
` function (data) { } `
1838
1789
1839
- Called when data is received on the stream. ` data `
1840
- will be a string. Encoding of data is set by ` stream.setEncoding() ` .
1790
+ Emitted when data is received. The argument ` data ` will be a ` Buffer ` or
1791
+ ` String ` . Encoding of data is set by ` stream.setEncoding() ` .
1792
+ (See the section on Readable Streams for more infromation.)
1841
1793
1842
1794
### Event: 'end'
1843
1795
1844
1796
` function () { } `
1845
1797
1846
- Called when the other end of the stream sends a FIN
1847
- packet. After this is emitted the ` readyState ` will be
1848
- ` 'writeOnly' ` . One should probably just call
1849
- ` stream.end() ` when this event is emitted.
1798
+ Emitted when the other end of the stream sends a FIN packet. After this is
1799
+ emitted the ` readyState ` will be ` 'writeOnly' ` . One should probably just
1800
+ call ` stream.end() ` when this event is emitted.
1850
1801
1851
1802
### Event: 'timeout'
1852
1803
@@ -1874,7 +1825,7 @@ following this event.
1874
1825
1875
1826
Emitted once the stream is fully closed. The argument ` had_error ` is a boolean which says if
1876
1827
the stream was closed due to a transmission
1877
- error.
1828
+ error.
1878
1829
1879
1830
1880
1831
### net.createConnection(port, host='127.0.0.1')
@@ -1958,7 +1909,7 @@ algorithm, they buffer data before sending it off. Setting `noDelay` will
1958
1909
immediately fire off data each time ` stream.write() ` is called.
1959
1910
1960
1911
1961
- ## DNS module
1912
+ ## DNS
1962
1913
1963
1914
Use ` require('dns') ` to access this module.
1964
1915
@@ -2049,9 +2000,10 @@ Each DNS query can return an error code.
2049
2000
- ` dns.BADQUERY ` : the query is malformed.
2050
2001
2051
2002
2052
- ## Assert Module
2003
+ ## Assert
2053
2004
2054
- This module is used for writing unit tests for your applications, you can access it with ` require('assert') ` .
2005
+ This module is used for writing unit tests for your applications, you can
2006
+ access it with ` require('assert') ` .
2055
2007
2056
2008
### assert.fail(actual, expected, message, operator)
2057
2009
@@ -2094,7 +2046,7 @@ Expects `block` to throw an error.
2094
2046
Expects ` block ` not to throw an error.
2095
2047
2096
2048
2097
- ## Path Module
2049
+ ## Path
2098
2050
2099
2051
This module contains utilities for dealing with file paths. Use
2100
2052
` require('path') ` to use it. It provides the following methods:
@@ -2165,9 +2117,10 @@ Test whether or not the given path exists. Then, call the `callback` argument w
2165
2117
});
2166
2118
2167
2119
2168
- ## URL Module
2120
+ ## URL
2169
2121
2170
2122
This module has utilities for URL resolution and parsing.
2123
+ Call ` require('url') ` to use it.
2171
2124
2172
2125
Parsed URL objects have some or all of the following fields, depending on
2173
2126
whether or not they exist in the URL string. Any parts that are not in the URL
@@ -2177,7 +2130,7 @@ string will not be in the parsed object. Examples are shown for the URL
2177
2130
2178
2131
- ` href `
2179
2132
2180
- The full URL that was originally parsed. Example:
2133
+ The full URL that was originally parsed. Example:
2181
2134
` 'http://user:[email protected] :8080/p/a/t/h?query=string#hash' `
2182
2135
2183
2136
- ` protocol `
@@ -2235,7 +2188,7 @@ Take a parsed URL object, and return a formatted URL string.
2235
2188
Take a base URL, and a href URL, and resolve them as a browser would for an anchor tag.
2236
2189
2237
2190
2238
- ## Query String Module
2191
+ ## Query String
2239
2192
2240
2193
This module provides utilities for dealing with query strings. It provides the following methods:
2241
2194
0 commit comments