From 6cd5312b221d70f422a8397358c3d7942c93818d Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Thu, 1 Jun 2017 02:07:25 +0300 Subject: [PATCH] doc: unify spaces in object literals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/13354 Reviewed-By: Timothy Gu Reviewed-By: Refael Ackermann Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: Gibson Fahnestock Reviewed-By: Colin Ihrig Reviewed-By: Michael Dawson Reviewed-By: Tobias Nießen Reviewed-By: James M Snell --- doc/api/assert.md | 10 +++++----- doc/api/child_process.md | 4 ++-- doc/api/fs.md | 4 ++-- doc/api/http.md | 10 +++++----- doc/api/inspector.md | 4 +++- doc/api/net.md | 4 ++-- doc/api/readline.md | 2 +- doc/api/repl.md | 8 ++++---- doc/guides/writing-tests.md | 2 +- 9 files changed, 25 insertions(+), 23 deletions(-) diff --git a/doc/api/assert.md b/doc/api/assert.md index 3eb95f0ba29cbb..1a040a927bc7f9 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -131,10 +131,10 @@ Generally identical to `assert.deepEqual()` with three exceptions: ```js const assert = require('assert'); -assert.deepEqual({a: 1}, {a: '1'}); +assert.deepEqual({ a: 1 }, { a: '1' }); // OK, because 1 == '1' -assert.deepStrictEqual({a: 1}, {a: '1'}); +assert.deepStrictEqual({ a: 1 }, { a: '1' }); // AssertionError: { a: 1 } deepStrictEqual { a: '1' } // because 1 !== '1' using strict equality @@ -248,7 +248,7 @@ assert.equal(1, '1'); assert.equal(1, 2); // AssertionError: 1 == 2 -assert.equal({a: {b: 1}}, {a: {b: 1}}); +assert.equal({ a: { b: 1 } }, { a: { b: 1 } }); //AssertionError: { a: { b: 1 } } == { a: { b: 1 } } ``` @@ -368,10 +368,10 @@ Tests for deep strict inequality. Opposite of [`assert.deepStrictEqual()`][]. ```js const assert = require('assert'); -assert.notDeepEqual({a: 1}, {a: '1'}); +assert.notDeepEqual({ a: 1 }, { a: '1' }); // AssertionError: { a: 1 } notDeepEqual { a: '1' } -assert.notDeepStrictEqual({a: 1}, {a: '1'}); +assert.notDeepStrictEqual({ a: 1 }, { a: '1' }); // OK ``` diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 3d73f0b859cab5..2120e36f4be32e 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -224,7 +224,7 @@ const util = require('util'); const exec = util.promisify(require('child_process').exec); async function lsExample() { - const {stdout, stderr} = await exec('ls'); + const { stdout, stderr } = await exec('ls'); console.log('stdout:', stdout); console.log('stderr:', stderr); } @@ -287,7 +287,7 @@ a Promise for an object with `stdout` and `stderr` properties. const util = require('util'); const execFile = util.promisify(require('child_process').execFile); async function getVersion() { - const {stdout} = await execFile('node', ['--version']); + const { stdout } = await execFile('node', ['--version']); console.log(stdout); } getVersion(); diff --git a/doc/api/fs.md b/doc/api/fs.md index 9ee328e6523218..8ae521a0d2dd1a 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -228,7 +228,7 @@ support. If `filename` is provided, it will be provided as a `Buffer` if ```js // Example when handled through fs.watch listener -fs.watch('./tmp', {encoding: 'buffer'}, (eventType, filename) => { +fs.watch('./tmp', { encoding: 'buffer' }, (eventType, filename) => { if (filename) console.log(filename); // Prints: @@ -787,7 +787,7 @@ file was created. An example to read the last 10 bytes of a file which is 100 bytes long: ```js -fs.createReadStream('sample.txt', {start: 90, end: 99}); +fs.createReadStream('sample.txt', { start: 90, end: 99 }); ``` If `options` is a string, then it specifies the encoding. diff --git a/doc/api/http.md b/doc/api/http.md index cd66a2063b22f8..2ceeaf6dac04ea 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -312,7 +312,7 @@ const url = require('url'); // Create an HTTP tunneling proxy const proxy = http.createServer((req, res) => { - res.writeHead(200, {'Content-Type': 'text/plain'}); + res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('okay'); }); proxy.on('connect', (req, cltSocket, head) => { @@ -408,7 +408,7 @@ const http = require('http'); // Create an HTTP server const srv = http.createServer((req, res) => { - res.writeHead(200, {'Content-Type': 'text/plain'}); + res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('okay'); }); srv.on('upgrade', (req, socket, head) => { @@ -912,7 +912,7 @@ emit trailers, with a list of the header fields in its value. E.g., response.writeHead(200, { 'Content-Type': 'text/plain', 'Trailer': 'Content-MD5' }); response.write(fileData); -response.addTrailers({'Content-MD5': '7895bf4b8828b55ceaf47747b4bca667'}); +response.addTrailers({ 'Content-MD5': '7895bf4b8828b55ceaf47747b4bca667' }); response.end(); ``` @@ -1103,7 +1103,7 @@ any headers passed to [`response.writeHead()`][], with the headers passed to const server = http.createServer((req, res) => { res.setHeader('Content-Type', 'text/html'); res.setHeader('X-Foo', 'bar'); - res.writeHead(200, {'Content-Type': 'text/plain'}); + res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('ok'); }); ``` @@ -1257,7 +1257,7 @@ any headers passed to [`response.writeHead()`][], with the headers passed to const server = http.createServer((req, res) => { res.setHeader('Content-Type', 'text/html'); res.setHeader('X-Foo', 'bar'); - res.writeHead(200, {'Content-Type': 'text/plain'}); + res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('ok'); }); ``` diff --git a/doc/api/inspector.md b/doc/api/inspector.md index f90b823b78f511..73c735efd3b4b2 100644 --- a/doc/api/inspector.md +++ b/doc/api/inspector.md @@ -58,7 +58,9 @@ event, and prints the reason for program suspension whenever program execution is suspended (through breakpoints, for example): ```js -session.on('Debugger.paused', ({params}) => console.log(params.hitBreakpoints)); +session.on('Debugger.paused', ({ params }) => { + console.log(params.hitBreakpoints); +}); // [ '/node/test/inspector/test-bindings.js:11:0' ] ``` diff --git a/doc/api/net.md b/doc/api/net.md index 982a5a0aeb77a4..fc0ea4cc12dd02 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -884,7 +884,7 @@ in the [`net.createServer()`][] section: ```js const net = require('net'); -const client = net.createConnection({port: 8124}, () => { +const client = net.createConnection({ port: 8124 }, () => { //'connect' listener console.log('connected to server!'); client.write('world!\r\n'); @@ -902,7 +902,7 @@ To connect on the socket `/tmp/echo.sock` the second line would just be changed to ```js -const client = net.createConnection({path: '/tmp/echo.sock'}); +const client = net.createConnection({ path: '/tmp/echo.sock' }); ``` ### net.createConnection(path[, connectListener]) diff --git a/doc/api/readline.md b/doc/api/readline.md index 136d0e63ceb81d..bcd68d8085d82a 100644 --- a/doc/api/readline.md +++ b/doc/api/readline.md @@ -310,7 +310,7 @@ For example: ```js rl.write('Delete this!'); // Simulate Ctrl+u to delete the line written previously -rl.write(null, {ctrl: true, name: 'u'}); +rl.write(null, { ctrl: true, name: 'u' }); ``` *Note*: The `rl.write()` method will write the data to the `readline` diff --git a/doc/api/repl.md b/doc/api/repl.md index 0e456b71ea13c9..9d6bdfb112d6cf 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -180,7 +180,7 @@ function myEval(cmd, context, filename, callback) { callback(null, myTranslator.translate(cmd)); } -repl.start({prompt: '> ', eval: myEval}); +repl.start({ prompt: '> ', eval: myEval }); ``` #### Recoverable Errors @@ -226,7 +226,7 @@ following example, for instance, simply converts any input text to upper case: ```js const repl = require('repl'); -const r = repl.start({prompt: '> ', eval: myEval, writer: myWriter}); +const r = repl.start({ prompt: '> ', eval: myEval, writer: myWriter }); function myEval(cmd, context, filename, callback) { callback(null, cmd); @@ -284,7 +284,7 @@ function initializeContext(context) { context.m = 'test'; } -const r = repl.start({prompt: '> '}); +const r = repl.start({ prompt: '> ' }); initializeContext(r.context); r.on('reset', initializeContext); @@ -331,7 +331,7 @@ The following example shows two new commands added to the REPL instance: ```js const repl = require('repl'); -const replServer = repl.start({prompt: '> '}); +const replServer = repl.start({ prompt: '> ' }); replServer.defineCommand('sayhello', { help: 'Say hello', action(name) { diff --git a/doc/guides/writing-tests.md b/doc/guides/writing-tests.md index 168227872c98ff..688e13a3237d9f 100644 --- a/doc/guides/writing-tests.md +++ b/doc/guides/writing-tests.md @@ -38,7 +38,7 @@ const server = http.createServer(common.mustCall((req, res) => { // 10 server.listen(0, () => { // 13 http.get({ // 14 port: server.address().port, // 15 - headers: {'Test': 'Düsseldorf'} // 16 + headers: { 'Test': 'Düsseldorf' } // 16 }, common.mustCall((res) => { // 17 assert.strictEqual(res.statusCode, 200); // 18 server.close(); // 19