doc: remove extra spaces and concats in examples · nodejs/node@6ea8c66

7 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -423,7 +423,7 @@ const addon = require('./build/Release/addon');

423423
424424

var obj1 = addon('hello');

425425

var obj2 = addon('world');

426-

console.log(obj1.msg + ' ' + obj2.msg); // 'hello world'

426+

console.log(obj1.msg, obj2.msg); // 'hello world'

427427

```

428428
429429
Original file line numberDiff line numberDiff line change

@@ -832,7 +832,7 @@ const spawn = require('child_process').spawn;

832832
833833

let child = spawn('sh', ['-c',

834834

`node -e "setInterval(() => {

835-

console.log(process.pid + 'is alive')

835+

console.log(process.pid, 'is alive')

836836

}, 500);"`

837837

], {

838838

stdio: ['inherit', 'inherit', 'inherit']

Original file line numberDiff line numberDiff line change

@@ -220,7 +220,7 @@ values similar to `printf(3)` (the arguments are all passed to

220220

var count = 5;

221221

console.log('count: %d', count);

222222

// Prints: count: 5, to stdout

223-

console.log('count: ', count);

223+

console.log('count:', count);

224224

// Prints: count: 5, to stdout

225225

```

226226
Original file line numberDiff line numberDiff line change

@@ -107,8 +107,8 @@ Example:

107107

const https = require('https');

108108
109109

https.get('https://encrypted.google.com/', (res) => {

110-

console.log('statusCode: ', res.statusCode);

111-

console.log('headers: ', res.headers);

110+

console.log('statusCode:', res.statusCode);

111+

console.log('headers:', res.headers);

112112
113113

res.on('data', (d) => {

114114

process.stdout.write(d);

@@ -151,8 +151,8 @@ var options = {

151151

};

152152
153153

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

154-

console.log('statusCode: ', res.statusCode);

155-

console.log('headers: ', res.headers);

154+

console.log('statusCode:', res.statusCode);

155+

console.log('headers:', res.headers);

156156
157157

res.on('data', (d) => {

158158

process.stdout.write(d);

Original file line numberDiff line numberDiff line change

@@ -12,7 +12,7 @@ The contents of `foo.js`:

1212
1313

```js

1414

const circle = require('./circle.js');

15-

console.log( `The area of a circle of radius 4 is ${circle.area(4)}`);

15+

console.log(`The area of a circle of radius 4 is ${circle.area(4)}`);

1616

```

1717
1818

The contents of `circle.js`:

Original file line numberDiff line numberDiff line change

@@ -223,8 +223,8 @@ For example:

223223
224224

```js

225225

process.on('unhandledRejection', (reason, p) => {

226-

console.log("Unhandled Rejection at: Promise ", p, " reason: ", reason);

227-

// application specific logging, throwing an error, or other logic here

226+

console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);

227+

// application specific logging, throwing an error, or other logic here

228228

});

229229
230230

somePromise.then((res) => {

Original file line numberDiff line numberDiff line change

@@ -376,12 +376,12 @@ const vm = require('vm');

376376

var localVar = 'initial value';

377377
378378

const vmResult = vm.runInThisContext('localVar = "vm";');

379-

console.log('vmResult: ', vmResult);

380-

console.log('localVar: ', localVar);

379+

console.log('vmResult:', vmResult);

380+

console.log('localVar:', localVar);

381381
382382

const evalResult = eval('localVar = "eval";');

383-

console.log('evalResult: ', evalResult);

384-

console.log('localVar: ', localVar);

383+

console.log('evalResult:', evalResult);

384+

console.log('localVar:', localVar);

385385
386386

// vmResult: 'vm', localVar: 'initial value'

387387

// evalResult: 'eval', localVar: 'eval'