Browse Source

doc: fix inconsistencies in code style

Adds missing semicolons, removes extra white space, and properly indents
various code snippets in the documentation.

Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/7745
v7.x
saadq 8 years ago
committed by Lance Ball
parent
commit
28d9485c25
  1. 4
      doc/api/assert.md
  2. 2
      doc/api/buffer.md
  3. 2
      doc/api/crypto.md
  4. 4
      doc/api/fs.md
  5. 6
      doc/api/http.md
  6. 4
      doc/api/https.md
  7. 2
      doc/api/path.md
  8. 6
      doc/api/readline.md
  9. 2
      doc/api/repl.md
  10. 8
      doc/api/stream.md
  11. 8
      doc/api/util.md

4
doc/api/assert.md

@ -71,7 +71,7 @@ const obj3 = {
a : {
b : 1
}
}
};
const obj4 = Object.create(obj1);
assert.deepEqual(obj1, obj1);
@ -230,7 +230,7 @@ const assert = require('assert');
assert.ifError(0); // OK
assert.ifError(1); // Throws 1
assert.ifError('error') // Throws 'error'
assert.ifError('error'); // Throws 'error'
assert.ifError(new Error()); // Throws Error
```

2
doc/api/buffer.md

@ -256,7 +256,7 @@ Buffers can be iterated over using the ECMAScript 2015 (ES6) `for..of` syntax:
const buf = Buffer.from([1, 2, 3]);
for (var b of buf)
console.log(b)
console.log(b);
// Prints:
// 1

2
doc/api/crypto.md

@ -236,7 +236,7 @@ var decrypted = '';
decipher.on('readable', () => {
var data = decipher.read();
if (data)
decrypted += data.toString('utf8');
decrypted += data.toString('utf8');
});
decipher.on('end', () => {
console.log(decrypted);

4
doc/api/fs.md

@ -1022,12 +1022,12 @@ will be returned._
// OS X and Linux
fs.open('<directory>', 'a+', (err, fd) => {
// => [Error: EISDIR: illegal operation on a directory, open <directory>]
})
});
// Windows and FreeBSD
fs.open('<directory>', 'a+', (err, fd) => {
// => null, <fd>
})
});
```
## fs.openSync(path, flags[, mode])

6
doc/api/http.md

@ -90,7 +90,7 @@ http.get({
agent: false // create a new agent just for this one request
}, (res) => {
// Do stuff with response
})
});
```
### new Agent([options])
@ -1451,8 +1451,8 @@ var req = http.request(options, (res) => {
console.log(`BODY: ${chunk}`);
});
res.on('end', () => {
console.log('No more data in response.')
})
console.log('No more data in response.');
});
});
req.on('error', (e) => {

4
doc/api/https.md

@ -231,7 +231,7 @@ options.agent = new https.Agent(options);
var req = https.request(options, (res) => {
...
}
});
```
Alternatively, opt out of connection pooling by not using an `Agent`.
@ -251,7 +251,7 @@ var options = {
var req = https.request(options, (res) => {
...
}
});
```
[`Agent`]: #https_class_https_agent

2
doc/api/path.md

@ -234,7 +234,7 @@ path.format({
base : "file.txt",
ext : ".txt",
name : "file"
})
});
// returns 'C:\\path\\dir\\file.txt'
```

6
doc/api/readline.md

@ -398,10 +398,10 @@ For instance: `[[substr1, substr2, ...], originalsubstring]`.
```js
function completer(line) {
var completions = '.help .error .exit .quit .q'.split(' ')
var hits = completions.filter((c) => { return c.indexOf(line) == 0 })
var completions = '.help .error .exit .quit .q'.split(' ');
var hits = completions.filter((c) => { return c.indexOf(line) == 0 });
// show all completions if none found
return [hits.length ? hits : completions, line]
return [hits.length ? hits : completions, line];
}
```

2
doc/api/repl.md

@ -494,7 +494,7 @@ net.createServer((socket) => {
output: socket
}).on('exit', () => {
socket.end();
})
});
}).listen('/tmp/node-repl-sock');
net.createServer((socket) => {

8
doc/api/stream.md

@ -1227,9 +1227,9 @@ const Writable = require('stream').Writable;
const myWritable = new Writable({
write(chunk, encoding, callback) {
if (chunk.toString().indexOf('a') >= 0) {
callback(new Error('chunk is invalid'))
callback(new Error('chunk is invalid'));
} else {
callback()
callback();
}
}
});
@ -1252,9 +1252,9 @@ class MyWritable extends Writable {
_write(chunk, encoding, callback) {
if (chunk.toString().indexOf('a') >= 0) {
callback(new Error('chunk is invalid'))
callback(new Error('chunk is invalid'));
} else {
callback()
callback();
}
}
}

8
doc/api/util.md

@ -145,14 +145,14 @@ const util = require('util');
const EventEmitter = require('events');
function MyStream() {
EventEmitter.call(this);
EventEmitter.call(this);
}
util.inherits(MyStream, EventEmitter);
MyStream.prototype.write = function(data) {
this.emit('data', data);
}
this.emit('data', data);
};
const stream = new MyStream();
@ -161,7 +161,7 @@ console.log(MyStream.super_ === EventEmitter); // true
stream.on('data', (data) => {
console.log(`Received data: "${data}"`);
})
});
stream.write('It works!'); // Received data: "It works!"
```

Loading…
Cancel
Save