Skip to content

Commit dac76f2

Browse files
docs: use ES6 syntax for the code examples
1 parent d5d81a7 commit dac76f2

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

README.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ standalone build you can use as follows:
1919
<script src="/path/to/engine.io.js"></script>
2020
<script>
2121
// eio = Socket
22-
var socket = eio('ws://localhost');
23-
socket.on('open', function(){
24-
socket.on('message', function(data){});
25-
socket.on('close', function(){});
22+
const socket = eio('ws://localhost');
23+
socket.on('open', () => {
24+
socket.on('message', (data) => {});
25+
socket.on('close', () => {});
2626
});
2727
</script>
2828
```
@@ -41,10 +41,10 @@ Engine.IO is a commonjs module, which means you can include it by using
4141
1. write your app code
4242

4343
```js
44-
var socket = require('engine.io-client')('ws://localhost');
45-
socket.on('open', function(){
46-
socket.on('message', function(data){});
47-
socket.on('close', function(){});
44+
const socket = require('engine.io-client')('ws://localhost');
45+
socket.on('open', () => {
46+
socket.on('message', (data) => {});
47+
socket.on('close', () => {});
4848
});
4949
```
5050

@@ -65,12 +65,12 @@ Engine.IO is a commonjs module, which means you can include it by using
6565
```html
6666
<script src="/path/to/engine.io.js"></script>
6767
<script>
68-
var socket = new eio.Socket('ws://localhost/');
68+
const socket = new eio.Socket('ws://localhost/');
6969
socket.binaryType = 'blob';
70-
socket.on('open', function () {
70+
socket.on('open', () => {
7171
socket.send(new Int8Array(5));
72-
socket.on('message', function(blob){});
73-
socket.on('close', function(){ });
72+
socket.on('message', (blob) => {});
73+
socket.on('close', () => {});
7474
});
7575
</script>
7676
```
@@ -80,41 +80,41 @@ Engine.IO is a commonjs module, which means you can include it by using
8080
Add `engine.io-client` to your `package.json` and then:
8181

8282
```js
83-
var socket = require('engine.io-client')('ws://localhost');
84-
socket.on('open', function(){
85-
socket.on('message', function(data){});
86-
socket.on('close', function(){});
83+
const socket = require('engine.io-client')('ws://localhost');
84+
socket.on('open', () => {
85+
socket.on('message', (data) => {});
86+
socket.on('close', () => {});
8787
});
8888
```
8989

9090
### Node.js with certificates
9191
```js
92-
var opts = {
92+
const opts = {
9393
key: fs.readFileSync('test/fixtures/client.key'),
9494
cert: fs.readFileSync('test/fixtures/client.crt'),
9595
ca: fs.readFileSync('test/fixtures/ca.crt')
9696
};
9797
98-
var socket = require('engine.io-client')('ws://localhost', opts);
99-
socket.on('open', function(){
100-
socket.on('message', function(data){});
101-
socket.on('close', function(){});
98+
const socket = require('engine.io-client')('ws://localhost', opts);
99+
socket.on('open', () => {
100+
socket.on('message', (data) => {});
101+
socket.on('close', () => {});
102102
});
103103
```
104104

105105
### Node.js with extraHeaders
106106
```js
107-
var opts = {
107+
const opts = {
108108
extraHeaders: {
109109
'X-Custom-Header-For-My-Project': 'my-secret-access-token',
110110
'Cookie': 'user_session=NI2JlCKF90aE0sJZD9ZzujtdsUqNYSBYxzlTsvdSUe35ZzdtVRGqYFr0kdGxbfc5gUOkR9RGp20GVKza; path=/; expires=Tue, 07-Apr-2015 18:18:08 GMT; secure; HttpOnly'
111111
}
112112
};
113113
114-
var socket = require('engine.io-client')('ws://localhost', opts);
115-
socket.on('open', function(){
116-
socket.on('message', function(data){});
117-
socket.on('close', function(){});
114+
const socket = require('engine.io-client')('ws://localhost', opts);
115+
socket.on('open', () => {
116+
socket.on('message', (data) => {});
117+
socket.on('close', () => {});
118118
});
119119
```
120120

0 commit comments

Comments
 (0)