Skip to content

Commit

Permalink
doc: fix inconsistencies in code style
Browse files Browse the repository at this point in the history
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: #7745
  • Loading branch information
saadq authored and evanlucas committed Jul 20, 2016
1 parent 49a6ea1 commit 1f00359
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const obj3 = {
a : {
b : 1
}
}
};
const obj4 = Object.create(obj1);

assert.deepEqual(obj1, obj1);
Expand Down Expand Up @@ -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
```

Expand Down
2 changes: 1 addition & 1 deletion doc/api/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,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
Expand Down
2 changes: 1 addition & 1 deletion doc/api/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
6 changes: 3 additions & 3 deletions doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions doc/api/https.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -251,7 +251,7 @@ var options = {

var req = https.request(options, (res) => {
...
}
});
```

[`Agent`]: #https_class_https_agent
Expand Down
2 changes: 1 addition & 1 deletion doc/api/path.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ path.format({
base : "file.txt",
ext : ".txt",
name : "file"
})
});
// returns 'C:\\path\\dir\\file.txt'
```

Expand Down
6 changes: 3 additions & 3 deletions doc/api/readline.md
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
```

Expand Down
2 changes: 1 addition & 1 deletion doc/api/repl.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ net.createServer((socket) => {
output: socket
}).on('exit', () => {
socket.end();
})
});
}).listen('/tmp/node-repl-sock');

net.createServer((socket) => {
Expand Down
8 changes: 4 additions & 4 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
});
Expand All @@ -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();
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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!"
```

Expand Down

0 comments on commit 1f00359

Please sign in to comment.