From 40fedd3620e9febd0469a6f89d09115e56e6e186 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sat, 21 Jul 2018 10:29:39 -0400 Subject: [PATCH] dgram: add getters/setters for private APIs This commit makes all previously private APIs available via getters, setters, and wrapper functions. PR-URL: https://github.com/nodejs/node/pull/21923 Reviewed-By: Anatoli Papirovski Reviewed-By: Wyatt Preul Reviewed-By: Matteo Collina --- lib/dgram.js | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/lib/dgram.js b/lib/dgram.js index a8de95111f8412..292f7daf876c43 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -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 };