node-opcua-utils 2.51.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.
- package/.mocharc.yml +10 -0
- package/LICENSE +20 -0
- package/dist/buffer_ellipsis.d.ts +5 -0
- package/dist/buffer_ellipsis.js +17 -0
- package/dist/buffer_ellipsis.js.map +1 -0
- package/dist/compare_buffers.d.ts +2 -0
- package/dist/compare_buffers.js +27 -0
- package/dist/compare_buffers.js.map +1 -0
- package/dist/get_clock_tick.d.ts +4 -0
- package/dist/get_clock_tick.js +18 -0
- package/dist/get_clock_tick.js.map +1 -0
- package/dist/get_function_parameters_name.d.ts +1 -0
- package/dist/get_function_parameters_name.js +19 -0
- package/dist/get_function_parameters_name.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +69 -0
- package/dist/index.js.map +1 -0
- package/dist/line_file.d.ts +9 -0
- package/dist/line_file.js +24 -0
- package/dist/line_file.js.map +1 -0
- package/dist/match_uri.d.ts +11 -0
- package/dist/match_uri.js +24 -0
- package/dist/match_uri.js.map +1 -0
- package/dist/object_classname.d.ts +9 -0
- package/dist/object_classname.js +16 -0
- package/dist/object_classname.js.map +1 -0
- package/dist/replace_buffer_with_hex_dump.d.ts +4 -0
- package/dist/replace_buffer_with_hex_dump.js +21 -0
- package/dist/replace_buffer_with_hex_dump.js.map +1 -0
- package/dist/set_deprecated.d.ts +1 -0
- package/dist/set_deprecated.js +26 -0
- package/dist/set_deprecated.js.map +1 -0
- package/dist/string_utils.d.ts +66 -0
- package/dist/string_utils.js +128 -0
- package/dist/string_utils.js.map +1 -0
- package/dist/timestamp.d.ts +1 -0
- package/dist/timestamp.js +17 -0
- package/dist/timestamp.js.map +1 -0
- package/dist/watchdog.d.ts +56 -0
- package/dist/watchdog.js +156 -0
- package/dist/watchdog.js.map +1 -0
- package/package.json +38 -0
- package/source/buffer_ellipsis.ts +13 -0
- package/source/compare_buffers.ts +23 -0
- package/source/get_clock_tick.ts +18 -0
- package/source/get_function_parameters_name.ts +13 -0
- package/source/index.ts +46 -0
- package/source/line_file.ts +24 -0
- package/source/match_uri.ts +19 -0
- package/source/object_classname.ts +11 -0
- package/source/replace_buffer_with_hex_dump.ts +15 -0
- package/source/set_deprecated.ts +28 -0
- package/source/string_utils.ts +121 -0
- package/source/timestamp.ts +15 -0
- package/source/watchdog.ts +200 -0
package/.mocharc.yml
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014-2021 Etienne Rossignon
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
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, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buffer_ellipsis = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module node-opcua-utils
|
|
6
|
+
*/
|
|
7
|
+
function buffer_ellipsis(buffer, start, end) {
|
|
8
|
+
start = start || 0;
|
|
9
|
+
end = end || buffer.length;
|
|
10
|
+
if (end - start < 40) {
|
|
11
|
+
return buffer.slice(start, end).toString("hex");
|
|
12
|
+
}
|
|
13
|
+
return buffer.slice(start, start + 10).toString("hex") + " ... " + buffer.slice(end - 10, end).toString("hex");
|
|
14
|
+
}
|
|
15
|
+
exports.buffer_ellipsis = buffer_ellipsis;
|
|
16
|
+
exports.buffer_ellipsis = buffer_ellipsis;
|
|
17
|
+
//# sourceMappingURL=buffer_ellipsis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer_ellipsis.js","sourceRoot":"","sources":["../source/buffer_ellipsis.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,SAAgB,eAAe,CAAC,MAAc,EAAE,KAAc,EAAE,GAAY;IACxE,KAAK,GAAG,KAAK,IAAI,CAAC,CAAC;IACnB,GAAG,GAAG,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC;IAC3B,IAAI,GAAG,GAAG,KAAK,GAAG,EAAE,EAAE;QAClB,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;KACnD;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACnH,CAAC;AAPD,0CAOC;AAED,OAAO,CAAC,eAAe,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compare_buffers = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module node-opcua-utils
|
|
6
|
+
*/
|
|
7
|
+
// tslint:disable:no-console
|
|
8
|
+
const chalk = require("chalk");
|
|
9
|
+
const buffer_ellipsis_1 = require("./buffer_ellipsis");
|
|
10
|
+
function compare_buffers(buf1, buf2, max_length) {
|
|
11
|
+
max_length = max_length || buf2.length;
|
|
12
|
+
const block_length = 80;
|
|
13
|
+
let cursor = 0;
|
|
14
|
+
while (cursor < max_length) {
|
|
15
|
+
const slice1 = buf1.slice(cursor, cursor + block_length);
|
|
16
|
+
const slice2 = buf2.slice(cursor, cursor + block_length);
|
|
17
|
+
if (slice2.toString("hex") !== slice1.toString("hex")) {
|
|
18
|
+
console.log("pos = ", cursor);
|
|
19
|
+
console.log("slice1 :", chalk.yellow((0, buffer_ellipsis_1.buffer_ellipsis)(slice1)));
|
|
20
|
+
console.log("slice2 :", chalk.blue((0, buffer_ellipsis_1.buffer_ellipsis)(slice2)));
|
|
21
|
+
}
|
|
22
|
+
cursor += block_length;
|
|
23
|
+
}
|
|
24
|
+
// xx buf1.length.should.equal(max_length);
|
|
25
|
+
}
|
|
26
|
+
exports.compare_buffers = compare_buffers;
|
|
27
|
+
//# sourceMappingURL=compare_buffers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare_buffers.js","sourceRoot":"","sources":["../source/compare_buffers.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,4BAA4B;AAC5B,+BAA+B;AAC/B,uDAAoD;AAEpD,SAAgB,eAAe,CAAC,IAAY,EAAE,IAAY,EAAE,UAAmB;IAC3E,UAAU,GAAG,UAAU,IAAI,IAAI,CAAC,MAAM,CAAC;IACvC,MAAM,YAAY,GAAG,EAAE,CAAC;IACxB,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,OAAO,MAAM,GAAG,UAAU,EAAE;QACxB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC;QACzD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC;QACzD,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YACnD,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAC9B,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,IAAA,iCAAe,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC/D,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,IAAA,iCAAe,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SAChE;QACD,MAAM,IAAI,YAAY,CAAC;KAC1B;IACD,2CAA2C;AAC/C,CAAC;AAfD,0CAeC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.get_clock_tick = void 0;
|
|
4
|
+
require("browser-process-hrtime");
|
|
5
|
+
if (process && process.hrtime) {
|
|
6
|
+
const tickOrigin = process.hrtime()[0];
|
|
7
|
+
// clock it as a double in millisecond
|
|
8
|
+
// so we can measure very tiny time intervals
|
|
9
|
+
exports.get_clock_tick = () => {
|
|
10
|
+
const hrt = process.hrtime();
|
|
11
|
+
const r = (hrt[0] - tickOrigin) * 1000.0 + Math.ceil((hrt[1] / 1e6) * 1000) / 1000;
|
|
12
|
+
return r;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
exports.get_clock_tick = () => Date.now();
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=get_clock_tick.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get_clock_tick.js","sourceRoot":"","sources":["../source/get_clock_tick.ts"],"names":[],"mappings":";;;AAIA,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAElC,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE;IAC3B,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IACvC,sCAAsC;IACtC,6CAA6C;IAC7C,sBAAc,GAAG,GAAG,EAAE;QAClB,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;QAC7B,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;QACnF,OAAO,CAAC,CAAC;IACb,CAAC,CAAC;CACL;KAAM;IACH,sBAAc,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;CACrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getFunctionParameterNames(func: Function): RegExpMatchArray;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFunctionParameterNames = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module node-opcua-utils
|
|
6
|
+
*/
|
|
7
|
+
const STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;
|
|
8
|
+
const ARGUMENT_NAMES = /([^\s,]+)/g;
|
|
9
|
+
// tslint:disable-next-line:ban-types
|
|
10
|
+
function getFunctionParameterNames(func) {
|
|
11
|
+
const fnStr = func.toString().replace(STRIP_COMMENTS, "");
|
|
12
|
+
let result = fnStr.slice(fnStr.indexOf("(") + 1, fnStr.indexOf(")")).match(ARGUMENT_NAMES);
|
|
13
|
+
if (result === null) {
|
|
14
|
+
result = [];
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
exports.getFunctionParameterNames = getFunctionParameterNames;
|
|
19
|
+
//# sourceMappingURL=get_function_parameters_name.js.map
|
|
@@ -0,0 +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"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* set a flag
|
|
3
|
+
* @method set_flag
|
|
4
|
+
*/
|
|
5
|
+
export declare function set_flag(value: number, mask: number | {
|
|
6
|
+
value: number;
|
|
7
|
+
}): number;
|
|
8
|
+
/**
|
|
9
|
+
* check if a set of bits are set in the values
|
|
10
|
+
* @method check_flag
|
|
11
|
+
*/
|
|
12
|
+
export declare function check_flag(value: number, mask: number | {
|
|
13
|
+
value: number;
|
|
14
|
+
}): boolean;
|
|
15
|
+
export declare function isNullOrUndefined(value: any): boolean;
|
|
16
|
+
export { buffer_ellipsis } from "./buffer_ellipsis";
|
|
17
|
+
export { capitalizeFirstLetter, lowerFirstLetter } from "./string_utils";
|
|
18
|
+
export { getObjectClassName } from "./object_classname";
|
|
19
|
+
export { get_clock_tick } from "./get_clock_tick";
|
|
20
|
+
export { compare_buffers } from "./compare_buffers";
|
|
21
|
+
export { getFunctionParameterNames } from "./get_function_parameters_name";
|
|
22
|
+
export * from "./watchdog";
|
|
23
|
+
export { setDeprecated } from "./set_deprecated";
|
|
24
|
+
export { replaceBufferWithHexDump } from "./replace_buffer_with_hex_dump";
|
|
25
|
+
export * from "./timestamp";
|
|
26
|
+
export * from "./line_file";
|
|
27
|
+
export * from "./match_uri";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.replaceBufferWithHexDump = exports.setDeprecated = exports.getFunctionParameterNames = exports.compare_buffers = exports.get_clock_tick = exports.getObjectClassName = exports.lowerFirstLetter = exports.capitalizeFirstLetter = exports.buffer_ellipsis = exports.isNullOrUndefined = exports.check_flag = exports.set_flag = void 0;
|
|
14
|
+
/**
|
|
15
|
+
* @module node-opcua-utils
|
|
16
|
+
*/
|
|
17
|
+
// tslint:disable:no-bitwise
|
|
18
|
+
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
19
|
+
/**
|
|
20
|
+
* set a flag
|
|
21
|
+
* @method set_flag
|
|
22
|
+
*/
|
|
23
|
+
function set_flag(value, mask) {
|
|
24
|
+
if (mask.value) {
|
|
25
|
+
mask = mask.value;
|
|
26
|
+
}
|
|
27
|
+
(0, node_opcua_assert_1.assert)(!mask.hasOwnProperty("value"));
|
|
28
|
+
(0, node_opcua_assert_1.assert)(mask !== undefined);
|
|
29
|
+
return value | mask;
|
|
30
|
+
}
|
|
31
|
+
exports.set_flag = set_flag;
|
|
32
|
+
/**
|
|
33
|
+
* check if a set of bits are set in the values
|
|
34
|
+
* @method check_flag
|
|
35
|
+
*/
|
|
36
|
+
function check_flag(value, mask) {
|
|
37
|
+
if (mask.value) {
|
|
38
|
+
mask = mask.value;
|
|
39
|
+
}
|
|
40
|
+
(0, node_opcua_assert_1.assert)(!mask.hasOwnProperty("value"));
|
|
41
|
+
return (value & mask) === mask;
|
|
42
|
+
}
|
|
43
|
+
exports.check_flag = check_flag;
|
|
44
|
+
function isNullOrUndefined(value) {
|
|
45
|
+
return value === undefined || value === null;
|
|
46
|
+
}
|
|
47
|
+
exports.isNullOrUndefined = isNullOrUndefined;
|
|
48
|
+
var buffer_ellipsis_1 = require("./buffer_ellipsis");
|
|
49
|
+
Object.defineProperty(exports, "buffer_ellipsis", { enumerable: true, get: function () { return buffer_ellipsis_1.buffer_ellipsis; } });
|
|
50
|
+
var string_utils_1 = require("./string_utils");
|
|
51
|
+
Object.defineProperty(exports, "capitalizeFirstLetter", { enumerable: true, get: function () { return string_utils_1.capitalizeFirstLetter; } });
|
|
52
|
+
Object.defineProperty(exports, "lowerFirstLetter", { enumerable: true, get: function () { return string_utils_1.lowerFirstLetter; } });
|
|
53
|
+
var object_classname_1 = require("./object_classname");
|
|
54
|
+
Object.defineProperty(exports, "getObjectClassName", { enumerable: true, get: function () { return object_classname_1.getObjectClassName; } });
|
|
55
|
+
var get_clock_tick_1 = require("./get_clock_tick");
|
|
56
|
+
Object.defineProperty(exports, "get_clock_tick", { enumerable: true, get: function () { return get_clock_tick_1.get_clock_tick; } });
|
|
57
|
+
var compare_buffers_1 = require("./compare_buffers");
|
|
58
|
+
Object.defineProperty(exports, "compare_buffers", { enumerable: true, get: function () { return compare_buffers_1.compare_buffers; } });
|
|
59
|
+
var get_function_parameters_name_1 = require("./get_function_parameters_name");
|
|
60
|
+
Object.defineProperty(exports, "getFunctionParameterNames", { enumerable: true, get: function () { return get_function_parameters_name_1.getFunctionParameterNames; } });
|
|
61
|
+
__exportStar(require("./watchdog"), exports);
|
|
62
|
+
var set_deprecated_1 = require("./set_deprecated");
|
|
63
|
+
Object.defineProperty(exports, "setDeprecated", { enumerable: true, get: function () { return set_deprecated_1.setDeprecated; } });
|
|
64
|
+
var replace_buffer_with_hex_dump_1 = require("./replace_buffer_with_hex_dump");
|
|
65
|
+
Object.defineProperty(exports, "replaceBufferWithHexDump", { enumerable: true, get: function () { return replace_buffer_with_hex_dump_1.replaceBufferWithHexDump; } });
|
|
66
|
+
__exportStar(require("./timestamp"), exports);
|
|
67
|
+
__exportStar(require("./line_file"), exports);
|
|
68
|
+
__exportStar(require("./match_uri"), exports);
|
|
69
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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;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"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module node-opcua-utils
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LineFile = void 0;
|
|
7
|
+
class LineFile {
|
|
8
|
+
constructor() {
|
|
9
|
+
this._line = [];
|
|
10
|
+
}
|
|
11
|
+
write(...arg) {
|
|
12
|
+
let str = "";
|
|
13
|
+
// tslint:disable:prefer-for-of
|
|
14
|
+
for (let i = 0; i < arguments.length; i++) {
|
|
15
|
+
str += arguments[i];
|
|
16
|
+
}
|
|
17
|
+
this._line.push(str);
|
|
18
|
+
}
|
|
19
|
+
toString(endOfLine = "\n") {
|
|
20
|
+
return this._line.join(endOfLine);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.LineFile = LineFile;
|
|
24
|
+
//# sourceMappingURL=line_file.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
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 declare function matchUri(endpointUri1: string | null, endpointUri2: string | null): boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.matchUri = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module node-opcua-utils
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* returns true if two endpoint matches the same address:
|
|
9
|
+
*
|
|
10
|
+
* @see https://www.dnscheck.co/faq
|
|
11
|
+
* @see https://tools.ietf.org/html/rfc4343 : Domain Name System (DNS) Case Insensitivity Clarification
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
function matchUri(endpointUri1, endpointUri2) {
|
|
15
|
+
if (endpointUri1 === null) {
|
|
16
|
+
return endpointUri2 === null;
|
|
17
|
+
}
|
|
18
|
+
if (endpointUri2 === null) {
|
|
19
|
+
return endpointUri1 === null;
|
|
20
|
+
}
|
|
21
|
+
return endpointUri1.toLowerCase() === endpointUri2.toLowerCase();
|
|
22
|
+
}
|
|
23
|
+
exports.matchUri = matchUri;
|
|
24
|
+
//# sourceMappingURL=match_uri.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match_uri.js","sourceRoot":"","sources":["../source/match_uri.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,YAA2B,EAAE,YAA2B;IAC7E,IAAI,YAAY,KAAK,IAAI,EAAE;QACvB,OAAO,YAAY,KAAK,IAAI,CAAC;KAChC;IACD,IAAI,YAAY,KAAK,IAAI,EAAE;QACvB,OAAO,YAAY,KAAK,IAAI,CAAC;KAChC;IACD,OAAO,YAAY,CAAC,WAAW,EAAE,KAAK,YAAY,CAAC,WAAW,EAAE,CAAC;AACrE,CAAC;AARD,4BAQC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getObjectClassName = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module node-opcua-utils
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @method getObjectClassName
|
|
9
|
+
* @param obj
|
|
10
|
+
* @return {string}
|
|
11
|
+
*/
|
|
12
|
+
function getObjectClassName(obj) {
|
|
13
|
+
return Object.prototype.toString.call(obj).slice(8, -1);
|
|
14
|
+
}
|
|
15
|
+
exports.getObjectClassName = getObjectClassName;
|
|
16
|
+
//# sourceMappingURL=object_classname.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.replaceBufferWithHexDump = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module node-opcua-utils
|
|
6
|
+
*/
|
|
7
|
+
function replaceBufferWithHexDump(obj) {
|
|
8
|
+
for (const p in obj) {
|
|
9
|
+
if (obj.hasOwnProperty(p)) {
|
|
10
|
+
if (obj[p] instanceof Buffer) {
|
|
11
|
+
obj[p] = "<BUFFER>" + obj[p].toString("hex") + "</BUFFER>";
|
|
12
|
+
}
|
|
13
|
+
else if (typeof obj[p] === "object") {
|
|
14
|
+
replaceBufferWithHexDump(obj[p]);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return obj;
|
|
19
|
+
}
|
|
20
|
+
exports.replaceBufferWithHexDump = replaceBufferWithHexDump;
|
|
21
|
+
//# sourceMappingURL=replace_buffer_with_hex_dump.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setDeprecated(constructor: Function, methodName: string, helpString: string): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setDeprecated = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module node-opcua-utils
|
|
6
|
+
*/
|
|
7
|
+
// tslint:disable:ban-types
|
|
8
|
+
const chalk = require("chalk");
|
|
9
|
+
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
10
|
+
/* istanbul ignore next */
|
|
11
|
+
function setDeprecated(constructor, methodName, helpString) {
|
|
12
|
+
const oldMethod = constructor.prototype[methodName];
|
|
13
|
+
(0, node_opcua_assert_1.assert)(oldMethod instanceof Function, "expecting a valid " + methodName + "method on class " + constructor.constructor.name);
|
|
14
|
+
let counter = 0;
|
|
15
|
+
constructor.prototype[methodName] = function () {
|
|
16
|
+
if (counter % 1000 === 0) {
|
|
17
|
+
// tslint:disable:no-console
|
|
18
|
+
console.log(chalk.green("Warning !"), chalk.green(chalk.bold(constructor.name + "#" + methodName), " is now deprecated"));
|
|
19
|
+
console.log(" ", helpString);
|
|
20
|
+
}
|
|
21
|
+
counter++;
|
|
22
|
+
return oldMethod.apply(this, arguments);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
exports.setDeprecated = setDeprecated;
|
|
26
|
+
//# sourceMappingURL=set_deprecated.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module node-opcua-utils
|
|
3
|
+
*/
|
|
4
|
+
export declare function capitalizeFirstLetter(str: string): string;
|
|
5
|
+
export declare function isUpperCaseChar(c: string): boolean;
|
|
6
|
+
export declare function isAlpha(c: string): boolean;
|
|
7
|
+
export declare function countUpperCaseSlow(str: string): number;
|
|
8
|
+
export declare function countAlphaSlow(str: string): number;
|
|
9
|
+
export declare function countUpperCase(str: string): number;
|
|
10
|
+
export declare function countAlpha(str: string): number;
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* lowerFirstLetter convert a OPCUA Identifier to a javascript Identifier
|
|
14
|
+
*
|
|
15
|
+
* @summary
|
|
16
|
+
*
|
|
17
|
+
* OPCUA and Javascript use two different rules to build identifiers.
|
|
18
|
+
*
|
|
19
|
+
* OPCUA Identifier usually starts with a upper case letter and word are join together, this is known as
|
|
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.
|
|
24
|
+
*
|
|
25
|
+
* Javascritpt uses a slightly different convention called camelCase where word are joined together
|
|
26
|
+
* and inner words starts with a capital letter whereas first word starts with a lower case letter.
|
|
27
|
+
* (for instance helloWorld)
|
|
28
|
+
*
|
|
29
|
+
* In node-opcua we have taken the opinionated decision to consistently use camelCase convention for
|
|
30
|
+
* object properties so that all the code look nice and consistent.
|
|
31
|
+
* the lowerFirstLetter method can be used to easily convert from the OPCUA naming convention
|
|
32
|
+
* to javascript naming convention by applying the following rules.
|
|
33
|
+
*
|
|
34
|
+
* * each ascii sequence in a identifier will be converted to lower camel case.
|
|
35
|
+
* * when an identifier only contains upper case letter then it will be untouched. ( i.e CQDF => CQFD)
|
|
36
|
+
* (this rules helps to preserve acronyms)
|
|
37
|
+
* * when a identifier starts with more than one UpperCase letter but still contain lowercase letter
|
|
38
|
+
* then the first Uppercase letter excluding the last one will be converted to lower case
|
|
39
|
+
* ( ie: EURange = > euRange)
|
|
40
|
+
* * when a identifier contains several sequences delimited with underscores (_) the above rules
|
|
41
|
+
* will be applied to each of the element of the sequence
|
|
42
|
+
* ( ie: ALM_FlowOutOfTolerance => ALM_flowOutOfTolerance ( ALM=>ALM , FlowOutOfTolerance=>flowOutOfTolerance)
|
|
43
|
+
*
|
|
44
|
+
* @reference
|
|
45
|
+
* * https://en.wikipedia.org/wiki/Camel_case
|
|
46
|
+
* * https://en.wikipedia.org/wiki/Hungarian_notation
|
|
47
|
+
* * http://wiki.c2.com/?UnderscoreVersusCapitalAndLowerCaseVariableNaming
|
|
48
|
+
*
|
|
49
|
+
*
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* HelloWorld => helloWorld
|
|
53
|
+
* XAxis => xAxis
|
|
54
|
+
* EURange => euRange
|
|
55
|
+
* DATE => DATE
|
|
56
|
+
* XYZ => XYZ
|
|
57
|
+
* AB => AB
|
|
58
|
+
* Ab => ab
|
|
59
|
+
* A => a
|
|
60
|
+
* T1ABC8 => T1ABC8
|
|
61
|
+
* F_ABC_D => F_ABC_D
|
|
62
|
+
* ALM_Timeout => ALM_timeout
|
|
63
|
+
* SV_GasOn => SV_gasOn
|
|
64
|
+
* DI_VAL_FlowImp => DI_VAL_flowImp
|
|
65
|
+
*/
|
|
66
|
+
export declare function lowerFirstLetter(str: string): string;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lowerFirstLetter = exports.countAlpha = exports.countUpperCase = exports.countAlphaSlow = exports.countUpperCaseSlow = exports.isAlpha = exports.isUpperCaseChar = exports.capitalizeFirstLetter = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module node-opcua-utils
|
|
6
|
+
*/
|
|
7
|
+
// tslint:disable:variable-name
|
|
8
|
+
function capitalizeFirstLetter(str) {
|
|
9
|
+
if (str == null) {
|
|
10
|
+
return str;
|
|
11
|
+
}
|
|
12
|
+
return str.substr(0, 1).toUpperCase() + str.substr(1);
|
|
13
|
+
}
|
|
14
|
+
exports.capitalizeFirstLetter = capitalizeFirstLetter;
|
|
15
|
+
const ACode = "A".charCodeAt(0);
|
|
16
|
+
const ZCode = "Z".charCodeAt(0);
|
|
17
|
+
function isUpperCaseChar(c) {
|
|
18
|
+
const code = c.charCodeAt(0);
|
|
19
|
+
return code >= ACode && code <= ZCode;
|
|
20
|
+
}
|
|
21
|
+
exports.isUpperCaseChar = isUpperCaseChar;
|
|
22
|
+
const aCode = "a".charCodeAt(0);
|
|
23
|
+
const zCode = "z".charCodeAt(0);
|
|
24
|
+
function isAlpha(c) {
|
|
25
|
+
const code = c.charCodeAt(0);
|
|
26
|
+
return (code >= ACode && code <= ZCode) || (code >= aCode && code <= zCode);
|
|
27
|
+
}
|
|
28
|
+
exports.isAlpha = isAlpha;
|
|
29
|
+
function countUpperCaseSlow(str) {
|
|
30
|
+
return str.split("").reduce((p, c) => p + (isUpperCaseChar(c) ? 1 : 0), 0);
|
|
31
|
+
}
|
|
32
|
+
exports.countUpperCaseSlow = countUpperCaseSlow;
|
|
33
|
+
function countAlphaSlow(str) {
|
|
34
|
+
return str.split("").reduce((p, c) => p + (isAlpha(c) ? 1 : 0), 0);
|
|
35
|
+
}
|
|
36
|
+
exports.countAlphaSlow = countAlphaSlow;
|
|
37
|
+
function countUpperCase(str) {
|
|
38
|
+
let count = 0;
|
|
39
|
+
const n = str.length;
|
|
40
|
+
for (let i = 0; i < n; i++) {
|
|
41
|
+
count += isUpperCaseChar(str[i]) ? 1 : 0;
|
|
42
|
+
}
|
|
43
|
+
return count;
|
|
44
|
+
}
|
|
45
|
+
exports.countUpperCase = countUpperCase;
|
|
46
|
+
function countAlpha(str) {
|
|
47
|
+
let count = 0;
|
|
48
|
+
const n = str.length;
|
|
49
|
+
for (let i = 0; i < n; i++) {
|
|
50
|
+
count += isAlpha(str[i]) ? 1 : 0;
|
|
51
|
+
}
|
|
52
|
+
return count;
|
|
53
|
+
}
|
|
54
|
+
exports.countAlpha = countAlpha;
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* lowerFirstLetter convert a OPCUA Identifier to a javascript Identifier
|
|
58
|
+
*
|
|
59
|
+
* @summary
|
|
60
|
+
*
|
|
61
|
+
* OPCUA and Javascript use two different rules to build identifiers.
|
|
62
|
+
*
|
|
63
|
+
* OPCUA Identifier usually starts with a upper case letter and word are join together, this is known as
|
|
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.
|
|
68
|
+
*
|
|
69
|
+
* Javascritpt uses a slightly different convention called camelCase where word are joined together
|
|
70
|
+
* and inner words starts with a capital letter whereas first word starts with a lower case letter.
|
|
71
|
+
* (for instance helloWorld)
|
|
72
|
+
*
|
|
73
|
+
* In node-opcua we have taken the opinionated decision to consistently use camelCase convention for
|
|
74
|
+
* object properties so that all the code look nice and consistent.
|
|
75
|
+
* the lowerFirstLetter method can be used to easily convert from the OPCUA naming convention
|
|
76
|
+
* to javascript naming convention by applying the following rules.
|
|
77
|
+
*
|
|
78
|
+
* * each ascii sequence in a identifier will be converted to lower camel case.
|
|
79
|
+
* * when an identifier only contains upper case letter then it will be untouched. ( i.e CQDF => CQFD)
|
|
80
|
+
* (this rules helps to preserve acronyms)
|
|
81
|
+
* * when a identifier starts with more than one UpperCase letter but still contain lowercase letter
|
|
82
|
+
* then the first Uppercase letter excluding the last one will be converted to lower case
|
|
83
|
+
* ( ie: EURange = > euRange)
|
|
84
|
+
* * when a identifier contains several sequences delimited with underscores (_) the above rules
|
|
85
|
+
* will be applied to each of the element of the sequence
|
|
86
|
+
* ( ie: ALM_FlowOutOfTolerance => ALM_flowOutOfTolerance ( ALM=>ALM , FlowOutOfTolerance=>flowOutOfTolerance)
|
|
87
|
+
*
|
|
88
|
+
* @reference
|
|
89
|
+
* * https://en.wikipedia.org/wiki/Camel_case
|
|
90
|
+
* * https://en.wikipedia.org/wiki/Hungarian_notation
|
|
91
|
+
* * http://wiki.c2.com/?UnderscoreVersusCapitalAndLowerCaseVariableNaming
|
|
92
|
+
*
|
|
93
|
+
*
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* HelloWorld => helloWorld
|
|
97
|
+
* XAxis => xAxis
|
|
98
|
+
* EURange => euRange
|
|
99
|
+
* DATE => DATE
|
|
100
|
+
* XYZ => XYZ
|
|
101
|
+
* AB => AB
|
|
102
|
+
* Ab => ab
|
|
103
|
+
* A => a
|
|
104
|
+
* T1ABC8 => T1ABC8
|
|
105
|
+
* F_ABC_D => F_ABC_D
|
|
106
|
+
* ALM_Timeout => ALM_timeout
|
|
107
|
+
* SV_GasOn => SV_gasOn
|
|
108
|
+
* DI_VAL_FlowImp => DI_VAL_flowImp
|
|
109
|
+
*/
|
|
110
|
+
function lowerFirstLetter(str) {
|
|
111
|
+
if (str == null) {
|
|
112
|
+
return str;
|
|
113
|
+
}
|
|
114
|
+
// at least, 2 all upper
|
|
115
|
+
if (str.length >= 2 && countUpperCase(str) === countAlpha(str)) {
|
|
116
|
+
return str;
|
|
117
|
+
}
|
|
118
|
+
if (str.match(/\_/)) {
|
|
119
|
+
return str.split("_").map(lowerFirstLetter).join("_");
|
|
120
|
+
}
|
|
121
|
+
let result = str.substr(0, 1).toLowerCase() + str.substr(1);
|
|
122
|
+
if (result.length > 3 && isUpperCaseChar(str[1]) && isUpperCaseChar(str[2])) {
|
|
123
|
+
result = str.substr(0, 2).toLowerCase() + str.substr(2);
|
|
124
|
+
}
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
exports.lowerFirstLetter = lowerFirstLetter;
|
|
128
|
+
//# sourceMappingURL=string_utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string_utils.js","sourceRoot":"","sources":["../source/string_utils.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function timestamp(): string;
|