Skip to content

Commit

Permalink
Various doc tweaks (2-spaces vs tabs, EOL-whitespace, repl prompt, "w…
Browse files Browse the repository at this point in the history
…orld" vs "World", etc...)
  • Loading branch information
silas authored and ry committed Nov 21, 2010
1 parent c11f3f8 commit 11b2ee7
Show file tree
Hide file tree
Showing 15 changed files with 98 additions and 98 deletions.
4 changes: 2 additions & 2 deletions doc/api/addons.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ To get started we create a file `hello.cc`:
using namespace v8;

extern "C" void
init (Handle<Object> target)
init (Handle<Object> target)
{
HandleScope scope;
target->Set(String::New("hello"), String::New("World"));
target->Set(String::New("hello"), String::New("world"));
}

This source code needs to be built into `hello.node`, the binary Addon. To
Expand Down
8 changes: 4 additions & 4 deletions doc/api/assert.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Tests if value is a `true` value, it is equivalent to `assert.equal(true, value,

### assert.equal(actual, expected, [message])

Tests shallow, coercive equality with the equal comparison operator ( `==` ).
Tests shallow, coercive equality with the equal comparison operator ( `==` ).

### assert.notEqual(actual, expected, [message])

Expand All @@ -25,15 +25,15 @@ Tests for deep equality.

### assert.notDeepEqual(actual, expected, [message])

Tests for any deep inequality.
Tests for any deep inequality.

### assert.strictEqual(actual, expected, [message])

Tests strict equality, as determined by the strict equality operator ( `===` )
Tests strict equality, as determined by the strict equality operator ( `===` )

### assert.notStrictEqual(actual, expected, [message])

Tests strict non-equality, as determined by the strict not equal operator ( `!==` )
Tests strict non-equality, as determined by the strict not equal operator ( `!==` )

### assert.throws(block, [error], [message])

Expand Down
10 changes: 5 additions & 5 deletions doc/api/buffers.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Example: write a utf8 string into a buffer, then print it
console.log(len + " bytes: " + buf.toString('utf8', 0, len));

// 12 bytes: ½ + ¼ = ¾


### buffer.toString(encoding, start=0, end=buffer.length)

Expand Down Expand Up @@ -84,7 +84,7 @@ Example: copy an ASCII string into a buffer, one byte at a time:

### Buffer.byteLength(string, encoding='utf8')

Gives the actual byte length of a string. This is not the same as
Gives the actual byte length of a string. This is not the same as
`String.prototype.length` since that returns the number of *characters* in a
string.

Expand All @@ -101,7 +101,7 @@ Example:
### buffer.length

The size of the buffer in bytes. Note that this is not necessarily the size
of the contents. `length` refers to the amount of memory allocated for the
of the contents. `length` refers to the amount of memory allocated for the
buffer object. It does not change when the contents of the buffer are changed.

buf = new Buffer(1234);
Expand All @@ -122,7 +122,7 @@ into `buf2`, starting at the 8th byte in `buf2`.

buf1 = new Buffer(26);
buf2 = new Buffer(26);

for (var i = 0 ; i < 26 ; i++) {
buf1[i] = i + 97; // 97 is ASCII a
buf2[i] = 33; // ASCII !
Expand All @@ -132,7 +132,7 @@ into `buf2`, starting at the 8th byte in `buf2`.
console.log(buf2.toString('ascii', 0, 25));

// !!!!!!!!qrst!!!!!!!!!!!!!


### buffer.slice(start, end=buffer.length)

Expand Down
2 changes: 1 addition & 1 deletion doc/api/child_processes.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ output, and return it all in a callback.
exec = require('child_process').exec,
child;

child = exec('cat *.js bad_file | wc -l',
child = exec('cat *.js bad_file | wc -l',
function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
Expand Down
16 changes: 8 additions & 8 deletions doc/api/dgram.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## dgram

Datagram sockets are available through `require('dgram')`. Datagrams are most commonly
Datagram sockets are available through `require('dgram')`. Datagrams are most commonly
handled as IP/UDP messages, but they can also be used over Unix domain sockets.

### Event: 'message'
Expand All @@ -27,15 +27,15 @@ on this socket.
### dgram.createSocket(type, [callback])

Creates a datagram socket of the specified types. Valid types are:
`udp4`, `udp6`, and `unix_dgram`.
`udp4`, `udp6`, and `unix_dgram`.

Takes an optional callback which is added as a listener for `message` events.

### dgram.send(buf, offset, length, path, [callback])

For Unix domain datagram sockets, the destination address is a pathname in the filesystem.
An optional callback may be supplied that is invoked after the `sendto` call is completed
by the OS. It is not safe to re-use `buf` until the callback is invoked. Note that
by the OS. It is not safe to re-use `buf` until the callback is invoked. Note that
unless the socket is bound to a pathname with `bind()` there is no way to receive messages
on this socket.

Expand All @@ -55,7 +55,7 @@ Example of sending a message to syslogd on OSX via Unix domain socket `/var/run/
### dgram.send(buf, offset, length, port, address, [callback])

For UDP sockets, the destination port and IP address must be specified. A string
may be supplied for the `address` parameter, and it will be resolved with DNS. An
may be supplied for the `address` parameter, and it will be resolved with DNS. An
optional callback may be specified to detect any DNS errors and when `buf` may be
re-used. Note that DNS lookups will delay the time that a send takes place, at
least until the next tick. The only way to know for sure that a send has taken place
Expand Down Expand Up @@ -143,12 +143,12 @@ Example of a UDP server listening on port 41234:

### dgram.close()

Close the underlying socket and stop listening for data on it. UDP sockets
Close the underlying socket and stop listening for data on it. UDP sockets
automatically listen for messages, even if they did not call `bind()`.

### dgram.address()

Returns an object containing the address information for a socket. For UDP sockets,
Returns an object containing the address information for a socket. For UDP sockets,
this object will contain `address` and `port`. For Unix domain sockets, it will contain
only `address`.

Expand All @@ -160,9 +160,9 @@ may be sent to a local interface's broadcast address.
### dgram.setTTL(ttl)

Sets the `IP_TTL` socket option. TTL stands for "Time to Live," but in this context it
specifies the number of IP hops that a packet is allowed to go through. Each router or
specifies the number of IP hops that a packet is allowed to go through. Each router or
gateway that forwards a packet decrements the TTL. If the TTL is decremented to 0 by a
router, it will not be forwarded. Changing TTL values is typically done for network
router, it will not be forwarded. Changing TTL values is typically done for network
probes or when multicasting.

The argument to `setTTL()` is a number of hops between 1 and 255. The default on most
Expand Down
8 changes: 4 additions & 4 deletions doc/api/dns.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ the error in English.

### dns.resolve4(domain, callback)

The same as `dns.resolve()`, but only for IPv4 queries (`A` records).
`addresses` is an array of IPv4 addresses (e.g.
The same as `dns.resolve()`, but only for IPv4 queries (`A` records).
`addresses` is an array of IPv4 addresses (e.g.
`['74.125.79.104', '74.125.79.105', '74.125.79.106']`).

### dns.resolve6(domain, callback)
Expand All @@ -80,14 +80,14 @@ The same as `dns.resolve()`, but only for text queries (`TXT` records).

The same as `dns.resolve()`, but only for service records (`SRV` records).
`addresses` is an array of the SRV records available for `domain`. Properties
of SRV records are priority, weight, port, and name (e.g.,
of SRV records are priority, weight, port, and name (e.g.,
`[{'priority': 10, {'weight': 5, 'port': 21223, 'name': 'service.example.com'}, ...]`).

### dns.reverse(ip, callback)

Reverse resolves an ip address to an array of domain names.

The callback has arguments `(err, domains)`.
The callback has arguments `(err, domains)`.

If there an an error, `err` will be non-null and an instanceof the Error
object.
Expand Down
40 changes: 20 additions & 20 deletions doc/api/events.markdown
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
## Events

Many objects in Node emit events: a `net.Server` emits an event each time
a peer connects to it, a `fs.readStream` emits an event when the file is
a peer connects to it, a `fs.readStream` emits an event when the file is
opened. All objects which emit events are instances of `events.EventEmitter`.
You can access this module by doing: `require("events");`

Typically, event names are represented by a camel-cased string, however,
Typically, event names are represented by a camel-cased string, however,
there aren't any strict restrictions on that, as any string will be accepted.

Functions can be then be attached to objects, to be executed when an event
Expand All @@ -16,9 +16,9 @@ is emitted. These functions are called _listeners_.

To access the EventEmitter class, `require('events').EventEmitter`.

When an `EventEmitter` instance experiences an error, the typical action is
When an `EventEmitter` instance experiences an error, the typical action is
to emit an `'error'` event. Error events are treated as a special case in node.
If there is no listener for it, then the default action is to print a stack
If there is no listener for it, then the default action is to print a stack
trace and exit the program.

All EventEmitters emit the event `'newListener'` when new listeners are
Expand All @@ -29,31 +29,31 @@ added.

Adds a listener to the end of the listeners array for the specified event.

server.on('connection', function (stream) {
console.log('someone connected!');
});
server.on('connection', function (stream) {
console.log('someone connected!');
});

#### emitter.once(event, listener)

Adds a **one time** listener for the event. The listener is
invoked only the first time the event is fired, after which
it is removed.

server.once('connection', function (stream) {
console.log('Ah, we have our first user!');
});
server.once('connection', function (stream) {
console.log('Ah, we have our first user!');
});

#### emitter.removeListener(event, listener)

Remove a listener from the listener array for the specified event.
**Caution**: changes array indices in the listener array behind the listener.

var callback = function(stream) {
console.log('someone connected!');
};
server.on('connection', callback);
// ...
server.removeListener('connection', callback);
var callback = function(stream) {
console.log('someone connected!');
};
server.on('connection', callback);
// ...
server.removeListener('connection', callback);


#### emitter.removeAllListeners(event)
Expand All @@ -66,10 +66,10 @@ Removes all listeners from the listener array for the specified event.
Returns an array of listeners for the specified event. This array can be
manipulated, e.g. to remove listeners.

server.on('connection', function (stream) {
console.log('someone connected!');
});
console.log(util.inspect(server.listeners('connection')); // [ [Function] ]
server.on('connection', function (stream) {
console.log('someone connected!');
});
console.log(util.inspect(server.listeners('connection')); // [ [Function] ]

#### emitter.emit(event, [arg1], [arg2], [...])

Expand Down
Loading

0 comments on commit 11b2ee7

Please sign in to comment.