var WebSocketServer = new require('ws');
var EventEmitter = require('events');
function MyEmitter() {}
MyEmitter.prototype = Object.create(EventEmitter.prototype);
var clients = {};
var webSocketServer = new WebSocketServer.Server({
port: 3001
}, function() {console.log('WebSocketServer-PORT: 3001')});
webSocketServer.on('connection', function(ws) {
var id = Math.random();
clients[id] = ws;
console.log("connect " + id);
ws.on('close', function() {
console.log('disconnect ' + id);
delete clients[id];
console.log(Object.keys(clients));
});
});
var myEmitter = new MyEmitter();
myEmitter.on('start', () => {
setInterval(function() {
for (var key in clients) {
clients[key].send('Hello, World!!!');
}
}, 3000);
});
myEmitter.emit('start');
var arrArrov = [[Date.UTC(2013,5,2),0.1],[Date.UTC(2013,5,3),0.2],[Date.UTC(2013,5,4),0.8]];
var json = JSON.stringify(arrArrov);
arrArrov[1][0] // => Date.UTC(2013,5,3)
function Foo(a, b, c) {...}
var f = new Foo(1, 2, 3);
class Foo {
constructor(a, b, c) {
...
}
}
Foo.showHimself = function(arguments) { ... }
var array = [
[1, 2, 3, 6, 0, 8, 5, 4, 7, 9],
[2, 1, 8, 6, 5, 9, 7, 0, 4, 3],
[7, 6, 1, 5, 8, 4, 2, 9, 3, 0],
[2, 6, 5, 7, 4, 0, 8, 1, 3, 9],
[0, 8, 6, 2, 7, 9, 4, 5, 3, 1],
[5, 7, 8, 0, 6, 9, 2, 4, 3, 1],
[0, 6, 5, 3, 8, 7, 1, 2, 9, 4],
[9, 7, 8, 6, 3, 0, 1, 5, 2, 4],
[1, 0, 5, 9, 2, 7, 3, 6, 4, 8],
[6, 2, 9, 4, 1, 0, 8, 5, 3, 7]
];
ipsEncodeString(array);
function ipsEncodeString(array) {
array.forEach(function(arr) {
var res = '';
for(var i=0; i<arr.length; i++) {
if(arr[i] < 0 || arr[i] > 9) {
arr.splice(arr[i], 1);
} else {
res += arr[i];
}
}
console.log(res);
});
}
return res.json({ token: jwt.sign({id: user.id}, secret) });
res.json({ token: jwt.sign({id: user.id}, secret) });
return;
if(document.documentElement.clientWidth <= 992) {
document.getElementById('video').children[0].src = '';
document.getElementById('video').children[1].src = '';
} else {
document.getElementById('video').children[0].src = 'video/h264.mp4';
document.getElementById('video').children[0].src = 'video/book.webm';
}
var scrpt = document.createElement('script');
scrpt.src = '.../...';
document.body.appendChild(scrpt);