mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
doc: fix, modernize examples in docs
* Use single quotes consistently * Modernize examples to use template strings and arrow funcs * Fix a few typos * Example edits for consistency PR-URL: https://github.com/nodejs/node/pull/4282 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
1 parent
5ce6e99474
commit
04dd861221
30 files changed
+613
-614
No files matched your search
+24
-24
@@ -32,31 +32,31 @@ automatically added to the `'request'` event.
|
||||
Example:
|
||||
|
||||
// curl -k https://localhost:8000/
|
||||
var https = require('https');
|
||||
var fs = require('fs');
|
||||
const https = require('https');
|
||||
const fs = require('fs');
|
||||
|
||||
var options = {
|
||||
const options = {
|
||||
key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
|
||||
cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
|
||||
};
|
||||
|
||||
https.createServer(options, function (req, res) {
|
||||
https.createServer(options, (req, res) => {
|
||||
res.writeHead(200);
|
||||
res.end("hello world\n");
|
||||
res.end('hello world\n');
|
||||
}).listen(8000);
|
||||
|
||||
Or
|
||||
|
||||
var https = require('https');
|
||||
var fs = require('fs');
|
||||
const https = require('https');
|
||||
const fs = require('fs');
|
||||
|
||||
var options = {
|
||||
const options = {
|
||||
pfx: fs.readFileSync('server.pfx')
|
||||
};
|
||||
|
||||
https.createServer(options, function (req, res) {
|
||||
https.createServer(options, (req, res) => {
|
||||
res.writeHead(200);
|
||||
res.end("hello world\n");
|
||||
res.end('hello world\n');
|
||||
}).listen(8000);
|
||||
|
||||
### server.close([callback])
|
||||
@@ -78,17 +78,17 @@ automatically parsed with [`url.parse()`][].
|
||||
|
||||
Example:
|
||||
|
||||
var https = require('https');
|
||||
const https = require('https');
|
||||
|
||||
https.get('https://encrypted.google.com/', function(res) {
|
||||
console.log("statusCode: ", res.statusCode);
|
||||
console.log("headers: ", res.headers);
|
||||
https.get('https://encrypted.google.com/', (res) => {
|
||||
console.log('statusCode: ', res.statusCode);
|
||||
console.log('headers: ', res.headers);
|
||||
|
||||
res.on('data', function(d) {
|
||||
res.on('data', (d) => {
|
||||
process.stdout.write(d);
|
||||
});
|
||||
|
||||
}).on('error', function(e) {
|
||||
}).on('error', (e) => {
|
||||
console.error(e);
|
||||
});
|
||||
|
||||
@@ -107,7 +107,7 @@ All options from [`http.request()`][] are valid.
|
||||
|
||||
Example:
|
||||
|
||||
var https = require('https');
|
||||
const https = require('https');
|
||||
|
||||
var options = {
|
||||
hostname: 'encrypted.google.com',
|
||||
@@ -116,17 +116,17 @@ Example:
|
||||
method: 'GET'
|
||||
};
|
||||
|
||||
var req = https.request(options, function(res) {
|
||||
console.log("statusCode: ", res.statusCode);
|
||||
console.log("headers: ", res.headers);
|
||||
var req = https.request(options, (res) => {
|
||||
console.log('statusCode: ', res.statusCode);
|
||||
console.log('headers: ', res.headers);
|
||||
|
||||
res.on('data', function(d) {
|
||||
res.on('data', (d) => {
|
||||
process.stdout.write(d);
|
||||
});
|
||||
});
|
||||
req.end();
|
||||
|
||||
req.on('error', function(e) {
|
||||
req.on('error', (e) => {
|
||||
console.error(e);
|
||||
});
|
||||
|
||||
@@ -192,7 +192,7 @@ Example:
|
||||
};
|
||||
options.agent = new https.Agent(options);
|
||||
|
||||
var req = https.request(options, function(res) {
|
||||
var req = https.request(options, (res) => {
|
||||
...
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ Example:
|
||||
agent: false
|
||||
};
|
||||
|
||||
var req = https.request(options, function(res) {
|
||||
var req = https.request(options, (res) => {
|
||||
...
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user