node-opcua-samples 2.66.3 → 2.68.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/bin/di_server.js CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- const chalk = require("chalk");
4
- const opcua = require("node-opcua");
5
3
  const path = require("path");
6
4
  const os = require("os");
5
+ const chalk = require("chalk");
6
+ const opcua = require("node-opcua");
7
7
 
8
8
  Error.stackTraceLimit = Infinity;
9
9
 
@@ -107,7 +107,7 @@ server_options.alternateHostname = argv.alternateHostname;
107
107
  const server = new OPCUAServer(server_options);
108
108
 
109
109
 
110
- const hostname = require("os").hostname();
110
+ const hostname = os.hostname();
111
111
 
112
112
 
113
113
 
@@ -209,8 +209,7 @@ server.on("post_initialize", function() {
209
209
 
210
210
  function dumpNode(node) {
211
211
  function w(str, width) {
212
- const tmp = str + " ";
213
- return tmp.substr(0, width);
212
+ return str.padEnd(width).substring(0, width);
214
213
  }
215
214
  return Object.entries(node).map((key,value) =>
216
215
  " " + w(key, 30) + " : " + ((value === null) ? null : value.toString())
@@ -261,7 +260,7 @@ server.on("session_closed", function(session, reason) {
261
260
  });
262
261
 
263
262
  function w(s, w) {
264
- return ("000" + s).substr(-w);
263
+ return s.toString().padStart(w,"0");
265
264
  }
266
265
  function t(d) {
267
266
  return w(d.getHours(), 2) + ":" + w(d.getMinutes(), 2) + ":" + w(d.getSeconds(), 2) + ":" + w(d.getMilliseconds(), 3);
@@ -1,5 +1,5 @@
1
- /* eslint-disable no-case-declarations */
2
1
  #!/usr/bin/env node
2
+ /* eslint-disable no-case-declarations */
3
3
  /* eslint no-process-exit: 0 */
4
4
  "use strict";
5
5
  const chalk = require("chalk");
@@ -44,7 +44,7 @@ let curNodeCompletion = [];
44
44
 
45
45
  function save_endpoint_history(callback) {
46
46
  if (endpoints_history.length > 0) {
47
- fs.writeFileSync(endpoints_history_file, endpoints_history.join("\n"), "ascii");
47
+ fs.writeFileSync(endpoints_history_file, endpoints_history.join("\n"), "utf-8");
48
48
  }
49
49
  if (callback) {
50
50
  callback();
@@ -63,7 +63,7 @@ let lines = [];
63
63
 
64
64
 
65
65
  if (fs.existsSync(endpoints_history_file)) {
66
- lines = fs.readFileSync(endpoints_history_file, "ascii");
66
+ lines = fs.readFileSync(endpoints_history_file, "utf-8");
67
67
  endpoints_history = lines.split(/\r\n|\n/);
68
68
  }
69
69
 
@@ -118,12 +118,12 @@ rl.prompt();
118
118
 
119
119
  function save_history(callback) {
120
120
  const history_uniq = _.uniq(rl.history);
121
- fs.writeFileSync(history_file, history_uniq.join("\n"), "ascii");
121
+ fs.writeFileSync(history_file, history_uniq.join("\n"), "utf-8");
122
122
  callback();
123
123
  }
124
124
 
125
125
  function w(str, width) {
126
- return (str + " ").substr(0, width);
126
+ return str.padEnd(width," ").substring(0, width);
127
127
  }
128
128
  /**
129
129
  * @method toDate
@@ -297,7 +297,7 @@ function colorize(value) {
297
297
  if (rl.history) {
298
298
 
299
299
  if (fs.existsSync(history_file)) {
300
- lines = fs.readFileSync(history_file, "ascii");
300
+ lines = fs.readFileSync(history_file, "utf-8");
301
301
  lines = lines.split(/\r\n|\n/);
302
302
  }
303
303
  if (lines.length === 0) {
@@ -128,7 +128,7 @@ const doCrawling = !!argv.crawl;
128
128
  const doHistory = !!argv.history;
129
129
 
130
130
  function w(str, l) {
131
- return (str + " ").substr(0, l);
131
+ return str.padEnd(l).substring(0, l);
132
132
  }
133
133
 
134
134
  async function enumerateAllConditionTypes(session) {
@@ -50,7 +50,7 @@ const Table = require("easy-table");
50
50
  const treeify = require("treeify");
51
51
 
52
52
  function w(str: string, l: number): string {
53
- return (str + " ").substr(0, l);
53
+ return str.padEnd(l).substring(0, l);
54
54
  }
55
55
 
56
56
  async function enumerateAllConditionTypes(session: ClientSession) {