node-opcua-utils 2.55.0 → 2.56.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 (40) hide show
  1. package/dist/function_variadic.d.ts +1 -0
  2. package/dist/function_variadic.js +3 -0
  3. package/dist/function_variadic.js.map +1 -0
  4. package/dist/get_function_parameters_name.d.ts +2 -1
  5. package/dist/get_function_parameters_name.js +0 -1
  6. package/dist/get_function_parameters_name.js.map +1 -1
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.js +2 -2
  9. package/dist/index.js.map +1 -1
  10. package/dist/line_file.d.ts +1 -1
  11. package/dist/line_file.js +3 -3
  12. package/dist/line_file.js.map +1 -1
  13. package/dist/object_classname.d.ts +1 -1
  14. package/dist/object_classname.js.map +1 -1
  15. package/dist/replace_buffer_with_hex_dump.d.ts +3 -1
  16. package/dist/replace_buffer_with_hex_dump.js +1 -1
  17. package/dist/replace_buffer_with_hex_dump.js.map +1 -1
  18. package/dist/set_deprecated.d.ts +2 -1
  19. package/dist/set_deprecated.js +2 -2
  20. package/dist/set_deprecated.js.map +1 -1
  21. package/dist/string_utils.d.ts +4 -4
  22. package/dist/string_utils.js +5 -5
  23. package/dist/string_utils.js.map +1 -1
  24. package/dist/timestamp.js +1 -4
  25. package/dist/timestamp.js.map +1 -1
  26. package/dist/watchdog.js +1 -1
  27. package/dist/watchdog.js.map +1 -1
  28. package/package.json +4 -2
  29. package/source/function_variadic.ts +1 -0
  30. package/source/get_clock_tick.ts +18 -18
  31. package/source/get_function_parameters_name.ts +15 -13
  32. package/source/index.ts +46 -46
  33. package/source/line_file.ts +24 -24
  34. package/source/match_uri.ts +19 -19
  35. package/source/object_classname.ts +11 -11
  36. package/source/replace_buffer_with_hex_dump.ts +15 -15
  37. package/source/set_deprecated.ts +29 -28
  38. package/source/string_utils.ts +12 -12
  39. package/source/timestamp.ts +11 -15
  40. package/source/watchdog.ts +200 -200
@@ -0,0 +1 @@
1
+ export declare type FunctionVariadic = (...args: any[]) => void;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=function_variadic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function_variadic.js","sourceRoot":"","sources":["../source/function_variadic.ts"],"names":[],"mappings":""}
@@ -1 +1,2 @@
1
- export declare function getFunctionParameterNames(func: Function): RegExpMatchArray;
1
+ import { FunctionVariadic } from "./function_variadic";
2
+ export declare function getFunctionParameterNames(func: FunctionVariadic): string[];
@@ -6,7 +6,6 @@ exports.getFunctionParameterNames = void 0;
6
6
  */
7
7
  const STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;
8
8
  const ARGUMENT_NAMES = /([^\s,]+)/g;
9
- // tslint:disable-next-line:ban-types
10
9
  function getFunctionParameterNames(func) {
11
10
  const fnStr = func.toString().replace(STRIP_COMMENTS, "");
12
11
  let result = fnStr.slice(fnStr.indexOf("(") + 1, fnStr.indexOf(")")).match(ARGUMENT_NAMES);
@@ -1 +1 @@
1
- {"version":3,"file":"get_function_parameters_name.js","sourceRoot":"","sources":["../source/get_function_parameters_name.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAM,cAAc,GAAG,kCAAkC,CAAC;AAC1D,MAAM,cAAc,GAAG,YAAY,CAAC;AAEpC,qCAAqC;AACrC,SAAgB,yBAAyB,CAAC,IAAc;IACpD,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;IAC1D,IAAI,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAC3F,IAAI,MAAM,KAAK,IAAI,EAAE;QAAE,MAAM,GAAG,EAAE,CAAC;KAAE;IACrC,OAAO,MAAM,CAAC;AAClB,CAAC;AALD,8DAKC"}
1
+ {"version":3,"file":"get_function_parameters_name.js","sourceRoot":"","sources":["../source/get_function_parameters_name.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAM,cAAc,GAAG,kCAAkC,CAAC;AAC1D,MAAM,cAAc,GAAG,YAAY,CAAC;AAGpC,SAAgB,yBAAyB,CAAC,IAAsB;IAC5D,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;IAC1D,IAAI,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAC3F,IAAI,MAAM,KAAK,IAAI,EAAE;QACjB,MAAM,GAAG,EAAE,CAAC;KACf;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAPD,8DAOC"}
package/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@ export declare function set_flag(value: number, mask: number | {
12
12
  export declare function check_flag(value: number, mask: number | {
13
13
  value: number;
14
14
  }): boolean;
15
- export declare function isNullOrUndefined(value: any): boolean;
15
+ export declare function isNullOrUndefined(value: unknown | undefined): boolean;
16
16
  export { buffer_ellipsis } from "./buffer_ellipsis";
17
17
  export { capitalizeFirstLetter, lowerFirstLetter } from "./string_utils";
18
18
  export { getObjectClassName } from "./object_classname";
package/dist/index.js CHANGED
@@ -24,7 +24,7 @@ function set_flag(value, mask) {
24
24
  if (mask.value) {
25
25
  mask = mask.value;
26
26
  }
27
- (0, node_opcua_assert_1.assert)(!mask.hasOwnProperty("value"));
27
+ (0, node_opcua_assert_1.assert)(!Object.prototype.hasOwnProperty.call(mask, "value"));
28
28
  (0, node_opcua_assert_1.assert)(mask !== undefined);
29
29
  return value | mask;
30
30
  }
@@ -37,7 +37,7 @@ function check_flag(value, mask) {
37
37
  if (mask.value) {
38
38
  mask = mask.value;
39
39
  }
40
- (0, node_opcua_assert_1.assert)(!mask.hasOwnProperty("value"));
40
+ (0, node_opcua_assert_1.assert)(!Object.prototype.hasOwnProperty.call(mask, "value"));
41
41
  return (value & mask) === mask;
42
42
  }
43
43
  exports.check_flag = check_flag;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;;GAEG;AACH,4BAA4B;AAC5B,yDAA2C;AAE3C;;;GAGG;AACH,SAAgB,QAAQ,CAAC,KAAa,EAAE,IAAgC;IACpE,IAAK,IAAY,CAAC,KAAK,EAAE;QACrB,IAAI,GAAI,IAAY,CAAC,KAAK,CAAC;KAC9B;IACD,IAAA,0BAAM,EAAC,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IACtC,IAAA,0BAAM,EAAC,IAAI,KAAK,SAAS,CAAC,CAAC;IAC3B,OAAO,KAAK,GAAI,IAAe,CAAC;AACpC,CAAC;AAPD,4BAOC;AACD;;;GAGG;AACH,SAAgB,UAAU,CAAC,KAAa,EAAE,IAAgC;IACtE,IAAK,IAAY,CAAC,KAAK,EAAE;QACrB,IAAI,GAAI,IAAY,CAAC,KAAK,CAAC;KAC9B;IACD,IAAA,0BAAM,EAAC,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IACtC,OAAO,CAAC,KAAK,GAAI,IAAe,CAAC,KAAM,IAAe,CAAC;AAC3D,CAAC;AAND,gCAMC;AAED,SAAgB,iBAAiB,CAAC,KAAU;IACxC,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AACjD,CAAC;AAFD,8CAEC;AAED,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,+CAAyE;AAAhE,qHAAA,qBAAqB,OAAA;AA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K,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AACjD,CAAC;AAFD,8CAEC;AAED,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,+CAAyE;AAAhE,qHAAA,qBAAqB,OAAA;AAAE,gHAAA,gBAAgB,OAAA;AAChD,uDAAwD;AAA/C,sHAAA,kBAAkB,OAAA;AAC3B,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,+EAA2E;AAAlE,yIAAA,yBAAyB,OAAA;AAClC,6CAA2B;AAC3B,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AACtB,+EAA0E;AAAjE,wIAAA,wBAAwB,OAAA;AACjC,8CAA4B;AAC5B,8CAA4B;AAC5B,8CAA4B"}
@@ -4,6 +4,6 @@
4
4
  export declare class LineFile {
5
5
  private _line;
6
6
  constructor();
7
- write(...arg: string[]): void;
7
+ write(...args: string[]): void;
8
8
  toString(endOfLine?: "\n" | "\r"): string;
9
9
  }
package/dist/line_file.js CHANGED
@@ -8,11 +8,11 @@ class LineFile {
8
8
  constructor() {
9
9
  this._line = [];
10
10
  }
11
- write(...arg) {
11
+ write(...args) {
12
12
  let str = "";
13
13
  // tslint:disable:prefer-for-of
14
- for (let i = 0; i < arguments.length; i++) {
15
- str += arguments[i];
14
+ for (let i = 0; i < args.length; i++) {
15
+ str += args[i];
16
16
  }
17
17
  this._line.push(str);
18
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"line_file.js","sourceRoot":"","sources":["../source/line_file.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,MAAa,QAAQ;IAGjB;QACI,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IACpB,CAAC;IAEM,KAAK,CAAC,GAAG,GAAa;QACzB,IAAI,GAAG,GAAG,EAAE,CAAC;QACb,+BAA+B;QAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACvC,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;SACvB;QACD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAEM,QAAQ,CAAC,YAAyB,IAAI;QACzC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;CACJ;AAnBD,4BAmBC"}
1
+ {"version":3,"file":"line_file.js","sourceRoot":"","sources":["../source/line_file.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,MAAa,QAAQ;IAGjB;QACI,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IACpB,CAAC;IAEM,KAAK,CAAC,GAAG,IAAc;QAC1B,IAAI,GAAG,GAAG,EAAE,CAAC;QACb,+BAA+B;QAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAClC,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;SAClB;QACD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAEM,QAAQ,CAAC,YAAyB,IAAI;QACzC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;CACJ;AAnBD,4BAmBC"}
@@ -6,4 +6,4 @@
6
6
  * @param obj
7
7
  * @return {string}
8
8
  */
9
- export declare function getObjectClassName(obj: object): string;
9
+ export declare function getObjectClassName(obj: unknown): string;
@@ -1 +1 @@
1
- {"version":3,"file":"object_classname.js","sourceRoot":"","sources":["../source/object_classname.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,GAAW;IAC1C,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC5D,CAAC;AAFD,gDAEC"}
1
+ {"version":3,"file":"object_classname.js","sourceRoot":"","sources":["../source/object_classname.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,GAAY;IAC3C,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC5D,CAAC;AAFD,gDAEC"}
@@ -1,4 +1,6 @@
1
1
  /**
2
2
  * @module node-opcua-utils
3
3
  */
4
- export declare function replaceBufferWithHexDump(obj: any): any;
4
+ export declare function replaceBufferWithHexDump(obj: Record<string, {
5
+ toString(format: string): void;
6
+ }>): any;
@@ -6,7 +6,7 @@ exports.replaceBufferWithHexDump = void 0;
6
6
  */
7
7
  function replaceBufferWithHexDump(obj) {
8
8
  for (const p in obj) {
9
- if (obj.hasOwnProperty(p)) {
9
+ if (Object.prototype.hasOwnProperty.call(obj, p)) {
10
10
  if (obj[p] instanceof Buffer) {
11
11
  obj[p] = "<BUFFER>" + obj[p].toString("hex") + "</BUFFER>";
12
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"replace_buffer_with_hex_dump.js","sourceRoot":"","sources":["../source/replace_buffer_with_hex_dump.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,SAAgB,wBAAwB,CAAC,GAAQ;IAC7C,KAAK,MAAM,CAAC,IAAI,GAAG,EAAE;QACjB,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE;YACvB,IAAI,GAAG,CAAC,CAAC,CAAC,YAAY,MAAM,EAAE;gBAC1B,GAAG,CAAC,CAAC,CAAC,GAAG,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC;aAC9D;iBAAM,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;gBACnC,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;aACpC;SACJ;KACJ;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AAXD,4DAWC"}
1
+ {"version":3,"file":"replace_buffer_with_hex_dump.js","sourceRoot":"","sources":["../source/replace_buffer_with_hex_dump.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,SAAgB,wBAAwB,CAAC,GAAuD;IAC5F,KAAK,MAAM,CAAC,IAAI,GAAG,EAAE;QACjB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE;YAC9C,IAAI,GAAG,CAAC,CAAC,CAAC,YAAY,MAAM,EAAE;gBAC1B,GAAG,CAAC,CAAC,CAAC,GAAG,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC;aAC9D;iBAAM,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;gBACnC,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;aACpC;SACJ;KACJ;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AAXD,4DAWC"}
@@ -1 +1,2 @@
1
- export declare function setDeprecated(constructor: Function, methodName: string, helpString: string): void;
1
+ import { FunctionVariadic } from "./function_variadic";
2
+ export declare function setDeprecated(constructor: FunctionVariadic, methodName: string, helpString: string): void;
@@ -12,14 +12,14 @@ function setDeprecated(constructor, methodName, helpString) {
12
12
  const oldMethod = constructor.prototype[methodName];
13
13
  (0, node_opcua_assert_1.assert)(oldMethod instanceof Function, "expecting a valid " + methodName + "method on class " + constructor.constructor.name);
14
14
  let counter = 0;
15
- constructor.prototype[methodName] = function () {
15
+ constructor.prototype[methodName] = function (...args) {
16
16
  if (counter % 1000 === 0) {
17
17
  // tslint:disable:no-console
18
18
  console.log(chalk.green("Warning !"), chalk.green(chalk.bold(constructor.name + "#" + methodName), " is now deprecated"));
19
19
  console.log(" ", helpString);
20
20
  }
21
21
  counter++;
22
- return oldMethod.apply(this, arguments);
22
+ return oldMethod.call(this, ...args);
23
23
  };
24
24
  }
25
25
  exports.setDeprecated = setDeprecated;
@@ -1 +1 @@
1
- {"version":3,"file":"set_deprecated.js","sourceRoot":"","sources":["../source/set_deprecated.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,2BAA2B;AAC3B,+BAA+B;AAC/B,yDAA2C;AAE3C,0BAA0B;AAC1B,SAAgB,aAAa,CAAC,WAAqB,EAAE,UAAkB,EAAE,UAAkB;IAEvF,MAAM,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAEpD,IAAA,0BAAM,EAAC,SAAS,YAAY,QAAQ,EAClC,oBAAoB,GAAG,UAAU,GAAG,kBAAkB,GAAG,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAEzF,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG;QAChC,IAAI,OAAO,GAAG,IAAI,KAAK,CAAC,EAAE;YACtB,4BAA4B;YAC5B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,EAClC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,GAAG,GAAG,GAAG,UAAU,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC;YACtF,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;SACxC;QACD,OAAO,EAAE,CAAC;QACV,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC5C,CAAC,CAAC;AAEN,CAAC;AAnBD,sCAmBC"}
1
+ {"version":3,"file":"set_deprecated.js","sourceRoot":"","sources":["../source/set_deprecated.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,2BAA2B;AAC3B,+BAA+B;AAC/B,yDAA2C;AAI3C,0BAA0B;AAC1B,SAAgB,aAAa,CAAC,WAA6B,EAAE,UAAkB,EAAE,UAAkB;IAC/F,MAAM,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAEpD,IAAA,0BAAM,EAAC,SAAS,YAAY,QAAQ,EAAE,oBAAoB,GAAG,UAAU,GAAG,kBAAkB,GAAG,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAE7H,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,IAAW;QACxD,IAAI,OAAO,GAAG,IAAI,KAAK,CAAC,EAAE;YACtB,4BAA4B;YAC5B,OAAO,CAAC,GAAG,CACP,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,EACxB,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,GAAG,GAAG,GAAG,UAAU,CAAC,EAAE,oBAAoB,CAAC,CACrF,CAAC;YACF,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;SACxC;QACD,OAAO,EAAE,CAAC;QACV,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;IACzC,CAAC,CAAC;AACN,CAAC;AAlBD,sCAkBC"}
@@ -18,11 +18,11 @@ export declare function countAlpha(str: string): number;
18
18
  *
19
19
  * OPCUA Identifier usually starts with a upper case letter and word are join together, this is known as
20
20
  * the Pascal case, or CapitalizedWords convention. (for instance HelloWorld)
21
- * But sometime, OPCUA indentifiers do not follow this convention strictly and we can find various
22
- * other convention being applied such as underscore between word, or addintion of ACRONYMED prefixes.
23
- * On it's own, this causes great confusion and inconsistancy in programming style.
21
+ * But sometime, OPCUA identifiers do not follow this convention strictly and we can find various
22
+ * other convention being applied such as underscore between word, or addition of ACRONYMIC prefixes.
23
+ * On it's own, this causes great confusion and inconsistency in programming style.
24
24
  *
25
- * Javascritpt uses a slightly different convention called camelCase where word are joined together
25
+ * Javascript uses a slightly different convention called camelCase where word are joined together
26
26
  * and inner words starts with a capital letter whereas first word starts with a lower case letter.
27
27
  * (for instance helloWorld)
28
28
  *
@@ -62,11 +62,11 @@ exports.countAlpha = countAlpha;
62
62
  *
63
63
  * OPCUA Identifier usually starts with a upper case letter and word are join together, this is known as
64
64
  * the Pascal case, or CapitalizedWords convention. (for instance HelloWorld)
65
- * But sometime, OPCUA indentifiers do not follow this convention strictly and we can find various
66
- * other convention being applied such as underscore between word, or addintion of ACRONYMED prefixes.
67
- * On it's own, this causes great confusion and inconsistancy in programming style.
65
+ * But sometime, OPCUA identifiers do not follow this convention strictly and we can find various
66
+ * other convention being applied such as underscore between word, or addition of ACRONYMIC prefixes.
67
+ * On it's own, this causes great confusion and inconsistency in programming style.
68
68
  *
69
- * Javascritpt uses a slightly different convention called camelCase where word are joined together
69
+ * Javascript uses a slightly different convention called camelCase where word are joined together
70
70
  * and inner words starts with a capital letter whereas first word starts with a lower case letter.
71
71
  * (for instance helloWorld)
72
72
  *
@@ -115,7 +115,7 @@ function lowerFirstLetter(str) {
115
115
  if (str.length >= 2 && countUpperCase(str) === countAlpha(str)) {
116
116
  return str;
117
117
  }
118
- if (str.match(/\_/)) {
118
+ if (str.match(/_/)) {
119
119
  return str.split("_").map(lowerFirstLetter).join("_");
120
120
  }
121
121
  let result = str.substr(0, 1).toLowerCase() + str.substr(1);
@@ -1 +1 @@
1
- {"version":3,"file":"string_utils.js","sourceRoot":"","sources":["../source/string_utils.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,+BAA+B;AAC/B,SAAgB,qBAAqB,CAAC,GAAW;IAC7C,IAAI,GAAG,IAAI,IAAI,EAAE;QACb,OAAO,GAAG,CAAC;KACd;IACD,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE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AC,CAAC,CAAC,IAAI,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE;QACzE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;KAC3D;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAjBD,4CAiBC"}
package/dist/timestamp.js CHANGED
@@ -5,10 +5,7 @@ function w(s, length) {
5
5
  return ("000" + s).substr(-length);
6
6
  }
7
7
  function t(d) {
8
- return w(d.getUTCHours(), 2) + ":"
9
- + w(d.getUTCMinutes(), 2) + ":"
10
- + w(d.getUTCSeconds(), 2) + ":"
11
- + w(d.getMilliseconds(), 3);
8
+ return w(d.getUTCHours(), 2) + ":" + w(d.getUTCMinutes(), 2) + ":" + w(d.getUTCSeconds(), 2) + ":" + w(d.getMilliseconds(), 3);
12
9
  }
13
10
  function timestamp() {
14
11
  return t(new Date());
@@ -1 +1 @@
1
- {"version":3,"file":"timestamp.js","sourceRoot":"","sources":["../source/timestamp.ts"],"names":[],"mappings":";;;AAAA,SAAS,CAAC,CAAC,CAAkB,EAAE,MAAc;IACzC,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AACvC,CAAC;AAED,SAAS,CAAC,CAAC,CAAO;IACd,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG;UAC5B,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG;UAC7B,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG;UAC7B,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC;AACpC,CAAC;AAED,SAAgB,SAAS;IACrB,OAAO,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;AACzB,CAAC;AAFD,8BAEC"}
1
+ {"version":3,"file":"timestamp.js","sourceRoot":"","sources":["../source/timestamp.ts"],"names":[],"mappings":";;;AAAA,SAAS,CAAC,CAAC,CAAkB,EAAE,MAAc;IACzC,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AACvC,CAAC;AAED,SAAS,CAAC,CAAC,CAAO;IACd,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC;AACnI,CAAC;AAED,SAAgB,SAAS;IACrB,OAAO,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;AACzB,CAAC;AAFD,8BAEC"}
package/dist/watchdog.js CHANGED
@@ -107,7 +107,7 @@ class WatchDog extends events_1.EventEmitter {
107
107
  (0, node_opcua_assert_1.assert)(subscriber._watchDog instanceof WatchDog);
108
108
  (0, node_opcua_assert_1.assert)(typeof subscriber._watchDogData.key === "number");
109
109
  (0, node_opcua_assert_1.assert)(typeof subscriber.keepAlive === "function");
110
- (0, node_opcua_assert_1.assert)(this._watchdogDataMap.hasOwnProperty(subscriber._watchDogData.key));
110
+ (0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(this._watchdogDataMap, subscriber._watchDogData.key));
111
111
  delete this._watchdogDataMap[subscriber._watchDogData.key];
112
112
  delete subscriber._watchDog;
113
113
  delete subscriber._watchDogData;
@@ -1 +1 @@
1
- {"version":3,"file":"watchdog.js","sourceRoot":"","sources":["../source/watchdog.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,mCA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AA,0BAAM,EAAC,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE,+BAA+B,CAAC,CAAC;QAC9D,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;IAC5D,CAAC;IAEO,WAAW;QACf,IAAA,0BAAM,EAAC,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE,8BAA8B,CAAC,CAAC;QAC7D,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE;YACtB,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC3B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;SACtB;IACL,CAAC;;AAzIL,4BA0IC;AAzIU,uBAAc,GAAG,GAAS,EAAE;IAC/B,KAAK;AACT,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "node-opcua-utils",
3
- "version": "2.55.0",
3
+ "version": "2.56.0",
4
4
  "description": "pure nodejs OPCUA SDK - module -utils",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc -b",
9
+ "lint": "eslint source test",
10
+ "format": "prettier --write source test",
9
11
  "test": "mocha",
10
12
  "clean": "node -e \"require('rimraf').sync('dist');\""
11
13
  },
@@ -34,5 +36,5 @@
34
36
  "internet of things"
35
37
  ],
36
38
  "homepage": "http://node-opcua.github.io/",
37
- "gitHead": "28fdbfe1c5306fd0e69758ccacfa2c6d1722115c"
39
+ "gitHead": "9f6eac1c658c0d182fbe03cf58f799af468615eb"
38
40
  }
@@ -0,0 +1 @@
1
+ export type FunctionVariadic = (...args: any[]) => void;
@@ -1,18 +1,18 @@
1
- /**
2
- * @module node-opcua-utils
3
- */
4
- export let get_clock_tick: () => number;
5
- require("browser-process-hrtime");
6
-
7
- if (process && process.hrtime) {
8
- const tickOrigin = process.hrtime()[0];
9
- // clock it as a double in millisecond
10
- // so we can measure very tiny time intervals
11
- get_clock_tick = () => {
12
- const hrt = process.hrtime();
13
- const r = (hrt[0] - tickOrigin) * 1000.0 + Math.ceil((hrt[1] / 1e6) * 1000) / 1000;
14
- return r;
15
- };
16
- } else {
17
- get_clock_tick = () => Date.now();
18
- }
1
+ /**
2
+ * @module node-opcua-utils
3
+ */
4
+ export let get_clock_tick: () => number;
5
+ require("browser-process-hrtime");
6
+
7
+ if (process && process.hrtime) {
8
+ const tickOrigin = process.hrtime()[0];
9
+ // clock it as a double in millisecond
10
+ // so we can measure very tiny time intervals
11
+ get_clock_tick = () => {
12
+ const hrt = process.hrtime();
13
+ const r = (hrt[0] - tickOrigin) * 1000.0 + Math.ceil((hrt[1] / 1e6) * 1000) / 1000;
14
+ return r;
15
+ };
16
+ } else {
17
+ get_clock_tick = () => Date.now();
18
+ }
@@ -1,13 +1,15 @@
1
- /**
2
- * @module node-opcua-utils
3
- */
4
- const STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;
5
- const ARGUMENT_NAMES = /([^\s,]+)/g;
6
-
7
- // tslint:disable-next-line:ban-types
8
- export function getFunctionParameterNames(func: Function) {
9
- const fnStr = func.toString().replace(STRIP_COMMENTS, "");
10
- let result = fnStr.slice(fnStr.indexOf("(") + 1, fnStr.indexOf(")")).match(ARGUMENT_NAMES);
11
- if (result === null) { result = []; }
12
- return result;
13
- }
1
+ /**
2
+ * @module node-opcua-utils
3
+ */
4
+ const STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;
5
+ const ARGUMENT_NAMES = /([^\s,]+)/g;
6
+ import { FunctionVariadic } from "./function_variadic";
7
+
8
+ export function getFunctionParameterNames(func: FunctionVariadic): string[] {
9
+ const fnStr = func.toString().replace(STRIP_COMMENTS, "");
10
+ let result = fnStr.slice(fnStr.indexOf("(") + 1, fnStr.indexOf(")")).match(ARGUMENT_NAMES);
11
+ if (result === null) {
12
+ result = [];
13
+ }
14
+ return result;
15
+ }
package/source/index.ts CHANGED
@@ -1,46 +1,46 @@
1
- /**
2
- * @module node-opcua-utils
3
- */
4
- // tslint:disable:no-bitwise
5
- import { assert } from "node-opcua-assert";
6
-
7
- /**
8
- * set a flag
9
- * @method set_flag
10
- */
11
- export function set_flag(value: number, mask: number | { value: number }): number {
12
- if ((mask as any).value) {
13
- mask = (mask as any).value;
14
- }
15
- assert(!mask.hasOwnProperty("value"));
16
- assert(mask !== undefined);
17
- return value | (mask as number);
18
- }
19
- /**
20
- * check if a set of bits are set in the values
21
- * @method check_flag
22
- */
23
- export function check_flag(value: number, mask: number | { value: number }): boolean {
24
- if ((mask as any).value) {
25
- mask = (mask as any).value;
26
- }
27
- assert(!mask.hasOwnProperty("value"));
28
- return (value & (mask as number)) === (mask as number);
29
- }
30
-
31
- export function isNullOrUndefined(value: any): boolean {
32
- return value === undefined || value === null;
33
- }
34
-
35
- export { buffer_ellipsis } from "./buffer_ellipsis";
36
- export { capitalizeFirstLetter, lowerFirstLetter } from "./string_utils";
37
- export { getObjectClassName } from "./object_classname";
38
- export { get_clock_tick } from "./get_clock_tick";
39
- export { compare_buffers } from "./compare_buffers";
40
- export { getFunctionParameterNames } from "./get_function_parameters_name";
41
- export * from "./watchdog";
42
- export { setDeprecated } from "./set_deprecated";
43
- export { replaceBufferWithHexDump } from "./replace_buffer_with_hex_dump";
44
- export * from "./timestamp";
45
- export * from "./line_file";
46
- export * from "./match_uri";
1
+ /**
2
+ * @module node-opcua-utils
3
+ */
4
+ // tslint:disable:no-bitwise
5
+ import { assert } from "node-opcua-assert";
6
+
7
+ /**
8
+ * set a flag
9
+ * @method set_flag
10
+ */
11
+ export function set_flag(value: number, mask: number | { value: number }): number {
12
+ if ((mask as any).value) {
13
+ mask = (mask as any).value;
14
+ }
15
+ assert(!Object.prototype.hasOwnProperty.call(mask, "value"));
16
+ assert(mask !== undefined);
17
+ return value | (mask as number);
18
+ }
19
+ /**
20
+ * check if a set of bits are set in the values
21
+ * @method check_flag
22
+ */
23
+ export function check_flag(value: number, mask: number | { value: number }): boolean {
24
+ if ((mask as any).value) {
25
+ mask = (mask as any).value;
26
+ }
27
+ assert(!Object.prototype.hasOwnProperty.call(mask, "value"));
28
+ return (value & (mask as number)) === (mask as number);
29
+ }
30
+
31
+ export function isNullOrUndefined(value: unknown | undefined): boolean {
32
+ return value === undefined || value === null;
33
+ }
34
+
35
+ export { buffer_ellipsis } from "./buffer_ellipsis";
36
+ export { capitalizeFirstLetter, lowerFirstLetter } from "./string_utils";
37
+ export { getObjectClassName } from "./object_classname";
38
+ export { get_clock_tick } from "./get_clock_tick";
39
+ export { compare_buffers } from "./compare_buffers";
40
+ export { getFunctionParameterNames } from "./get_function_parameters_name";
41
+ export * from "./watchdog";
42
+ export { setDeprecated } from "./set_deprecated";
43
+ export { replaceBufferWithHexDump } from "./replace_buffer_with_hex_dump";
44
+ export * from "./timestamp";
45
+ export * from "./line_file";
46
+ export * from "./match_uri";
@@ -1,24 +1,24 @@
1
- /**
2
- * @module node-opcua-utils
3
- */
4
-
5
- export class LineFile {
6
- private _line: string[];
7
-
8
- constructor() {
9
- this._line = [];
10
- }
11
-
12
- public write(...arg: string[]): void {
13
- let str = "";
14
- // tslint:disable:prefer-for-of
15
- for (let i = 0; i < arguments.length; i++) {
16
- str += arguments[i];
17
- }
18
- this._line.push(str);
19
- }
20
-
21
- public toString(endOfLine: "\n" | "\r" = "\n"): string {
22
- return this._line.join(endOfLine);
23
- }
24
- }
1
+ /**
2
+ * @module node-opcua-utils
3
+ */
4
+
5
+ export class LineFile {
6
+ private _line: string[];
7
+
8
+ constructor() {
9
+ this._line = [];
10
+ }
11
+
12
+ public write(...args: string[]): void {
13
+ let str = "";
14
+ // tslint:disable:prefer-for-of
15
+ for (let i = 0; i < args.length; i++) {
16
+ str += args[i];
17
+ }
18
+ this._line.push(str);
19
+ }
20
+
21
+ public toString(endOfLine: "\n" | "\r" = "\n"): string {
22
+ return this._line.join(endOfLine);
23
+ }
24
+ }
@@ -1,19 +1,19 @@
1
- /**
2
- * @module node-opcua-utils
3
- */
4
- /**
5
- * returns true if two endpoint matches the same address:
6
- *
7
- * @see https://www.dnscheck.co/faq
8
- * @see https://tools.ietf.org/html/rfc4343 : Domain Name System (DNS) Case Insensitivity Clarification
9
- *
10
- */
11
- export function matchUri(endpointUri1: string | null, endpointUri2: string | null) {
12
- if (endpointUri1 === null) {
13
- return endpointUri2 === null;
14
- }
15
- if (endpointUri2 === null) {
16
- return endpointUri1 === null;
17
- }
18
- return endpointUri1.toLowerCase() === endpointUri2.toLowerCase();
19
- }
1
+ /**
2
+ * @module node-opcua-utils
3
+ */
4
+ /**
5
+ * returns true if two endpoint matches the same address:
6
+ *
7
+ * @see https://www.dnscheck.co/faq
8
+ * @see https://tools.ietf.org/html/rfc4343 : Domain Name System (DNS) Case Insensitivity Clarification
9
+ *
10
+ */
11
+ export function matchUri(endpointUri1: string | null, endpointUri2: string | null): boolean {
12
+ if (endpointUri1 === null) {
13
+ return endpointUri2 === null;
14
+ }
15
+ if (endpointUri2 === null) {
16
+ return endpointUri1 === null;
17
+ }
18
+ return endpointUri1.toLowerCase() === endpointUri2.toLowerCase();
19
+ }
@@ -1,11 +1,11 @@
1
- /**
2
- * @module node-opcua-utils
3
- */
4
- /**
5
- * @method getObjectClassName
6
- * @param obj
7
- * @return {string}
8
- */
9
- export function getObjectClassName(obj: object): string {
10
- return Object.prototype.toString.call(obj).slice(8, -1);
11
- }
1
+ /**
2
+ * @module node-opcua-utils
3
+ */
4
+ /**
5
+ * @method getObjectClassName
6
+ * @param obj
7
+ * @return {string}
8
+ */
9
+ export function getObjectClassName(obj: unknown): string {
10
+ return Object.prototype.toString.call(obj).slice(8, -1);
11
+ }
@@ -1,15 +1,15 @@
1
- /**
2
- * @module node-opcua-utils
3
- */
4
- export function replaceBufferWithHexDump(obj: any): any {
5
- for (const p in obj) {
6
- if (obj.hasOwnProperty(p)) {
7
- if (obj[p] instanceof Buffer) {
8
- obj[p] = "<BUFFER>" + obj[p].toString("hex") + "</BUFFER>";
9
- } else if (typeof obj[p] === "object") {
10
- replaceBufferWithHexDump(obj[p]);
11
- }
12
- }
13
- }
14
- return obj;
15
- }
1
+ /**
2
+ * @module node-opcua-utils
3
+ */
4
+ export function replaceBufferWithHexDump(obj: Record<string, { toString(format: string): void }>): any {
5
+ for (const p in obj) {
6
+ if (Object.prototype.hasOwnProperty.call(obj, p)) {
7
+ if (obj[p] instanceof Buffer) {
8
+ obj[p] = "<BUFFER>" + obj[p].toString("hex") + "</BUFFER>";
9
+ } else if (typeof obj[p] === "object") {
10
+ replaceBufferWithHexDump(obj[p]);
11
+ }
12
+ }
13
+ }
14
+ return obj;
15
+ }
@@ -1,28 +1,29 @@
1
- /**
2
- * @module node-opcua-utils
3
- */
4
- // tslint:disable:ban-types
5
- import * as chalk from "chalk";
6
- import { assert } from "node-opcua-assert";
7
-
8
- /* istanbul ignore next */
9
- export function setDeprecated(constructor: Function, methodName: string, helpString: string): void {
10
-
11
- const oldMethod = constructor.prototype[methodName];
12
-
13
- assert(oldMethod instanceof Function,
14
- "expecting a valid " + methodName + "method on class " + constructor.constructor.name);
15
-
16
- let counter = 0;
17
- constructor.prototype[methodName] = function() {
18
- if (counter % 1000 === 0) {
19
- // tslint:disable:no-console
20
- console.log(chalk.green("Warning !"),
21
- chalk.green(chalk.bold(constructor.name + "#" + methodName), " is now deprecated"));
22
- console.log(" ", helpString);
23
- }
24
- counter++;
25
- return oldMethod.apply(this, arguments);
26
- };
27
-
28
- }
1
+ /**
2
+ * @module node-opcua-utils
3
+ */
4
+ // tslint:disable:ban-types
5
+ import * as chalk from "chalk";
6
+ import { assert } from "node-opcua-assert";
7
+
8
+ import { FunctionVariadic } from "./function_variadic";
9
+
10
+ /* istanbul ignore next */
11
+ export function setDeprecated(constructor: FunctionVariadic, methodName: string, helpString: string): void {
12
+ const oldMethod = constructor.prototype[methodName];
13
+
14
+ assert(oldMethod instanceof Function, "expecting a valid " + methodName + "method on class " + constructor.constructor.name);
15
+
16
+ let counter = 0;
17
+ constructor.prototype[methodName] = function (...args: any[]) {
18
+ if (counter % 1000 === 0) {
19
+ // tslint:disable:no-console
20
+ console.log(
21
+ chalk.green("Warning !"),
22
+ chalk.green(chalk.bold(constructor.name + "#" + methodName), " is now deprecated")
23
+ );
24
+ console.log(" ", helpString);
25
+ }
26
+ counter++;
27
+ return oldMethod.call(this, ...args);
28
+ };
29
+ }
@@ -31,16 +31,16 @@ export function countAlphaSlow(str: string): number {
31
31
 
32
32
  export function countUpperCase(str: string): number {
33
33
  let count = 0;
34
- const n = str.length
35
- for (let i=0; i < n ; i++) {
34
+ const n = str.length;
35
+ for (let i = 0; i < n; i++) {
36
36
  count += isUpperCaseChar(str[i]) ? 1 : 0;
37
37
  }
38
38
  return count;
39
39
  }
40
40
  export function countAlpha(str: string): number {
41
41
  let count = 0;
42
- const n = str.length
43
- for (let i=0; i < n ; i++) {
42
+ const n = str.length;
43
+ for (let i = 0; i < n; i++) {
44
44
  count += isAlpha(str[i]) ? 1 : 0;
45
45
  }
46
46
  return count;
@@ -54,19 +54,19 @@ export function countAlpha(str: string): number {
54
54
  *
55
55
  * OPCUA and Javascript use two different rules to build identifiers.
56
56
  *
57
- * OPCUA Identifier usually starts with a upper case letter and word are join together, this is known as
57
+ * OPCUA Identifier usually starts with a upper case letter and word are join together, this is known as
58
58
  * the Pascal case, or CapitalizedWords convention. (for instance HelloWorld)
59
- * But sometime, OPCUA indentifiers do not follow this convention strictly and we can find various
60
- * other convention being applied such as underscore between word, or addintion of ACRONYMED prefixes.
61
- * On it's own, this causes great confusion and inconsistancy in programming style.
59
+ * But sometime, OPCUA identifiers do not follow this convention strictly and we can find various
60
+ * other convention being applied such as underscore between word, or addition of ACRONYMIC prefixes.
61
+ * On it's own, this causes great confusion and inconsistency in programming style.
62
62
  *
63
- * Javascritpt uses a slightly different convention called camelCase where word are joined together
64
- * and inner words starts with a capital letter whereas first word starts with a lower case letter.
63
+ * Javascript uses a slightly different convention called camelCase where word are joined together
64
+ * and inner words starts with a capital letter whereas first word starts with a lower case letter.
65
65
  * (for instance helloWorld)
66
66
  *
67
67
  * In node-opcua we have taken the opinionated decision to consistently use camelCase convention for
68
68
  * object properties so that all the code look nice and consistent.
69
- * the lowerFirstLetter method can be used to easily convert from the OPCUA naming convention
69
+ * the lowerFirstLetter method can be used to easily convert from the OPCUA naming convention
70
70
  * to javascript naming convention by applying the following rules.
71
71
  *
72
72
  * * each ascii sequence in a identifier will be converted to lower camel case.
@@ -110,7 +110,7 @@ export function lowerFirstLetter(str: string): string {
110
110
  return str;
111
111
  }
112
112
 
113
- if (str.match(/\_/)) {
113
+ if (str.match(/_/)) {
114
114
  return str.split("_").map(lowerFirstLetter).join("_");
115
115
  }
116
116
  let result = str.substr(0, 1).toLowerCase() + str.substr(1);
@@ -1,15 +1,11 @@
1
- function w(s: string | number, length: number): string {
2
- return ("000" + s).substr(-length);
3
- }
4
-
5
- function t(d: Date): string {
6
- return w(d.getUTCHours(), 2) + ":"
7
- + w(d.getUTCMinutes(), 2) + ":"
8
- + w(d.getUTCSeconds(), 2) + ":"
9
- + w(d.getMilliseconds(), 3);
10
- }
11
-
12
- export function timestamp() {
13
- return t(new Date());
14
- }
15
-
1
+ function w(s: string | number, length: number): string {
2
+ return ("000" + s).substr(-length);
3
+ }
4
+
5
+ function t(d: Date): string {
6
+ return w(d.getUTCHours(), 2) + ":" + w(d.getUTCMinutes(), 2) + ":" + w(d.getUTCSeconds(), 2) + ":" + w(d.getMilliseconds(), 3);
7
+ }
8
+
9
+ export function timestamp(): string {
10
+ return t(new Date());
11
+ }
@@ -1,200 +1,200 @@
1
- /**
2
- * @module node-opcua-utils
3
- */
4
- import { EventEmitter } from "events";
5
- import { assert } from "node-opcua-assert";
6
-
7
- type ArbitraryClockTick = number; // in millisecond
8
- type DurationInMillisecond = number;
9
-
10
- /**
11
- * a arbitrary clock which is system dependant and
12
- * insensible to clock drifts ....
13
- *
14
- */
15
- function _getCurrentSystemTick(): ArbitraryClockTick {
16
- if (process && process.hrtime) {
17
- const h = process.hrtime();
18
- const n = h[1] / 1000000;
19
- assert(n <= 1000);
20
- return h[0] * 1000 + n;
21
- } else {
22
- // fallback to Date as process.hrtime doesn't exit
23
- return Date.now();
24
- }
25
- }
26
-
27
- export interface IWatchdogData2 {
28
- key: number;
29
- subscriber: ISubscriber;
30
- timeout: DurationInMillisecond;
31
- lastSeen: ArbitraryClockTick;
32
- visitCount: number;
33
- }
34
-
35
- export interface ISubscriber {
36
- _watchDog?: WatchDog;
37
- _watchDogData?: IWatchdogData2;
38
-
39
- watchdogReset: () => void;
40
- keepAlive?: () => void;
41
- onClientSeen?: () => void;
42
- }
43
-
44
- function hasExpired(watchDogData: IWatchdogData2, currentTime: ArbitraryClockTick) {
45
- const elapsedTime = currentTime - watchDogData.lastSeen;
46
- return elapsedTime > watchDogData.timeout;
47
- }
48
-
49
- function keepAliveFunc(this: ISubscriber) {
50
- assert(this._watchDog instanceof WatchDog);
51
- // istanbul ignore next
52
- if (!this._watchDogData || !this._watchDog) {
53
- throw new Error("Internal error");
54
- }
55
- assert(typeof this._watchDogData.key === "number");
56
- this._watchDogData.lastSeen = this._watchDog.getCurrentSystemTick();
57
- if (this.onClientSeen) {
58
- this.onClientSeen();
59
- }
60
- }
61
-
62
- export class WatchDog extends EventEmitter {
63
- static emptyKeepAlive = () => {
64
- /* */
65
- };
66
- /**
67
- * returns the number of subscribers using the WatchDog object.
68
- */
69
- get subscriberCount(): number {
70
- return Object.keys(this._watchdogDataMap).length;
71
- }
72
-
73
- private readonly _watchdogDataMap: { [id: number]: IWatchdogData2 };
74
- private _counter: number;
75
- private _currentTime: ArbitraryClockTick;
76
- private _timer: NodeJS.Timer | null;
77
- private readonly _visitSubscriberB: (...args: any[]) => void;
78
-
79
- constructor() {
80
- super();
81
-
82
- this._watchdogDataMap = {};
83
- this._counter = 0;
84
- this._currentTime = this.getCurrentSystemTick();
85
- this._visitSubscriberB = this._visit_subscriber.bind(this);
86
- this._timer = null; // as NodeJS.Timer;
87
- }
88
-
89
- /**
90
- * add a subscriber to the WatchDog.
91
- * @method addSubscriber
92
- *
93
- * add a subscriber to the WatchDog.
94
- *
95
- * This method modifies the subscriber be adding a
96
- * new method to it called 'keepAlive'
97
- * The subscriber must also provide a "watchdogReset". watchdogReset will be called
98
- * if the subscriber failed to call keepAlive withing the timeout period.
99
- * @param subscriber
100
- * @param timeout
101
- * @return the numerical key associated with this subscriber
102
- */
103
- public addSubscriber(subscriber: ISubscriber, timeout: number): number {
104
- this._currentTime = this.getCurrentSystemTick();
105
- timeout = timeout || 1000;
106
- assert(typeof timeout === "number", " invalid timeout ");
107
- assert(typeof subscriber.watchdogReset === "function", " the subscriber must provide a watchdogReset method ");
108
- assert(typeof subscriber.keepAlive !== "function" || subscriber.keepAlive === WatchDog.emptyKeepAlive);
109
-
110
- this._counter += 1;
111
- const key = this._counter;
112
-
113
- subscriber._watchDog = this;
114
- subscriber._watchDogData = {
115
- key,
116
- lastSeen: this._currentTime,
117
- subscriber,
118
- timeout,
119
- visitCount: 0
120
- } as IWatchdogData2;
121
-
122
- this._watchdogDataMap[key] = subscriber._watchDogData;
123
-
124
- if (subscriber.onClientSeen) {
125
- subscriber.onClientSeen();
126
- }
127
-
128
- subscriber.keepAlive = keepAliveFunc.bind(subscriber);
129
-
130
- // start timer when the first subscriber comes in
131
- if (this.subscriberCount === 1) {
132
- assert(this._timer === null);
133
- this._start_timer();
134
- }
135
- assert(this._timer !== null);
136
- return key;
137
- }
138
-
139
- public removeSubscriber(subscriber: ISubscriber) {
140
- if (!subscriber._watchDog) {
141
- return; // already removed !!!
142
- }
143
- if (!subscriber._watchDogData) {
144
- throw new Error("Internal error");
145
- }
146
-
147
- assert(subscriber._watchDog instanceof WatchDog);
148
- assert(typeof subscriber._watchDogData.key === "number");
149
- assert(typeof subscriber.keepAlive === "function");
150
- assert(this._watchdogDataMap.hasOwnProperty(subscriber._watchDogData.key));
151
-
152
- delete this._watchdogDataMap[subscriber._watchDogData.key];
153
- delete subscriber._watchDog;
154
- delete subscriber._watchDogData;
155
- subscriber.keepAlive = WatchDog.emptyKeepAlive;
156
-
157
- // delete timer when the last subscriber comes out
158
- if (this.subscriberCount === 0) {
159
- this._stop_timer();
160
- }
161
- }
162
-
163
- public shutdown(): void {
164
- assert(this._timer === null && Object.keys(this._watchdogDataMap).length === 0, " leaking subscriber in watchdog");
165
- }
166
-
167
- public getCurrentSystemTick(): ArbitraryClockTick {
168
- return _getCurrentSystemTick();
169
- }
170
-
171
- private _visit_subscriber() {
172
- this._currentTime = this.getCurrentSystemTick();
173
-
174
- const expiredSubscribers = Object.values(this._watchdogDataMap).filter((watchDogData: IWatchdogData2) => {
175
- watchDogData.visitCount += 1;
176
- return hasExpired(watchDogData, this._currentTime);
177
- });
178
-
179
- if (expiredSubscribers.length) {
180
- this.emit("timeout", expiredSubscribers);
181
- }
182
- expiredSubscribers.forEach((watchDogData: IWatchdogData2) => {
183
- this.removeSubscriber(watchDogData.subscriber);
184
- watchDogData.subscriber.watchdogReset();
185
- });
186
- }
187
-
188
- private _start_timer(): void {
189
- assert(this._timer === null, " setInterval already called ?");
190
- this._timer = setInterval(this._visitSubscriberB, 1000);
191
- }
192
-
193
- private _stop_timer(): void {
194
- assert(this._timer !== null, "_stop_timer already called ?");
195
- if (this._timer !== null) {
196
- clearInterval(this._timer);
197
- this._timer = null;
198
- }
199
- }
200
- }
1
+ /**
2
+ * @module node-opcua-utils
3
+ */
4
+ import { EventEmitter } from "events";
5
+ import { assert } from "node-opcua-assert";
6
+
7
+ type ArbitraryClockTick = number; // in millisecond
8
+ type DurationInMillisecond = number;
9
+
10
+ /**
11
+ * a arbitrary clock which is system dependant and
12
+ * insensible to clock drifts ....
13
+ *
14
+ */
15
+ function _getCurrentSystemTick(): ArbitraryClockTick {
16
+ if (process && process.hrtime) {
17
+ const h = process.hrtime();
18
+ const n = h[1] / 1000000;
19
+ assert(n <= 1000);
20
+ return h[0] * 1000 + n;
21
+ } else {
22
+ // fallback to Date as process.hrtime doesn't exit
23
+ return Date.now();
24
+ }
25
+ }
26
+
27
+ export interface IWatchdogData2 {
28
+ key: number;
29
+ subscriber: ISubscriber;
30
+ timeout: DurationInMillisecond;
31
+ lastSeen: ArbitraryClockTick;
32
+ visitCount: number;
33
+ }
34
+
35
+ export interface ISubscriber {
36
+ _watchDog?: WatchDog;
37
+ _watchDogData?: IWatchdogData2;
38
+
39
+ watchdogReset: () => void;
40
+ keepAlive?: () => void;
41
+ onClientSeen?: () => void;
42
+ }
43
+
44
+ function hasExpired(watchDogData: IWatchdogData2, currentTime: ArbitraryClockTick) {
45
+ const elapsedTime = currentTime - watchDogData.lastSeen;
46
+ return elapsedTime > watchDogData.timeout;
47
+ }
48
+
49
+ function keepAliveFunc(this: ISubscriber) {
50
+ assert(this._watchDog instanceof WatchDog);
51
+ // istanbul ignore next
52
+ if (!this._watchDogData || !this._watchDog) {
53
+ throw new Error("Internal error");
54
+ }
55
+ assert(typeof this._watchDogData.key === "number");
56
+ this._watchDogData.lastSeen = this._watchDog.getCurrentSystemTick();
57
+ if (this.onClientSeen) {
58
+ this.onClientSeen();
59
+ }
60
+ }
61
+
62
+ export class WatchDog extends EventEmitter {
63
+ static emptyKeepAlive = (): void => {
64
+ /* */
65
+ };
66
+ /**
67
+ * returns the number of subscribers using the WatchDog object.
68
+ */
69
+ get subscriberCount(): number {
70
+ return Object.keys(this._watchdogDataMap).length;
71
+ }
72
+
73
+ private readonly _watchdogDataMap: { [id: number]: IWatchdogData2 };
74
+ private _counter: number;
75
+ private _currentTime: ArbitraryClockTick;
76
+ private _timer: NodeJS.Timer | null;
77
+ private readonly _visitSubscriberB: (...args: any[]) => void;
78
+
79
+ constructor() {
80
+ super();
81
+
82
+ this._watchdogDataMap = {};
83
+ this._counter = 0;
84
+ this._currentTime = this.getCurrentSystemTick();
85
+ this._visitSubscriberB = this._visit_subscriber.bind(this);
86
+ this._timer = null; // as NodeJS.Timer;
87
+ }
88
+
89
+ /**
90
+ * add a subscriber to the WatchDog.
91
+ * @method addSubscriber
92
+ *
93
+ * add a subscriber to the WatchDog.
94
+ *
95
+ * This method modifies the subscriber be adding a
96
+ * new method to it called 'keepAlive'
97
+ * The subscriber must also provide a "watchdogReset". watchdogReset will be called
98
+ * if the subscriber failed to call keepAlive withing the timeout period.
99
+ * @param subscriber
100
+ * @param timeout
101
+ * @return the numerical key associated with this subscriber
102
+ */
103
+ public addSubscriber(subscriber: ISubscriber, timeout: number): number {
104
+ this._currentTime = this.getCurrentSystemTick();
105
+ timeout = timeout || 1000;
106
+ assert(typeof timeout === "number", " invalid timeout ");
107
+ assert(typeof subscriber.watchdogReset === "function", " the subscriber must provide a watchdogReset method ");
108
+ assert(typeof subscriber.keepAlive !== "function" || subscriber.keepAlive === WatchDog.emptyKeepAlive);
109
+
110
+ this._counter += 1;
111
+ const key = this._counter;
112
+
113
+ subscriber._watchDog = this;
114
+ subscriber._watchDogData = {
115
+ key,
116
+ lastSeen: this._currentTime,
117
+ subscriber,
118
+ timeout,
119
+ visitCount: 0
120
+ } as IWatchdogData2;
121
+
122
+ this._watchdogDataMap[key] = subscriber._watchDogData;
123
+
124
+ if (subscriber.onClientSeen) {
125
+ subscriber.onClientSeen();
126
+ }
127
+
128
+ subscriber.keepAlive = keepAliveFunc.bind(subscriber);
129
+
130
+ // start timer when the first subscriber comes in
131
+ if (this.subscriberCount === 1) {
132
+ assert(this._timer === null);
133
+ this._start_timer();
134
+ }
135
+ assert(this._timer !== null);
136
+ return key;
137
+ }
138
+
139
+ public removeSubscriber(subscriber: ISubscriber): void {
140
+ if (!subscriber._watchDog) {
141
+ return; // already removed !!!
142
+ }
143
+ if (!subscriber._watchDogData) {
144
+ throw new Error("Internal error");
145
+ }
146
+
147
+ assert(subscriber._watchDog instanceof WatchDog);
148
+ assert(typeof subscriber._watchDogData.key === "number");
149
+ assert(typeof subscriber.keepAlive === "function");
150
+ assert(Object.prototype.hasOwnProperty.call(this._watchdogDataMap, subscriber._watchDogData.key));
151
+
152
+ delete this._watchdogDataMap[subscriber._watchDogData.key];
153
+ delete subscriber._watchDog;
154
+ delete subscriber._watchDogData;
155
+ subscriber.keepAlive = WatchDog.emptyKeepAlive;
156
+
157
+ // delete timer when the last subscriber comes out
158
+ if (this.subscriberCount === 0) {
159
+ this._stop_timer();
160
+ }
161
+ }
162
+
163
+ public shutdown(): void {
164
+ assert(this._timer === null && Object.keys(this._watchdogDataMap).length === 0, " leaking subscriber in watchdog");
165
+ }
166
+
167
+ public getCurrentSystemTick(): ArbitraryClockTick {
168
+ return _getCurrentSystemTick();
169
+ }
170
+
171
+ private _visit_subscriber() {
172
+ this._currentTime = this.getCurrentSystemTick();
173
+
174
+ const expiredSubscribers = Object.values(this._watchdogDataMap).filter((watchDogData: IWatchdogData2) => {
175
+ watchDogData.visitCount += 1;
176
+ return hasExpired(watchDogData, this._currentTime);
177
+ });
178
+
179
+ if (expiredSubscribers.length) {
180
+ this.emit("timeout", expiredSubscribers);
181
+ }
182
+ expiredSubscribers.forEach((watchDogData: IWatchdogData2) => {
183
+ this.removeSubscriber(watchDogData.subscriber);
184
+ watchDogData.subscriber.watchdogReset();
185
+ });
186
+ }
187
+
188
+ private _start_timer(): void {
189
+ assert(this._timer === null, " setInterval already called ?");
190
+ this._timer = setInterval(this._visitSubscriberB, 1000);
191
+ }
192
+
193
+ private _stop_timer(): void {
194
+ assert(this._timer !== null, "_stop_timer already called ?");
195
+ if (this._timer !== null) {
196
+ clearInterval(this._timer);
197
+ this._timer = null;
198
+ }
199
+ }
200
+ }