node-opcua-transport 2.167.0 → 2.168.0

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.
Files changed (55) hide show
  1. package/dist/source/AcknowledgeMessage.d.ts +5 -5
  2. package/dist/source/AcknowledgeMessage.js +5 -5
  3. package/dist/source/AcknowledgeMessage.js.map +1 -1
  4. package/dist/source/HelloMessage.d.ts +3 -3
  5. package/dist/source/HelloMessage.js +6 -6
  6. package/dist/source/HelloMessage.js.map +1 -1
  7. package/dist/source/TCPErrorMessage.d.ts +3 -3
  8. package/dist/source/TCPErrorMessage.js.map +1 -1
  9. package/dist/source/client_tcp_transport.d.ts +5 -2
  10. package/dist/source/client_tcp_transport.js +24 -25
  11. package/dist/source/client_tcp_transport.js.map +1 -1
  12. package/dist/source/i_hello_ack_limits.d.ts +1 -1
  13. package/dist/source/index.d.ts +2 -2
  14. package/dist/source/index.js +2 -2
  15. package/dist/source/index.js.map +1 -1
  16. package/dist/source/message_builder_base.d.ts +14 -27
  17. package/dist/source/message_builder_base.js +14 -13
  18. package/dist/source/message_builder_base.js.map +1 -1
  19. package/dist/source/server_tcp_transport.d.ts +6 -3
  20. package/dist/source/server_tcp_transport.js +34 -22
  21. package/dist/source/server_tcp_transport.js.map +1 -1
  22. package/dist/source/tcp_transport.d.ts +11 -15
  23. package/dist/source/tcp_transport.js +45 -52
  24. package/dist/source/tcp_transport.js.map +1 -1
  25. package/dist/source/tools.d.ts +3 -3
  26. package/dist/source/tools.js +7 -7
  27. package/dist/source/tools.js.map +1 -1
  28. package/dist/test_helpers/ITransportPair.d.ts +1 -1
  29. package/dist/test_helpers/fake_server.d.ts +3 -3
  30. package/dist/test_helpers/fake_server.js +11 -7
  31. package/dist/test_helpers/fake_server.js.map +1 -1
  32. package/dist/test_helpers/half_com_channel.d.ts +6 -6
  33. package/dist/test_helpers/half_com_channel.js +6 -6
  34. package/dist/test_helpers/half_com_channel.js.map +1 -1
  35. package/dist/test_helpers/index.d.ts +1 -1
  36. package/dist/test_helpers/index.js +1 -1
  37. package/dist/test_helpers/index.js.map +1 -1
  38. package/dist/test_helpers/transport_pair_direct.d.ts +2 -2
  39. package/dist/test_helpers/transport_pair_direct.js +2 -2
  40. package/dist/test_helpers/transport_pair_direct.js.map +1 -1
  41. package/dist/test_helpers/transport_pair_socket.d.ts +3 -3
  42. package/dist/test_helpers/transport_pair_socket.js +3 -3
  43. package/dist/test_helpers/transport_pair_socket.js.map +1 -1
  44. package/dist/tsconfig.tsbuildinfo +1 -1
  45. package/package.json +13 -13
  46. package/source/AcknowledgeMessage.ts +10 -11
  47. package/source/HelloMessage.ts +9 -9
  48. package/source/TCPErrorMessage.ts +3 -3
  49. package/source/client_tcp_transport.ts +28 -33
  50. package/source/i_hello_ack_limits.ts +1 -1
  51. package/source/index.ts +4 -4
  52. package/source/message_builder_base.ts +31 -43
  53. package/source/server_tcp_transport.ts +36 -32
  54. package/source/tcp_transport.ts +51 -68
  55. package/source/tools.ts +12 -18
@@ -2,20 +2,20 @@
2
2
  /**
3
3
  * @module node-opcua-transport
4
4
  */
5
- import { EventEmitter } from "events";
5
+
6
+ import { EventEmitter } from "node:events";
6
7
  import chalk from "chalk";
7
8
 
8
9
  import { assert } from "node-opcua-assert";
9
- import { make_debugLog, checkDebugFlag, make_errorLog, hexDump, make_warningLog } from "node-opcua-debug";
10
+ import { checkDebugFlag, hexDump, make_debugLog, make_errorLog, make_warningLog } from "node-opcua-debug";
10
11
  import { ObjectRegistry } from "node-opcua-object-registry";
11
12
  import { PacketAssembler, PacketAssemblerErrorCode } from "node-opcua-packet-assembler";
12
- import { ErrorCallback, CallbackWithData, StatusCode } from "node-opcua-status-code";
13
-
14
- import { StatusCodes2 } from "./status_codes";
13
+ import type { CallbackWithData, ErrorCallback, StatusCode } from "node-opcua-status-code";
15
14
  import { readRawMessageHeader } from "./message_builder_base";
16
- import { doTraceIncomingChunk } from "./utils";
15
+ import { StatusCodes2 } from "./status_codes";
17
16
  import { TCPErrorMessage } from "./TCPErrorMessage";
18
17
  import { packTcpMessage } from "./tools";
18
+ import { doTraceIncomingChunk } from "./utils";
19
19
 
20
20
  const debugLog = make_debugLog("TRANSPORT");
21
21
  const doDebug = checkDebugFlag("TRANSPORT");
@@ -28,7 +28,7 @@ export interface ISocketLike extends EventEmitter {
28
28
  remoteAddress?: string;
29
29
  remotePort?: number;
30
30
 
31
- write(data: string | Buffer, callback?: (err?: Error | null) => void | undefined): void;
31
+ write(data: string | Buffer, callback?: (err?: Error | null) => undefined | undefined): void;
32
32
  end(): void;
33
33
  setKeepAlive(enable?: boolean, initialDelay?: number): this;
34
34
  setNoDelay(noDelay?: boolean): this;
@@ -60,7 +60,7 @@ export interface ISocketLike extends EventEmitter {
60
60
  export interface IMockSocket extends ISocketLike {
61
61
  invalid?: boolean;
62
62
  // [key: string]: any;
63
- write(data: string | Buffer, callback?: (err?: Error) => void | undefined): void;
63
+ write(data: string | Buffer, callback?: (err?: Error) => void): void;
64
64
  destroy(): void;
65
65
  end(): void;
66
66
 
@@ -72,7 +72,7 @@ export interface IMockSocket extends ISocketLike {
72
72
  const defaultFakeSocket = {
73
73
  invalid: true,
74
74
  destroyed: false,
75
- destroy(err?: Error) {
75
+ destroy(_err?: Error) {
76
76
  this.destroyed = true;
77
77
  errorLog("MockSocket.destroy");
78
78
  },
@@ -81,20 +81,20 @@ const defaultFakeSocket = {
81
81
  errorLog("MockSocket.end");
82
82
  },
83
83
 
84
- write(data: string | Buffer, callback?: (err?: Error) => void | undefined): void {
84
+ write(_data: string | Buffer, callback?: (err?: Error) => undefined | undefined): void {
85
85
  /** */
86
86
  if (callback) {
87
87
  callback();
88
88
  }
89
89
  },
90
90
 
91
- setKeepAlive(enable?: boolean, initialDelay?: number) {
91
+ setKeepAlive(_enable?: boolean, _initialDelay?: number) {
92
92
  return this;
93
93
  },
94
- setNoDelay(noDelay?: boolean) {
94
+ setNoDelay(_noDelay?: boolean) {
95
95
  return this;
96
96
  },
97
- setTimeout(timeout: number, callback?: () => void) {
97
+ setTimeout(_timeout: number, _callback?: () => void) {
98
98
  return this;
99
99
  }
100
100
  };
@@ -116,27 +116,20 @@ export function getFakeTransport(): ISocketLike {
116
116
 
117
117
  let counter = 0;
118
118
 
119
- export interface TCP_transport {
119
+ export interface TCP_transportEvents {
120
120
  /**
121
121
  * notify the observers that a message chunk has been received
122
122
  * @event chunk
123
123
  * @param message_chunk the message chunk
124
124
  */
125
- on(eventName: "chunk", eventHandler: (messageChunk: Buffer) => void): this;
125
+ chunk: [messageChunk: Buffer];
126
126
  /**
127
127
  * notify the observers that the transport layer has been disconnected.
128
128
  * @event close
129
129
  */
130
- on(eventName: "close", eventHandler: (err: Error | null) => void): this;
131
-
132
- once(eventName: "chunk", eventHandler: (messageChunk: Buffer) => void): this;
133
- once(eventName: "close", eventHandler: (err: Error | null) => void): this;
134
-
135
- emit(eventName: "close", err?: Error | null): boolean;
136
- emit(eventName: "chunk", messageChunk: Buffer): boolean;
130
+ close: [err: Error | null];
137
131
  }
138
- // tslint:disable:class-name
139
- export class TCP_transport extends EventEmitter {
132
+ export class TCP_transport extends EventEmitter<TCP_transportEvents> {
140
133
  private static registry = new ObjectRegistry();
141
134
  /**
142
135
  * the size of the header in bytes
@@ -200,17 +193,17 @@ export class TCP_transport extends EventEmitter {
200
193
 
201
194
  public toString() {
202
195
  let str = "\n";
203
- str += " name.............. = " + this.name + "\n";
204
- str += " protocolVersion... = " + this.protocolVersion + "\n";
205
- str += " maxMessageSize.... = " + this.maxMessageSize + "\n";
206
- str += " maxChunkCount..... = " + this.maxChunkCount + "\n";
207
- str += " receiveBufferSize. = " + this.receiveBufferSize + "\n";
208
- str += " sendBufferSize.... = " + this.sendBufferSize + "\n";
209
- str += " bytesRead......... = " + this.bytesRead + "\n";
210
- str += " bytesWritten...... = " + this.bytesWritten + "\n";
211
- str += " chunkWrittenCount. = " + this.chunkWrittenCount + "\n";
212
- str += " chunkReadCount.... = " + this.chunkReadCount + "\n";
213
- str += " closeEmitted ? ....= " + this.#_closedEmitted + "\n";
196
+ str += ` name.............. = ${this.name}\n`;
197
+ str += ` protocolVersion... = ${this.protocolVersion}\n`;
198
+ str += ` maxMessageSize.... = ${this.maxMessageSize}\n`;
199
+ str += ` maxChunkCount..... = ${this.maxChunkCount}\n`;
200
+ str += ` receiveBufferSize. = ${this.receiveBufferSize}\n`;
201
+ str += ` sendBufferSize.... = ${this.sendBufferSize}\n`;
202
+ str += ` bytesRead......... = ${this.bytesRead}\n`;
203
+ str += ` bytesWritten...... = ${this.bytesWritten}\n`;
204
+ str += ` chunkWrittenCount. = ${this.chunkWrittenCount}\n`;
205
+ str += ` chunkReadCount.... = ${this.chunkReadCount}\n`;
206
+ str += ` closeEmitted ? ....= ${this.#_closedEmitted}\n`;
214
207
  return str;
215
208
  }
216
209
 
@@ -254,7 +247,7 @@ export class TCP_transport extends EventEmitter {
254
247
  }
255
248
  public set timeout(value: number) {
256
249
  assert(!this.#_timerId);
257
- doDebug && debugLog("Setting socket " + this.name + " timeout = ", value);
250
+ doDebug && debugLog(`Setting socket ${this.name} timeout = ${value}`);
258
251
  this.#_timeout = value;
259
252
  }
260
253
 
@@ -281,13 +274,13 @@ export class TCP_transport extends EventEmitter {
281
274
 
282
275
  * @param messageChunk
283
276
  */
284
- public write(messageChunk: Buffer, callback?: (err?: Error | null) => void | undefined): void {
277
+ public write(messageChunk: Buffer, callback?: (err?: Error | null) => undefined | undefined): void {
285
278
  const header = readRawMessageHeader(messageChunk);
286
279
  assert(header.length === messageChunk.length);
287
280
  const c = header.messageHeader.isFinal;
288
281
  assert(c === "F" || c === "C" || c === "A");
289
282
  this._write_chunk(messageChunk, (err) => {
290
- callback && callback(err);
283
+ callback?.(err);
291
284
  });
292
285
  }
293
286
 
@@ -300,7 +293,6 @@ export class TCP_transport extends EventEmitter {
300
293
  *
301
294
  */
302
295
  public disconnect(callback: ErrorCallback): void {
303
- assert(typeof callback === "function", "expecting a callback function, but got " + callback);
304
296
  if (!this._socket || this.#_isDisconnecting) {
305
297
  if (!this.#_isDisconnecting) {
306
298
  this.#_isDisconnecting = true;
@@ -320,7 +312,7 @@ export class TCP_transport extends EventEmitter {
320
312
  });
321
313
  });
322
314
 
323
- this._socket && this._socket.destroy(new Error("ClientTCP_transport disconnected"));
315
+ this._socket?.destroy(new Error("ClientTCP_transport disconnected"));
324
316
  this._socket = null;
325
317
  }
326
318
 
@@ -328,15 +320,13 @@ export class TCP_transport extends EventEmitter {
328
320
  return this._socket !== null && !this._socket.destroyed;
329
321
  }
330
322
 
331
- protected _write_chunk(messageChunk: Buffer, callback?: (err?: Error | null) => void | undefined): void {
323
+ protected _write_chunk(messageChunk: Buffer, callback?: (err?: Error | null) => undefined): void {
332
324
  if (this._socket !== null) {
333
325
  this.bytesWritten += messageChunk.length;
334
326
  this.chunkWrittenCount++;
335
327
  this._socket.write(messageChunk, callback);
336
328
  } else {
337
- if (callback) {
338
- callback();
339
- }
329
+ callback?.();
340
330
  }
341
331
  }
342
332
 
@@ -366,7 +356,7 @@ export class TCP_transport extends EventEmitter {
366
356
  }
367
357
 
368
358
  this.sendErrorMessage(statusCode, err.message);
369
- this.prematureTerminate(new Error("Packet Assembler : " + err.message), statusCode);
359
+ this.prematureTerminate(new Error(`Packet Assembler : ${err.message}`), statusCode);
370
360
  });
371
361
  }
372
362
 
@@ -383,10 +373,9 @@ export class TCP_transport extends EventEmitter {
383
373
  // Setting true for noDelay will immediately fire off data each time socket.write() is called.
384
374
  this._socket.setNoDelay(true);
385
375
  // set socket timeout
386
- debugLog(" TCP_transport#install => setting " + this.name + " _socket.setTimeout to ", this.timeout);
376
+ debugLog(` TCP_transport#install => setting ${this.name} _socket.setTimeout to `, this.timeout);
387
377
  // let use a large timeout here to make sure that we not conflict with our internal timeout
388
- this._socket.setTimeout(this.timeout, () => {
389
- });
378
+ this._socket.setTimeout(this.timeout, () => {});
390
379
 
391
380
  // c8 ignore next
392
381
  doDebug && debugLog(" TCP_transport#_install_socket ", this.name);
@@ -410,7 +399,7 @@ export class TCP_transport extends EventEmitter {
410
399
  debugLog(chalk.red(" extraErrorDescription ") + chalk.cyan(extraErrorDescription));
411
400
  }
412
401
 
413
- const reason = `${statusCode.toString()}:${extraErrorDescription || ""}`;
402
+ const reason = `${statusCode.toString()}:${extraErrorDescription || ""} `;
414
403
  const errorResponse = new TCPErrorMessage({
415
404
  statusCode,
416
405
  reason
@@ -427,7 +416,7 @@ export class TCP_transport extends EventEmitter {
427
416
  doDebugFlow && errorLog("prematureTerminate from", "has socket = ", !!this._socket, new Error().stack);
428
417
 
429
418
  if (this._socket) {
430
- err.message = "premature socket termination " + err.message;
419
+ err.message = `premature socket termination ${err.message} `;
431
420
  // we consider this as an error
432
421
  const _s = this._socket;
433
422
  this._socket = null;
@@ -450,7 +439,7 @@ export class TCP_transport extends EventEmitter {
450
439
  * Rules:
451
440
  * * TCP_transport will not emit the ```message``` event, while the "one time message receiver" is in operation.
452
441
  * * the TCP_transport will wait for the next complete message chunk and call the provided callback func
453
- * ```callback(null,messageChunk);```
442
+ * ```callback(null, messageChunk); ```
454
443
  *
455
444
  * if a messageChunk is not received within ```TCP_transport.timeout``` or if the underlying socket reports
456
445
  * an error, the callback function will be called with an Error.
@@ -503,9 +492,7 @@ export class TCP_transport extends EventEmitter {
503
492
 
504
493
  const onTimeout = () => {
505
494
  _cleanUp();
506
- this._fulfill_pending_promises(
507
- new Error(`Timeout(A) in waiting for data on socket ( timeout was = ${this.timeout} ms)`)
508
- );
495
+ this._fulfill_pending_promises(new Error(`Timeout(A) in waiting for data on socket(timeout was = ${this.timeout} ms)`));
509
496
  this.dispose();
510
497
  };
511
498
  // Setup timeout detection timer ....
@@ -518,9 +505,7 @@ export class TCP_transport extends EventEmitter {
518
505
  if (this._socket) {
519
506
  // to do = intercept socket error as well
520
507
  this.#_on_error_during_one_time_message_receiver = (hadError: boolean) => {
521
- const err = new Error(
522
- `ERROR in waiting for data on socket ( timeout was = ${this.timeout} ms) hadError` + hadError
523
- );
508
+ const err = new Error(`ERROR in waiting for data on socket(timeout was = ${this.timeout} ms) hadError${hadError} `);
524
509
  this._emitClose(err);
525
510
  this._fulfill_pending_promises(err);
526
511
  };
@@ -531,7 +516,7 @@ export class TCP_transport extends EventEmitter {
531
516
  this.#_theCallback = (err?: Error | null, data?: Buffer) => {
532
517
  _cleanUp();
533
518
  this.#_theCallback = undefined;
534
- _callback(err!, data);
519
+ _callback(err ?? null, data);
535
520
  };
536
521
  }
537
522
 
@@ -574,39 +559,37 @@ export class TCP_transport extends EventEmitter {
574
559
  // callback(err || null);
575
560
  // }
576
561
  } else {
577
- debugLog("Already emitted close event", (this.#_closedEmitted as any).message);
578
- debugLog("err = ", err?.message);
579
- debugLog("");
580
- debugLog("Already emitted close event", this.#_closedEmitted);
562
+ const prevClose = this.#_closedEmitted instanceof Error ? this.#_closedEmitted.message : this.#_closedEmitted;
563
+ debugLog("Already emitted close event", prevClose);
581
564
  debugLog("err = ", err?.message, err);
582
565
  }
583
566
  }
584
567
 
585
568
  private _on_socket_end() {
586
569
  // c8 ignore next
587
- doDebug && debugLog(chalk.red(` SOCKET END : ${this.name}`), "is disconnecting ", this.isDisconnecting());
570
+ doDebug && debugLog(chalk.red(` SOCKET END: ${this.name} `), "is disconnecting ", this.isDisconnecting());
588
571
  if (this.isDisconnecting()) {
589
572
  return;
590
573
  }
591
574
  //
592
- debugLog(chalk.red(" Transport Connection ended") + " " + this.name);
593
- const err = new Error(this.name + ": socket has been disconnected by third party");
575
+ debugLog(`${chalk.red(" Transport Connection ended")} ${this.name} `);
576
+ const err = new Error(`${this.name}: socket has been disconnected by third party`);
594
577
  debugLog(" bytesRead = ", this.bytesRead);
595
578
  debugLog(" bytesWritten = ", this.bytesWritten);
596
579
  this._theCloseError = err;
597
580
 
598
- this._fulfill_pending_promises(new Error("Connection aborted - ended by server : " + (err ? err.message : "")));
581
+ this._fulfill_pending_promises(new Error(`Connection aborted - ended by server: ${err ? err.message : ""} `));
599
582
  }
600
583
 
601
584
  private _on_socket_error(err: Error) {
602
585
  // c8 ignore next
603
- debugLog(chalk.red(` _on_socket_error: ${this.name}`), chalk.yellow(err.message));
586
+ debugLog(chalk.red(` _on_socket_error: ${this.name} `), chalk.yellow(err.message));
604
587
  // node The "close" event will be called directly following this event.
605
588
  // this._emitClose(err);
606
589
  }
607
590
 
608
591
  private _on_socket_timeout() {
609
- const msg = `socket timeout : timeout=${this.timeout} ${this.name}`;
592
+ const msg = `socket timeout: timeout = ${this.timeout} ${this.name} `;
610
593
  doDebug && debugLog(msg);
611
594
  this.prematureTerminate(new Error(msg), StatusCodes2.BadTimeout);
612
595
  }
package/source/tools.ts CHANGED
@@ -3,10 +3,10 @@
3
3
  */
4
4
 
5
5
  import { assert } from "node-opcua-assert";
6
- import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
6
+ import { BinaryStream, type OutputBinaryStream } from "node-opcua-binary-stream";
7
7
  import { createFastUninitializedBuffer } from "node-opcua-buffer-utils";
8
8
  import { readMessageHeader } from "node-opcua-chunkmanager";
9
- import { BaseUAObject } from "node-opcua-factory";
9
+ import type { BaseUAObject } from "node-opcua-factory";
10
10
 
11
11
  import { TCPErrorMessage } from "./TCPErrorMessage";
12
12
 
@@ -20,21 +20,21 @@ function is_valid_msg_type(msgType: string): boolean {
20
20
  "MSG",
21
21
  "CLO" // OPC Unified Architecture, Part 6 page 36
22
22
  ].indexOf(msgType) >= 0,
23
- "invalid message type " + msgType
23
+ `invalid message type ${msgType}`
24
24
  );
25
25
  return true;
26
26
  }
27
27
 
28
- export type ConstructorFunc = new (...args: any[]) => BaseUAObject;
28
+ export type ConstructorFunc = new () => BaseUAObject;
29
29
 
30
30
  export function decodeMessage(stream: BinaryStream, classNameConstructor: ConstructorFunc): BaseUAObject {
31
31
  assert(stream instanceof BinaryStream);
32
- assert(classNameConstructor instanceof Function, " expecting a function for " + classNameConstructor);
32
+ assert(classNameConstructor instanceof Function, ` expecting a function for ${classNameConstructor}`);
33
33
 
34
34
  const header = readMessageHeader(stream);
35
35
  assert(stream.length === 8);
36
36
 
37
- let obj;
37
+ let obj: BaseUAObject;
38
38
  if (header.msgType === "ERR") {
39
39
  obj = new TCPErrorMessage();
40
40
  obj.decode(stream);
@@ -73,19 +73,19 @@ export function parseEndpointUrl(endpointUrl: string): ParsedEndpointUrl {
73
73
  // original protocol in the result.
74
74
  const protocolMatch = endpointUrl.match(/^([a-z][a-z0-9.+-]*):/i);
75
75
  if (!protocolMatch) {
76
- throw new Error("Invalid endpoint url " + endpointUrl);
76
+ throw new Error(`Invalid endpoint url ${endpointUrl}`);
77
77
  }
78
- const originalProtocol = protocolMatch[1].toLowerCase() + ":";
78
+ const originalProtocol = `${protocolMatch[1].toLowerCase()}:`;
79
79
  const normalizedUrl = endpointUrl.replace(/^[a-z][a-z0-9.+-]*:/i, "http:");
80
80
 
81
81
  let parsed: URL;
82
82
  try {
83
83
  parsed = new URL(normalizedUrl);
84
84
  } catch {
85
- throw new Error("Invalid endpoint url " + endpointUrl);
85
+ throw new Error(`Invalid endpoint url ${endpointUrl}`);
86
86
  }
87
87
  if (!parsed.hostname) {
88
- throw new Error("Invalid endpoint url " + endpointUrl);
88
+ throw new Error(`Invalid endpoint url ${endpointUrl}`);
89
89
  }
90
90
  return {
91
91
  protocol: originalProtocol,
@@ -95,20 +95,14 @@ export function parseEndpointUrl(endpointUrl: string): ParsedEndpointUrl {
95
95
  auth: parsed.username ? (parsed.password ? `${parsed.username}:${parsed.password}` : parsed.username) : null,
96
96
  href: endpointUrl
97
97
  };
98
-
99
98
  }
100
99
 
101
100
  export function is_valid_endpointUrl(endpointUrl: string): boolean {
102
101
  const e = parseEndpointUrl(endpointUrl);
103
- return Object.prototype.hasOwnProperty.call(e, "hostname");
102
+ return Object.hasOwn(e, "hostname");
104
103
  }
105
104
 
106
- export function writeTCPMessageHeader(
107
- msgType: string,
108
- chunkType: string,
109
- totalLength: number,
110
- stream: OutputBinaryStream
111
- ): void {
105
+ export function writeTCPMessageHeader(msgType: string, chunkType: string, totalLength: number, stream: OutputBinaryStream): void {
112
106
  if (stream instanceof Buffer) {
113
107
  stream = new BinaryStream(stream);
114
108
  }