Allow undefined (optional) callbacks for Socket.connect and Socket.write

This commit is contained in:
m000z0rz 2020-06-17 18:41:49 -05:00
parent 892c175868
commit 0e9f6f183b
1 changed files with 10 additions and 1 deletions

View File

@ -51,6 +51,7 @@ const _gprNames = [
// to them in Javascript so they don't get garbage collected before native code uses them.
const _strongBackingReferences = (function() {
const _references = [];
const noop = function () { };
return {
"add": function _strongBackingReferences_add(obj)
@ -67,6 +68,11 @@ const _strongBackingReferences = (function() {
},
"singleUseCallback": function _strongBackingReferences_singleUseCallback(callback)
{
if (callback === undefined)
{
return noop;
}
const singleUseCallback = function ()
{
callback.apply(undefined, arguments);
@ -896,7 +902,10 @@ function Socket(fd)
var _onconnect_base = function(){
connected = 1;
_onconnect();
if (_onconnect !== undefined)
{
_onconnect();
}
}
var _bufferSize = 2048