Es6ify api docs (#21686)

* docs: es6ify docs -> var -> const / let

* docs: apply arrow functions throughout all of the docs
This commit is contained in:
Jorn 2020-01-13 02:29:46 +01:00 committed by Cheng Zhao
parent 29b7d80eb5
commit aef9ab1bb7
6 changed files with 23 additions and 23 deletions

View file

@ -116,7 +116,7 @@ However, it is recommended to avoid using the `remote` module altogether.
// main
const { ipcMain, webContents } = require('electron')
const getGuestForWebContents = function (webContentsId, contents) {
const getGuestForWebContents = (webContentsId, contents) => {
const guest = webContents.fromId(webContentsId)
if (!guest) {
throw new Error(`Invalid webContentsId: ${webContentsId}`)

View file

@ -519,12 +519,12 @@ A [`Protocol`](protocol.md) object for this session.
const { app, session } = require('electron')
const path = require('path')
app.on('ready', function () {
app.on('ready', () => {
const protocol = session.fromPartition('some-partition').protocol
protocol.registerFileProtocol('atom', function (request, callback) {
var url = request.url.substr(7)
protocol.registerFileProtocol('atom', (request, callback) => {
let url = request.url.substr(7)
callback({ path: path.normalize(`${__dirname}/${url}`) })
}, function (error) {
}, (error) => {
if (error) console.error('Failed to register protocol')
})
})
@ -537,7 +537,7 @@ A [`NetLog`](net-log.md) object for this session.
```javascript
const { app, session } = require('electron')
app.on('ready', async function () {
app.on('ready', async () => {
const netLog = session.fromPartition('some-partition').netLog
netLog.startLogging('/path/to/net-log')
// After some network events

View file

@ -987,7 +987,7 @@ Injects CSS into the current web page and returns a unique key for the inserted
stylesheet.
```js
contents.on('did-finish-load', function () {
contents.on('did-finish-load', () => {
contents.insertCSS('html, body { background-color: #f00; }')
})
```
@ -1002,7 +1002,7 @@ Removes the inserted CSS from the current web page. The stylesheet is identified
by its key, which is returned from `contents.insertCSS(css)`.
```js
contents.on('did-finish-load', async function () {
contents.on('did-finish-load', async () => {
const key = await contents.insertCSS('html, body { background-color: #f00; }')
contents.removeInsertedCSS(key)
})