Skip to content

Commit

Permalink
dgram: add getters/setters for private APIs
Browse files Browse the repository at this point in the history
This commit makes all previously private APIs available via
getters, setters, and wrapper functions.

PR-URL: #21923
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Wyatt Preul <wpreul@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
cjihrig authored and targos committed Jul 31, 2018
1 parent 98ef8cf commit 40fedd3
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,69 @@ Socket.prototype.getSendBufferSize = function() {
};


// Legacy private APIs to be deprecated in the future.
Object.defineProperty(Socket.prototype, '_handle', {
get() {
return this[kStateSymbol].handle;
},
set(val) {
this[kStateSymbol].handle = val;
}
});


Object.defineProperty(Socket.prototype, '_receiving', {
get() {
return this[kStateSymbol].receiving;
},
set(val) {
this[kStateSymbol].receiving = val;
}
});


Object.defineProperty(Socket.prototype, '_bindState', {
get() {
return this[kStateSymbol].bindState;
},
set(val) {
this[kStateSymbol].bindState = val;
}
});


Object.defineProperty(Socket.prototype, '_queue', {
get() {
return this[kStateSymbol].queue;
},
set(val) {
this[kStateSymbol].queue = val;
}
});


Object.defineProperty(Socket.prototype, '_reuseAddr', {
get() {
return this[kStateSymbol].reuseAddr;
},
set(val) {
this[kStateSymbol].reuseAddr = val;
}
});


Socket.prototype._healthCheck = function() {
healthCheck(this);
};


Socket.prototype._stopReceiving = function() {
stopReceiving(this);
};


module.exports = {
_createSocketHandle,
createSocket,
Socket
};

0 comments on commit 40fedd3

Please sign in to comment.