node-opcua-utils
Advanced tools
Comparing version 2.55.0 to 2.56.0
@@ -1,1 +0,2 @@ | ||
export declare function getFunctionParameterNames(func: Function): RegExpMatchArray; | ||
import { FunctionVariadic } from "./function_variadic"; | ||
export declare function getFunctionParameterNames(func: FunctionVariadic): string[]; |
@@ -9,3 +9,2 @@ "use strict"; | ||
const ARGUMENT_NAMES = /([^\s,]+)/g; | ||
// tslint:disable-next-line:ban-types | ||
function getFunctionParameterNames(func) { | ||
@@ -12,0 +11,0 @@ const fnStr = func.toString().replace(STRIP_COMMENTS, ""); |
@@ -15,3 +15,3 @@ /** | ||
}): boolean; | ||
export declare function isNullOrUndefined(value: any): boolean; | ||
export declare function isNullOrUndefined(value: unknown | undefined): boolean; | ||
export { buffer_ellipsis } from "./buffer_ellipsis"; | ||
@@ -18,0 +18,0 @@ export { capitalizeFirstLetter, lowerFirstLetter } from "./string_utils"; |
@@ -27,3 +27,3 @@ "use strict"; | ||
} | ||
(0, node_opcua_assert_1.assert)(!mask.hasOwnProperty("value")); | ||
(0, node_opcua_assert_1.assert)(!Object.prototype.hasOwnProperty.call(mask, "value")); | ||
(0, node_opcua_assert_1.assert)(mask !== undefined); | ||
@@ -41,3 +41,3 @@ return value | mask; | ||
} | ||
(0, node_opcua_assert_1.assert)(!mask.hasOwnProperty("value")); | ||
(0, node_opcua_assert_1.assert)(!Object.prototype.hasOwnProperty.call(mask, "value")); | ||
return (value & mask) === mask; | ||
@@ -44,0 +44,0 @@ } |
@@ -7,4 +7,4 @@ /** | ||
constructor(); | ||
write(...arg: string[]): void; | ||
write(...args: string[]): void; | ||
toString(endOfLine?: "\n" | "\r"): string; | ||
} |
@@ -11,7 +11,7 @@ "use strict"; | ||
} | ||
write(...arg) { | ||
write(...args) { | ||
let str = ""; | ||
// tslint:disable:prefer-for-of | ||
for (let i = 0; i < arguments.length; i++) { | ||
str += arguments[i]; | ||
for (let i = 0; i < args.length; i++) { | ||
str += args[i]; | ||
} | ||
@@ -18,0 +18,0 @@ this._line.push(str); |
@@ -9,2 +9,2 @@ /** | ||
*/ | ||
export declare function getObjectClassName(obj: object): string; | ||
export declare function getObjectClassName(obj: unknown): string; |
/** | ||
* @module node-opcua-utils | ||
*/ | ||
export declare function replaceBufferWithHexDump(obj: any): any; | ||
export declare function replaceBufferWithHexDump(obj: Record<string, { | ||
toString(format: string): void; | ||
}>): any; |
@@ -9,3 +9,3 @@ "use strict"; | ||
for (const p in obj) { | ||
if (obj.hasOwnProperty(p)) { | ||
if (Object.prototype.hasOwnProperty.call(obj, p)) { | ||
if (obj[p] instanceof Buffer) { | ||
@@ -12,0 +12,0 @@ obj[p] = "<BUFFER>" + obj[p].toString("hex") + "</BUFFER>"; |
@@ -1,1 +0,2 @@ | ||
export declare function setDeprecated(constructor: Function, methodName: string, helpString: string): void; | ||
import { FunctionVariadic } from "./function_variadic"; | ||
export declare function setDeprecated(constructor: FunctionVariadic, methodName: string, helpString: string): void; |
@@ -15,3 +15,3 @@ "use strict"; | ||
let counter = 0; | ||
constructor.prototype[methodName] = function () { | ||
constructor.prototype[methodName] = function (...args) { | ||
if (counter % 1000 === 0) { | ||
@@ -23,3 +23,3 @@ // tslint:disable:no-console | ||
counter++; | ||
return oldMethod.apply(this, arguments); | ||
return oldMethod.call(this, ...args); | ||
}; | ||
@@ -26,0 +26,0 @@ } |
@@ -21,7 +21,7 @@ /** | ||
* the Pascal case, or CapitalizedWords convention. (for instance HelloWorld) | ||
* But sometime, OPCUA indentifiers do not follow this convention strictly and we can find various | ||
* other convention being applied such as underscore between word, or addintion of ACRONYMED prefixes. | ||
* On it's own, this causes great confusion and inconsistancy in programming style. | ||
* But sometime, OPCUA identifiers do not follow this convention strictly and we can find various | ||
* other convention being applied such as underscore between word, or addition of ACRONYMIC prefixes. | ||
* On it's own, this causes great confusion and inconsistency in programming style. | ||
* | ||
* Javascritpt uses a slightly different convention called camelCase where word are joined together | ||
* Javascript uses a slightly different convention called camelCase where word are joined together | ||
* and inner words starts with a capital letter whereas first word starts with a lower case letter. | ||
@@ -28,0 +28,0 @@ * (for instance helloWorld) |
@@ -65,7 +65,7 @@ "use strict"; | ||
* the Pascal case, or CapitalizedWords convention. (for instance HelloWorld) | ||
* But sometime, OPCUA indentifiers do not follow this convention strictly and we can find various | ||
* other convention being applied such as underscore between word, or addintion of ACRONYMED prefixes. | ||
* On it's own, this causes great confusion and inconsistancy in programming style. | ||
* But sometime, OPCUA identifiers do not follow this convention strictly and we can find various | ||
* other convention being applied such as underscore between word, or addition of ACRONYMIC prefixes. | ||
* On it's own, this causes great confusion and inconsistency in programming style. | ||
* | ||
* Javascritpt uses a slightly different convention called camelCase where word are joined together | ||
* Javascript uses a slightly different convention called camelCase where word are joined together | ||
* and inner words starts with a capital letter whereas first word starts with a lower case letter. | ||
@@ -119,3 +119,3 @@ * (for instance helloWorld) | ||
} | ||
if (str.match(/\_/)) { | ||
if (str.match(/_/)) { | ||
return str.split("_").map(lowerFirstLetter).join("_"); | ||
@@ -122,0 +122,0 @@ } |
@@ -8,6 +8,3 @@ "use strict"; | ||
function t(d) { | ||
return w(d.getUTCHours(), 2) + ":" | ||
+ w(d.getUTCMinutes(), 2) + ":" | ||
+ w(d.getUTCSeconds(), 2) + ":" | ||
+ w(d.getMilliseconds(), 3); | ||
return w(d.getUTCHours(), 2) + ":" + w(d.getUTCMinutes(), 2) + ":" + w(d.getUTCSeconds(), 2) + ":" + w(d.getMilliseconds(), 3); | ||
} | ||
@@ -14,0 +11,0 @@ function timestamp() { |
@@ -110,3 +110,3 @@ "use strict"; | ||
(0, node_opcua_assert_1.assert)(typeof subscriber.keepAlive === "function"); | ||
(0, node_opcua_assert_1.assert)(this._watchdogDataMap.hasOwnProperty(subscriber._watchDogData.key)); | ||
(0, node_opcua_assert_1.assert)(Object.prototype.hasOwnProperty.call(this._watchdogDataMap, subscriber._watchDogData.key)); | ||
delete this._watchdogDataMap[subscriber._watchDogData.key]; | ||
@@ -113,0 +113,0 @@ delete subscriber._watchDog; |
{ | ||
"name": "node-opcua-utils", | ||
"version": "2.55.0", | ||
"version": "2.56.0", | ||
"description": "pure nodejs OPCUA SDK - module -utils", | ||
@@ -9,2 +9,4 @@ "main": "./dist/index.js", | ||
"build": "tsc -b", | ||
"lint": "eslint source test", | ||
"format": "prettier --write source test", | ||
"test": "mocha", | ||
@@ -38,3 +40,3 @@ "clean": "node -e \"require('rimraf').sync('dist');\"" | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "28fdbfe1c5306fd0e69758ccacfa2c6d1722115c" | ||
"gitHead": "9f6eac1c658c0d182fbe03cf58f799af468615eb" | ||
} |
@@ -0,0 +0,0 @@ /** |
@@ -6,9 +6,11 @@ /** | ||
const ARGUMENT_NAMES = /([^\s,]+)/g; | ||
import { FunctionVariadic } from "./function_variadic"; | ||
// tslint:disable-next-line:ban-types | ||
export function getFunctionParameterNames(func: Function) { | ||
export function getFunctionParameterNames(func: FunctionVariadic): string[] { | ||
const fnStr = func.toString().replace(STRIP_COMMENTS, ""); | ||
let result = fnStr.slice(fnStr.indexOf("(") + 1, fnStr.indexOf(")")).match(ARGUMENT_NAMES); | ||
if (result === null) { result = []; } | ||
if (result === null) { | ||
result = []; | ||
} | ||
return result; | ||
} |
@@ -15,3 +15,3 @@ /** | ||
} | ||
assert(!mask.hasOwnProperty("value")); | ||
assert(!Object.prototype.hasOwnProperty.call(mask, "value")); | ||
assert(mask !== undefined); | ||
@@ -28,7 +28,7 @@ return value | (mask as number); | ||
} | ||
assert(!mask.hasOwnProperty("value")); | ||
assert(!Object.prototype.hasOwnProperty.call(mask, "value")); | ||
return (value & (mask as number)) === (mask as number); | ||
} | ||
export function isNullOrUndefined(value: any): boolean { | ||
export function isNullOrUndefined(value: unknown | undefined): boolean { | ||
return value === undefined || value === null; | ||
@@ -35,0 +35,0 @@ } |
@@ -12,7 +12,7 @@ /** | ||
public write(...arg: string[]): void { | ||
public write(...args: string[]): void { | ||
let str = ""; | ||
// tslint:disable:prefer-for-of | ||
for (let i = 0; i < arguments.length; i++) { | ||
str += arguments[i]; | ||
for (let i = 0; i < args.length; i++) { | ||
str += args[i]; | ||
} | ||
@@ -19,0 +19,0 @@ this._line.push(str); |
@@ -11,3 +11,3 @@ /** | ||
*/ | ||
export function matchUri(endpointUri1: string | null, endpointUri2: string | null) { | ||
export function matchUri(endpointUri1: string | null, endpointUri2: string | null): boolean { | ||
if (endpointUri1 === null) { | ||
@@ -14,0 +14,0 @@ return endpointUri2 === null; |
@@ -9,4 +9,4 @@ /** | ||
*/ | ||
export function getObjectClassName(obj: object): string { | ||
export function getObjectClassName(obj: unknown): string { | ||
return Object.prototype.toString.call(obj).slice(8, -1); | ||
} |
/** | ||
* @module node-opcua-utils | ||
*/ | ||
export function replaceBufferWithHexDump(obj: any): any { | ||
export function replaceBufferWithHexDump(obj: Record<string, { toString(format: string): void }>): any { | ||
for (const p in obj) { | ||
if (obj.hasOwnProperty(p)) { | ||
if (Object.prototype.hasOwnProperty.call(obj, p)) { | ||
if (obj[p] instanceof Buffer) { | ||
@@ -8,0 +8,0 @@ obj[p] = "<BUFFER>" + obj[p].toString("hex") + "</BUFFER>"; |
@@ -8,22 +8,23 @@ /** | ||
import { FunctionVariadic } from "./function_variadic"; | ||
/* istanbul ignore next */ | ||
export function setDeprecated(constructor: Function, methodName: string, helpString: string): void { | ||
export function setDeprecated(constructor: FunctionVariadic, methodName: string, helpString: string): void { | ||
const oldMethod = constructor.prototype[methodName]; | ||
assert(oldMethod instanceof Function, | ||
"expecting a valid " + methodName + "method on class " + constructor.constructor.name); | ||
assert(oldMethod instanceof Function, "expecting a valid " + methodName + "method on class " + constructor.constructor.name); | ||
let counter = 0; | ||
constructor.prototype[methodName] = function() { | ||
constructor.prototype[methodName] = function (...args: any[]) { | ||
if (counter % 1000 === 0) { | ||
// tslint:disable:no-console | ||
console.log(chalk.green("Warning !"), | ||
chalk.green(chalk.bold(constructor.name + "#" + methodName), " is now deprecated")); | ||
console.log( | ||
chalk.green("Warning !"), | ||
chalk.green(chalk.bold(constructor.name + "#" + methodName), " is now deprecated") | ||
); | ||
console.log(" ", helpString); | ||
} | ||
counter++; | ||
return oldMethod.apply(this, arguments); | ||
return oldMethod.call(this, ...args); | ||
}; | ||
} |
@@ -34,4 +34,4 @@ /** | ||
let count = 0; | ||
const n = str.length | ||
for (let i=0; i < n ; i++) { | ||
const n = str.length; | ||
for (let i = 0; i < n; i++) { | ||
count += isUpperCaseChar(str[i]) ? 1 : 0; | ||
@@ -43,4 +43,4 @@ } | ||
let count = 0; | ||
const n = str.length | ||
for (let i=0; i < n ; i++) { | ||
const n = str.length; | ||
for (let i = 0; i < n; i++) { | ||
count += isAlpha(str[i]) ? 1 : 0; | ||
@@ -59,10 +59,10 @@ } | ||
* | ||
* OPCUA Identifier usually starts with a upper case letter and word are join together, this is known as | ||
* OPCUA Identifier usually starts with a upper case letter and word are join together, this is known as | ||
* the Pascal case, or CapitalizedWords convention. (for instance HelloWorld) | ||
* But sometime, OPCUA indentifiers do not follow this convention strictly and we can find various | ||
* other convention being applied such as underscore between word, or addintion of ACRONYMED prefixes. | ||
* On it's own, this causes great confusion and inconsistancy in programming style. | ||
* But sometime, OPCUA identifiers do not follow this convention strictly and we can find various | ||
* other convention being applied such as underscore between word, or addition of ACRONYMIC prefixes. | ||
* On it's own, this causes great confusion and inconsistency in programming style. | ||
* | ||
* Javascritpt uses a slightly different convention called camelCase where word are joined together | ||
* and inner words starts with a capital letter whereas first word starts with a lower case letter. | ||
* Javascript uses a slightly different convention called camelCase where word are joined together | ||
* and inner words starts with a capital letter whereas first word starts with a lower case letter. | ||
* (for instance helloWorld) | ||
@@ -72,3 +72,3 @@ * | ||
* object properties so that all the code look nice and consistent. | ||
* the lowerFirstLetter method can be used to easily convert from the OPCUA naming convention | ||
* the lowerFirstLetter method can be used to easily convert from the OPCUA naming convention | ||
* to javascript naming convention by applying the following rules. | ||
@@ -117,3 +117,3 @@ * | ||
if (str.match(/\_/)) { | ||
if (str.match(/_/)) { | ||
return str.split("_").map(lowerFirstLetter).join("_"); | ||
@@ -120,0 +120,0 @@ } |
@@ -6,11 +6,7 @@ function w(s: string | number, length: number): string { | ||
function t(d: Date): string { | ||
return w(d.getUTCHours(), 2) + ":" | ||
+ w(d.getUTCMinutes(), 2) + ":" | ||
+ w(d.getUTCSeconds(), 2) + ":" | ||
+ w(d.getMilliseconds(), 3); | ||
return w(d.getUTCHours(), 2) + ":" + w(d.getUTCMinutes(), 2) + ":" + w(d.getUTCSeconds(), 2) + ":" + w(d.getMilliseconds(), 3); | ||
} | ||
export function timestamp() { | ||
export function timestamp(): string { | ||
return t(new Date()); | ||
} | ||
@@ -63,3 +63,3 @@ /** | ||
export class WatchDog extends EventEmitter { | ||
static emptyKeepAlive = () => { | ||
static emptyKeepAlive = (): void => { | ||
/* */ | ||
@@ -140,3 +140,3 @@ }; | ||
public removeSubscriber(subscriber: ISubscriber) { | ||
public removeSubscriber(subscriber: ISubscriber): void { | ||
if (!subscriber._watchDog) { | ||
@@ -152,3 +152,3 @@ return; // already removed !!! | ||
assert(typeof subscriber.keepAlive === "function"); | ||
assert(this._watchdogDataMap.hasOwnProperty(subscriber._watchDogData.key)); | ||
assert(Object.prototype.hasOwnProperty.call(this._watchdogDataMap, subscriber._watchDogData.key)); | ||
@@ -155,0 +155,0 @@ delete this._watchdogDataMap[subscriber._watchDogData.key]; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64910
59
1244