docs: update to the use of arrow functions in line with the style guide (#30194)

* docs: Update to the use of arrow functions in line with the style guide

* docs: Fixed unmatched bracket typo in previous commit 9ebe3e58f7948c6636d77f3c58a2693683b69691

* fix linting

Co-authored-by: Cheng Zhao <zcbenz@gmail.com>
This commit is contained in:
Matthew Shen 2021-08-01 21:57:37 -04:00 committed by GitHub
parent ced2e8779f
commit c0e72bd335
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 33 additions and 33 deletions

View file

@ -84,11 +84,15 @@ class TestDriver {
In the app, you'd need to write a simple handler for the RPC calls:
```js
if (process.env.APP_TEST_DRIVER) {
process.on('message', onMessage)
const METHODS = {
isReady () {
// do any setup needed
return true
}
// define your RPC-able methods here
}
async function onMessage ({ msgId, cmd, args }) {
const onMessage = async ({ msgId, cmd, args }) => {
let method = METHODS[cmd]
if (!method) method = () => new Error('Invalid method: ' + cmd)
try {
@ -104,12 +108,8 @@ async function onMessage ({ msgId, cmd, args }) {
}
}
const METHODS = {
isReady () {
// do any setup needed
return true
}
// define your RPC-able methods here
if (process.env.APP_TEST_DRIVER) {
process.on('message', onMessage)
}
```