njs-modbus 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +3 -3
- package/dist/src/layers/physical/tcp-client-physical-layer.d.ts +1 -1
- package/dist/src/layers/physical/tcp-server-physical-layer.d.ts +1 -1
- package/dist/src/layers/physical/udp-physical-layer.d.ts +1 -1
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Xie Jay
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -181,7 +181,7 @@ For more advanced examples, check out [examples](/examples) included in the repo
|
|
|
181
181
|
|
|
182
182
|
## Contributing
|
|
183
183
|
|
|
184
|
-
Please read our [contributing guide](/
|
|
184
|
+
Please read our [contributing guide](/CODE_OF_CONDUCT.md) first.
|
|
185
185
|
|
|
186
186
|
## License
|
|
187
187
|
|
package/dist/index.cjs
CHANGED
|
@@ -158,7 +158,7 @@ class TcpClientPhysicalLayer extends AbstractPhysicalLayer {
|
|
|
158
158
|
}
|
|
159
159
|
return new Promise((resolve, reject) => {
|
|
160
160
|
let called = false;
|
|
161
|
-
this._socket.connect(
|
|
161
|
+
this._socket.connect(options !== null && options !== void 0 ? options : { port: 502 }, () => {
|
|
162
162
|
called = true;
|
|
163
163
|
this._isOpen = true;
|
|
164
164
|
this._socket.on('data', (data) => {
|
|
@@ -279,7 +279,7 @@ class TcpServerPhysicalLayer extends AbstractPhysicalLayer {
|
|
|
279
279
|
return new Promise((resolve, reject) => {
|
|
280
280
|
var _a;
|
|
281
281
|
let called = false;
|
|
282
|
-
this._server.listen(Object.assign(Object.assign({}, options), { port: (_a = options.port) !== null && _a !== void 0 ? _a : 502 }), () => {
|
|
282
|
+
this._server.listen(Object.assign(Object.assign({}, options), { port: (_a = options === null || options === void 0 ? void 0 : options.port) !== null && _a !== void 0 ? _a : 502 }), () => {
|
|
283
283
|
called = true;
|
|
284
284
|
this._isOpen = true;
|
|
285
285
|
this._sockets.clear();
|
|
@@ -410,7 +410,7 @@ class UdpPhysicalLayer extends AbstractPhysicalLayer {
|
|
|
410
410
|
var _a;
|
|
411
411
|
if (this.isServer) {
|
|
412
412
|
let called = false;
|
|
413
|
-
this._socket.bind(Object.assign(Object.assign({}, options), { port: (_a = options.port) !== null && _a !== void 0 ? _a : 502 }), () => {
|
|
413
|
+
this._socket.bind(Object.assign(Object.assign({}, options), { port: (_a = options === null || options === void 0 ? void 0 : options.port) !== null && _a !== void 0 ? _a : 502 }), () => {
|
|
414
414
|
called = true;
|
|
415
415
|
this._isOpen = true;
|
|
416
416
|
this._socket.on('close', () => {
|
package/dist/index.d.ts
CHANGED
|
@@ -77,7 +77,7 @@ declare class TcpClientPhysicalLayer extends AbstractPhysicalLayer {
|
|
|
77
77
|
get isOpen(): boolean;
|
|
78
78
|
get destroyed(): boolean;
|
|
79
79
|
constructor(options?: SocketConstructorOpts);
|
|
80
|
-
open(options
|
|
80
|
+
open(options?: SocketConnectOpts): Promise<void>;
|
|
81
81
|
write(data: Buffer): Promise<void>;
|
|
82
82
|
close(): Promise<void>;
|
|
83
83
|
destroy(): Promise<void>;
|
|
@@ -92,7 +92,7 @@ declare class TcpServerPhysicalLayer extends AbstractPhysicalLayer {
|
|
|
92
92
|
get isOpen(): boolean;
|
|
93
93
|
get destroyed(): boolean;
|
|
94
94
|
constructor(options?: NetConnectOpts);
|
|
95
|
-
open(options
|
|
95
|
+
open(options?: ListenOptions): Promise<void>;
|
|
96
96
|
write(data: Buffer): Promise<void>;
|
|
97
97
|
close(): Promise<void>;
|
|
98
98
|
destroy(): Promise<void>;
|
|
@@ -118,7 +118,7 @@ declare class UdpPhysicalLayer extends AbstractPhysicalLayer {
|
|
|
118
118
|
port?: number;
|
|
119
119
|
address?: string;
|
|
120
120
|
});
|
|
121
|
-
open(options
|
|
121
|
+
open(options?: BindOptions): Promise<void>;
|
|
122
122
|
write(data: Buffer): Promise<void>;
|
|
123
123
|
close(): Promise<void>;
|
|
124
124
|
destroy(): Promise<void>;
|
package/dist/index.mjs
CHANGED
|
@@ -156,7 +156,7 @@ class TcpClientPhysicalLayer extends AbstractPhysicalLayer {
|
|
|
156
156
|
}
|
|
157
157
|
return new Promise((resolve, reject) => {
|
|
158
158
|
let called = false;
|
|
159
|
-
this._socket.connect(
|
|
159
|
+
this._socket.connect(options !== null && options !== void 0 ? options : { port: 502 }, () => {
|
|
160
160
|
called = true;
|
|
161
161
|
this._isOpen = true;
|
|
162
162
|
this._socket.on('data', (data) => {
|
|
@@ -277,7 +277,7 @@ class TcpServerPhysicalLayer extends AbstractPhysicalLayer {
|
|
|
277
277
|
return new Promise((resolve, reject) => {
|
|
278
278
|
var _a;
|
|
279
279
|
let called = false;
|
|
280
|
-
this._server.listen(Object.assign(Object.assign({}, options), { port: (_a = options.port) !== null && _a !== void 0 ? _a : 502 }), () => {
|
|
280
|
+
this._server.listen(Object.assign(Object.assign({}, options), { port: (_a = options === null || options === void 0 ? void 0 : options.port) !== null && _a !== void 0 ? _a : 502 }), () => {
|
|
281
281
|
called = true;
|
|
282
282
|
this._isOpen = true;
|
|
283
283
|
this._sockets.clear();
|
|
@@ -408,7 +408,7 @@ class UdpPhysicalLayer extends AbstractPhysicalLayer {
|
|
|
408
408
|
var _a;
|
|
409
409
|
if (this.isServer) {
|
|
410
410
|
let called = false;
|
|
411
|
-
this._socket.bind(Object.assign(Object.assign({}, options), { port: (_a = options.port) !== null && _a !== void 0 ? _a : 502 }), () => {
|
|
411
|
+
this._socket.bind(Object.assign(Object.assign({}, options), { port: (_a = options === null || options === void 0 ? void 0 : options.port) !== null && _a !== void 0 ? _a : 502 }), () => {
|
|
412
412
|
called = true;
|
|
413
413
|
this._isOpen = true;
|
|
414
414
|
this._socket.on('close', () => {
|
|
@@ -8,7 +8,7 @@ export declare class TcpClientPhysicalLayer extends AbstractPhysicalLayer {
|
|
|
8
8
|
get isOpen(): boolean;
|
|
9
9
|
get destroyed(): boolean;
|
|
10
10
|
constructor(options?: SocketConstructorOpts);
|
|
11
|
-
open(options
|
|
11
|
+
open(options?: SocketConnectOpts): Promise<void>;
|
|
12
12
|
write(data: Buffer): Promise<void>;
|
|
13
13
|
close(): Promise<void>;
|
|
14
14
|
destroy(): Promise<void>;
|
|
@@ -9,7 +9,7 @@ export declare class TcpServerPhysicalLayer extends AbstractPhysicalLayer {
|
|
|
9
9
|
get isOpen(): boolean;
|
|
10
10
|
get destroyed(): boolean;
|
|
11
11
|
constructor(options?: NetConnectOpts);
|
|
12
|
-
open(options
|
|
12
|
+
open(options?: ListenOptions): Promise<void>;
|
|
13
13
|
write(data: Buffer): Promise<void>;
|
|
14
14
|
close(): Promise<void>;
|
|
15
15
|
destroy(): Promise<void>;
|
|
@@ -20,7 +20,7 @@ export declare class UdpPhysicalLayer extends AbstractPhysicalLayer {
|
|
|
20
20
|
port?: number;
|
|
21
21
|
address?: string;
|
|
22
22
|
});
|
|
23
|
-
open(options
|
|
23
|
+
open(options?: BindOptions): Promise<void>;
|
|
24
24
|
write(data: Buffer): Promise<void>;
|
|
25
25
|
close(): Promise<void>;
|
|
26
26
|
destroy(): Promise<void>;
|