From 11c8bf971e20ea03df31bf1192d00bc1a53af12b Mon Sep 17 00:00:00 2001 From: Rapsssito Date: Tue, 26 Oct 2021 12:59:39 +0200 Subject: [PATCH] feat: Publish Socket timeout property --- README.md | 1 + src/Socket.js | 6 +++++- tsconfig.json | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6e16538..5359fa5 100644 --- a/README.md +++ b/README.md @@ -241,6 +241,7 @@ Here are listed all methods implemented in `react-native-tcp-socket`, their func * [`remotePort`](https://nodejs.org/api/net.html#net_socket_remoteport) * [`localAddress`](https://nodejs.org/api/net.html#net_socket_localaddress) * [`localPort`](https://nodejs.org/api/net.html#net_socket_localport) + * [`timeout`](https://nodejs.org/api/net.html#sockettimeout) * **Events:** * Inherited from [`Stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable): * [`'pause'`](https://nodejs.org/api/stream.html#stream_event_pause) diff --git a/src/Socket.js b/src/Socket.js index 3ea9d43..74ed52a 100644 --- a/src/Socket.js +++ b/src/Socket.js @@ -62,7 +62,7 @@ export default class Socket extends EventEmitter { this._msgEvtEmitter = new EventEmitter(); /** @type {number} @private */ this._timeoutMsecs = 0; - /** @private */ + /** @type {number | undefined} @private */ this._timeout = undefined; /** @type {number} @private */ this._state = STATE.DISCONNECTED; @@ -94,6 +94,10 @@ export default class Socket extends EventEmitter { this._registerEvents(); } + get timeout() { + return this._timeout; + } + /** * @package * @param {number} id diff --git a/tsconfig.json b/tsconfig.json index 03ddc21..9e97fda 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "target": "ES5", "allowJs": true, "lib": ["es2015"], "checkJs": true,