Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
SCSocket.prototype._emit = function (event, data, callback) {
var self = this;
if (this.state == this.CLOSED) {
this.connect();
}
var eventObject = {
event: event,
data: data,
callback: callback
};
var eventNode = new LinkedList.Item();
eventNode.data = eventObject;
// Events which do not have a callback will be treated as volatile
if (callback) {
eventObject.timeout = setTimeout(function () {
self._handleEventAckTimeout(eventObject, eventNode);
}, this.ackTimeout);
}
this._emitBuffer.append(eventNode);
if (this.state == this.OPEN) {
this._flushEmitBuffer();
}
};
SCClientSocket.prototype._emit = function (event, data, callback) {
var self = this;
if (this.state === this.CLOSED) {
this.connect();
}
var eventObject = {
event: event,
callback: callback
};
var eventNode = new LinkedList.Item();
if (this.options.cloneData) {
eventObject.data = clone(data);
} else {
eventObject.data = data;
}
eventNode.data = eventObject;
eventObject.timeout = setTimeout(function () {
self._handleEventAckTimeout(eventObject, eventNode);
}, this.ackTimeout);
this._emitBuffer.append(eventNode);
if (this.state === this.OPEN) {
this._flushEmitBuffer();
}
function set (key, value) {
let entry = dict.get(key)
if (exists(entry)) {
entry.value = value
list.append(entry)
} else {
entry = Object.assign(new LinkedList.Item(), { key, value })
dict.set(key, entry)
!size ? dict.delete(list.head.detach().key) : --size
list.append(entry)
}
return value
}
SCSocket.prototype._emit = function (event, data, callback) {
var self = this;
if (this.state == this.CLOSED) {
this.connect();
}
var eventObject = {
event: event,
data: data,
callback: callback
};
var eventNode = new LinkedList.Item();
eventNode.data = eventObject;
eventObject.timeout = setTimeout(function () {
self._handleEventAckTimeout(eventObject, eventNode);
}, this.ackTimeout);
this._emitBuffer.append(eventNode);
if (this.state == this.OPEN) {
this._flushEmitBuffer();
}
};