From 28d9485c25a0ddeb8817525e25d4c7bb1ee5013b Mon Sep 17 00:00:00 2001 From: saadq Date: Thu, 14 Jul 2016 22:41:29 -0700 Subject: [PATCH] doc: fix inconsistencies in code style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds missing semicolons, removes extra white space, and properly indents various code snippets in the documentation. Reviewed-By: Evan Lucas Reviewed-By: targos - Michaƫl Zasso PR-URL: https://github.com/nodejs/node/pull/7745 --- doc/api/assert.md | 4 ++-- doc/api/buffer.md | 2 +- doc/api/crypto.md | 2 +- doc/api/fs.md | 4 ++-- doc/api/http.md | 6 +++--- doc/api/https.md | 4 ++-- doc/api/path.md | 2 +- doc/api/readline.md | 6 +++--- doc/api/repl.md | 2 +- doc/api/stream.md | 8 ++++---- doc/api/util.md | 8 ++++---- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/doc/api/assert.md b/doc/api/assert.md index e54e81d22e..bc5c0b833a 100644 --- a/doc/api/assert.md +++ b/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 ``` diff --git a/doc/api/buffer.md b/doc/api/buffer.md index b332de1ab2..bd982dfaba 100644 --- a/doc/api/buffer.md +++ b/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 diff --git a/doc/api/crypto.md b/doc/api/crypto.md index bf5ace765b..1c4e825d4e 100644 --- a/doc/api/crypto.md +++ b/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); diff --git a/doc/api/fs.md b/doc/api/fs.md index 4c9efdd91c..0c84c44b58 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1022,12 +1022,12 @@ will be returned._ // OS X and Linux fs.open('', 'a+', (err, fd) => { // => [Error: EISDIR: illegal operation on a directory, open ] -}) +}); // Windows and FreeBSD fs.open('', 'a+', (err, fd) => { // => null, -}) +}); ``` ## fs.openSync(path, flags[, mode]) diff --git a/doc/api/http.md b/doc/api/http.md index 0079ec7566..606f79f395 100644 --- a/doc/api/http.md +++ b/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) => { diff --git a/doc/api/https.md b/doc/api/https.md index c76f1ef837..620b6b36c7 100644 --- a/doc/api/https.md +++ b/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 diff --git a/doc/api/path.md b/doc/api/path.md index f18ed52730..fd07cd6802 100644 --- a/doc/api/path.md +++ b/doc/api/path.md @@ -234,7 +234,7 @@ path.format({ base : "file.txt", ext : ".txt", name : "file" -}) +}); // returns 'C:\\path\\dir\\file.txt' ``` diff --git a/doc/api/readline.md b/doc/api/readline.md index 3855409083..9025f6fe7d 100644 --- a/doc/api/readline.md +++ b/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]; } ``` diff --git a/doc/api/repl.md b/doc/api/repl.md index f74b40723c..124106e642 100644 --- a/doc/api/repl.md +++ b/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) => { diff --git a/doc/api/stream.md b/doc/api/stream.md index f1d2614e3c..1ccabe6c00 100644 --- a/doc/api/stream.md +++ b/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(); } } } diff --git a/doc/api/util.md b/doc/api/util.md index 856e1f1584..34c6839333 100644 --- a/doc/api/util.md +++ b/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!" ```