Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: some fixes in events.md #11810

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions doc/api/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ listener will be invoked _every time_ the named event is emitted.

```js
const myEmitter = new MyEmitter();
var m = 0;
let m = 0;
myEmitter.on('event', () => {
console.log(++m);
});
Expand All @@ -114,7 +114,7 @@ the listener is unregistered and *then* called.

```js
const myEmitter = new MyEmitter();
var m = 0;
let m = 0;
myEmitter.once('event', () => {
console.log(++m);
});
Expand Down Expand Up @@ -148,7 +148,7 @@ can be used. (_Note, however, that the `domain` module has been deprecated_)
const myEmitter = new MyEmitter();

process.on('uncaughtException', (err) => {
console.log('whoops! there was an error');
console.error('whoops! there was an error');
});

myEmitter.emit('error', new Error('whoops!'));
Expand All @@ -160,7 +160,7 @@ As a best practice, listeners should always be added for the `'error'` events.
```js
const myEmitter = new MyEmitter();
myEmitter.on('error', (err) => {
console.log('whoops! there was an error');
console.error('whoops! there was an error');
});
myEmitter.emit('error', new Error('whoops!'));
// Prints: whoops! there was an error
Expand Down Expand Up @@ -502,7 +502,7 @@ Removes the specified `listener` from the listener array for the event named
`eventName`.

```js
var callback = (stream) => {
const callback = (stream) => {
console.log('someone connected!');
};
server.on('connection', callback);
Expand All @@ -524,12 +524,12 @@ events will behave as expected.
```js
const myEmitter = new MyEmitter();

var callbackA = () => {
const callbackA = () => {
console.log('A');
myEmitter.removeListener('event', callbackB);
};

var callbackB = () => {
const callbackB = () => {
console.log('B');
};

Expand Down