node-opcua-enum 2.64.1 → 2.66.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/dist/enum.d.ts CHANGED
@@ -1,74 +1,78 @@
1
- /**
2
- * @module node-opcua-enum
3
- *
4
- */
5
- /**
6
- * Represents an Item of an Enum.
7
- *
8
- * @class Enum
9
- */
10
- export declare class EnumItem {
11
- key: string;
12
- value: number;
13
- /**
14
- *
15
- * @param key the enum key
16
- * @param value the enum value
17
- */
18
- constructor(key: string, value: number);
19
- /**
20
- * Checks if the EnumItem is the same as the passing object.
21
- * @method is
22
- * @param {EnumItem | String | Number} item The object to check with.
23
- * @return {Boolean} The check result.
24
- */
25
- is(item: EnumItem | string | number): boolean;
26
- /**
27
- * Checks if the flagged EnumItem has the passing object.
28
- * @method has
29
- * @param {EnumItem | String |Number} value The object to check with.
30
- * @return {Boolean} The check result.
31
- */
32
- has(value: string | number | EnumItem): boolean;
33
- /**
34
- * Returns String representation of this EnumItem.
35
- * @method toString
36
- * @return {String} String representation of this EnumItem.
37
- */
38
- toString(): string;
39
- /**
40
- * Returns JSON object representation of this EnumItem.
41
- * @method toJSON
42
- * @return {String} JSON object representation of this EnumItem.
43
- */
44
- toJSON(): any;
45
- /**
46
- * Returns the value to compare with.
47
- * @method valueOf
48
- * @return {String} The value to compare with.
49
- */
50
- valueOf(): number;
51
- }
52
- /**
53
- * @class Enum
54
- * @constructor
55
- * Represents an Enum with enum items.
56
- * @param {Array || Object} map This are the enum items.
57
- */
58
- export declare class Enum {
59
- private readonly enumItems;
60
- private readonly _isFlaggable;
61
- constructor(map: any);
62
- get isFlaggable(): boolean;
63
- /**
64
- * Returns the appropriate EnumItem.
65
- * @method get
66
- * @param key The object to get with.
67
- * @return the get result.
68
- */
69
- get(key: EnumItem | string | number): (EnumItem | null);
70
- getDefaultValue(): EnumItem;
71
- toString(): string;
72
- private _getByString;
73
- private _getByNum;
74
- }
1
+ /**
2
+ * @module node-opcua-enum
3
+ *
4
+ */
5
+ /**
6
+ * Represents an Item of an Enum.
7
+ *
8
+ * @class Enum
9
+ */
10
+ export declare class EnumItem {
11
+ key: string;
12
+ value: number;
13
+ /**
14
+ *
15
+ * @param key the enum key
16
+ * @param value the enum value
17
+ */
18
+ constructor(key: string, value: number);
19
+ /**
20
+ * Checks if the EnumItem is the same as the passing object.
21
+ * @method is
22
+ * @param {EnumItem | String | Number} item The object to check with.
23
+ * @return {Boolean} The check result.
24
+ */
25
+ is(item: EnumItem | string | number): boolean;
26
+ /**
27
+ * Checks if the flagged EnumItem has the passing object.
28
+ * @method has
29
+ * @param {EnumItem | String |Number} value The object to check with.
30
+ * @return {Boolean} The check result.
31
+ */
32
+ has(value: string | number | EnumItem): boolean;
33
+ /**
34
+ * Returns String representation of this EnumItem.
35
+ * @method toString
36
+ * @return {String} String representation of this EnumItem.
37
+ */
38
+ toString(): string;
39
+ /**
40
+ * Returns JSON object representation of this EnumItem.
41
+ * @method toJSON
42
+ * @return {String} JSON object representation of this EnumItem.
43
+ */
44
+ toJSON(): any;
45
+ /**
46
+ * Returns the value to compare with.
47
+ * @method valueOf
48
+ * @return {String} The value to compare with.
49
+ */
50
+ valueOf(): number;
51
+ }
52
+ export interface _TypescriptEnum {
53
+ [key: string | number]: number | string;
54
+ }
55
+ export declare function adaptTypescriptEnum(map: _TypescriptEnum | string[]): _TypescriptEnum;
56
+ /**
57
+ * @class Enum
58
+ * @constructor
59
+ * Represents an Enum with enum items.
60
+ * @param {Array || Object} map This are the enum items.
61
+ */
62
+ export declare class Enum {
63
+ private readonly enumItems;
64
+ private readonly _isFlaggable;
65
+ constructor(map: _TypescriptEnum | string[]);
66
+ get isFlaggable(): boolean;
67
+ /**
68
+ * Returns the appropriate EnumItem.
69
+ * @method get
70
+ * @param key The object to get with.
71
+ * @return the get result.
72
+ */
73
+ get(key: EnumItem | string | number): EnumItem | null;
74
+ getDefaultValue(): EnumItem;
75
+ toString(): string;
76
+ private _getByString;
77
+ private _getByNum;
78
+ }
package/dist/enum.js CHANGED
@@ -1,232 +1,244 @@
1
- "use strict";
2
- /**
3
- * @module node-opcua-enum
4
- *
5
- */
6
- // tslint:disable:no-bitwise
7
- // tslint:disable:max-classes-per-file
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.Enum = exports.EnumItem = void 0;
10
- /**
11
- * Represents an Item of an Enum.
12
- *
13
- * @class Enum
14
- */
15
- class EnumItem {
16
- /**
17
- *
18
- * @param key the enum key
19
- * @param value the enum value
20
- */
21
- constructor(key, value) {
22
- this.key = key;
23
- this.value = value;
24
- }
25
- /**
26
- * Checks if the EnumItem is the same as the passing object.
27
- * @method is
28
- * @param {EnumItem | String | Number} item The object to check with.
29
- * @return {Boolean} The check result.
30
- */
31
- is(item) {
32
- if (item instanceof EnumItem) {
33
- return this.value === item.value;
34
- }
35
- else if (typeof item === "string") {
36
- return this.key === item;
37
- }
38
- else {
39
- return this.value === item;
40
- }
41
- }
42
- /**
43
- * Checks if the flagged EnumItem has the passing object.
44
- * @method has
45
- * @param {EnumItem | String |Number} value The object to check with.
46
- * @return {Boolean} The check result.
47
- */
48
- has(value) {
49
- if (value instanceof EnumItem) {
50
- return (value.value & this.value) !== 0;
51
- }
52
- else if (typeof value === "string") {
53
- return this.key.indexOf(value) >= 0;
54
- }
55
- else {
56
- return (value & this.value) !== 0;
57
- }
58
- }
59
- /**
60
- * Returns String representation of this EnumItem.
61
- * @method toString
62
- * @return {String} String representation of this EnumItem.
63
- */
64
- toString() {
65
- return this.key;
66
- }
67
- /**
68
- * Returns JSON object representation of this EnumItem.
69
- * @method toJSON
70
- * @return {String} JSON object representation of this EnumItem.
71
- */
72
- toJSON() {
73
- return this.key;
74
- }
75
- /**
76
- * Returns the value to compare with.
77
- * @method valueOf
78
- * @return {String} The value to compare with.
79
- */
80
- valueOf() {
81
- return this.value;
82
- }
83
- }
84
- exports.EnumItem = EnumItem;
85
- function powerOfTwo(n) {
86
- return n && (!(n & (n - 1))) ? true : false;
87
- }
88
- // check if enum is flaggable
89
- function checkIsFlaggable(enums) {
90
- for (const e of enums) {
91
- const value = +e.value;
92
- if (isNaN(value)) {
93
- continue; // skipping none number value
94
- }
95
- if ((value !== 0 && value !== 1) && !powerOfTwo(value)) {
96
- return false;
97
- }
98
- }
99
- return true;
100
- }
101
- /**
102
- * @class Enum
103
- * @constructor
104
- * Represents an Enum with enum items.
105
- * @param {Array || Object} map This are the enum items.
106
- */
107
- class Enum {
108
- constructor(map) {
109
- this.enumItems = [];
110
- let mm = null;
111
- let isFlaggable = null;
112
- if (Array.isArray(map)) {
113
- // create map as flaggable enum
114
- mm = {};
115
- for (let i = 0; i < map.length; i++) {
116
- mm[map[i]] = 1 << i;
117
- }
118
- isFlaggable = true;
119
- }
120
- else {
121
- mm = map;
122
- }
123
- for (const key of Object.keys(mm)) {
124
- const val = mm[key];
125
- if (undefined === val) {
126
- continue;
127
- }
128
- const kv = new EnumItem(key, val);
129
- const pThis = this;
130
- pThis[key] = kv;
131
- pThis[val] = kv;
132
- this.enumItems.push(kv);
133
- }
134
- if (!isFlaggable) {
135
- isFlaggable = checkIsFlaggable(this.enumItems);
136
- }
137
- this._isFlaggable = isFlaggable;
138
- }
139
- get isFlaggable() {
140
- return this._isFlaggable;
141
- }
142
- /**
143
- * Returns the appropriate EnumItem.
144
- * @method get
145
- * @param key The object to get with.
146
- * @return the get result.
147
- */
148
- get(key) {
149
- const pThis = this;
150
- if (key instanceof EnumItem) {
151
- if (!pThis[key.key]) {
152
- throw new Error("Invalid key");
153
- }
154
- return key;
155
- }
156
- if (key === null || key === undefined) {
157
- return null;
158
- }
159
- const prop = pThis[key];
160
- if (prop) {
161
- return prop;
162
- }
163
- else if (this._isFlaggable) {
164
- if (typeof key === "string") {
165
- return this._getByString(key);
166
- }
167
- else if (typeof key === "number") {
168
- return this._getByNum(key);
169
- }
170
- }
171
- return null;
172
- }
173
- getDefaultValue() {
174
- return this.enumItems[0];
175
- }
176
- toString() {
177
- return this.enumItems.join(" , ");
178
- }
179
- _getByString(key) {
180
- const pThis = this;
181
- const parts = key.split(" | ");
182
- let val = 0;
183
- for (const part of parts) {
184
- const item = pThis[part];
185
- if (undefined === item) {
186
- return null;
187
- }
188
- val |= item.value;
189
- }
190
- const kv = new EnumItem(key, val);
191
- // add in cache for later
192
- let prop = pThis[val];
193
- if (prop === undefined) {
194
- pThis[val] = kv;
195
- }
196
- prop = pThis[key];
197
- if (prop === undefined) {
198
- pThis[key] = kv;
199
- }
200
- return kv;
201
- }
202
- _getByNum(key) {
203
- if (key === 0) {
204
- return null;
205
- }
206
- const pThis = this;
207
- let name;
208
- let c = 1;
209
- for (let i = 0; c < key; i++) {
210
- if ((c & key) === c) {
211
- const item = pThis[c];
212
- if (undefined === item) {
213
- return null;
214
- }
215
- if (name) {
216
- name = name + " | " + item.key;
217
- }
218
- else {
219
- name = item.key;
220
- }
221
- }
222
- c *= 2;
223
- }
224
- const kv = new EnumItem(name, key);
225
- // add in cache for later
226
- pThis[name] = kv;
227
- pThis[key] = kv;
228
- return kv;
229
- }
230
- }
231
- exports.Enum = Enum;
1
+ "use strict";
2
+ /**
3
+ * @module node-opcua-enum
4
+ *
5
+ */
6
+ // tslint:disable:no-bitwise
7
+ // tslint:disable:max-classes-per-file
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.Enum = exports.adaptTypescriptEnum = exports.EnumItem = void 0;
10
+ /**
11
+ * Represents an Item of an Enum.
12
+ *
13
+ * @class Enum
14
+ */
15
+ class EnumItem {
16
+ /**
17
+ *
18
+ * @param key the enum key
19
+ * @param value the enum value
20
+ */
21
+ constructor(key, value) {
22
+ this.key = key;
23
+ this.value = value;
24
+ }
25
+ /**
26
+ * Checks if the EnumItem is the same as the passing object.
27
+ * @method is
28
+ * @param {EnumItem | String | Number} item The object to check with.
29
+ * @return {Boolean} The check result.
30
+ */
31
+ is(item) {
32
+ if (item instanceof EnumItem) {
33
+ return this.value === item.value;
34
+ }
35
+ else if (typeof item === "string") {
36
+ return this.key === item;
37
+ }
38
+ else {
39
+ return this.value === item;
40
+ }
41
+ }
42
+ /**
43
+ * Checks if the flagged EnumItem has the passing object.
44
+ * @method has
45
+ * @param {EnumItem | String |Number} value The object to check with.
46
+ * @return {Boolean} The check result.
47
+ */
48
+ has(value) {
49
+ if (value instanceof EnumItem) {
50
+ return (value.value & this.value) !== 0;
51
+ }
52
+ else if (typeof value === "string") {
53
+ return this.key.indexOf(value) >= 0;
54
+ }
55
+ else {
56
+ return (value & this.value) !== 0;
57
+ }
58
+ }
59
+ /**
60
+ * Returns String representation of this EnumItem.
61
+ * @method toString
62
+ * @return {String} String representation of this EnumItem.
63
+ */
64
+ toString() {
65
+ return this.key;
66
+ }
67
+ /**
68
+ * Returns JSON object representation of this EnumItem.
69
+ * @method toJSON
70
+ * @return {String} JSON object representation of this EnumItem.
71
+ */
72
+ toJSON() {
73
+ return this.key;
74
+ }
75
+ /**
76
+ * Returns the value to compare with.
77
+ * @method valueOf
78
+ * @return {String} The value to compare with.
79
+ */
80
+ valueOf() {
81
+ return this.value;
82
+ }
83
+ }
84
+ exports.EnumItem = EnumItem;
85
+ function powerOfTwo(n) {
86
+ return n && !(n & (n - 1)) ? true : false;
87
+ }
88
+ // check if enum is flaggable
89
+ function checkIsFlaggable(enums) {
90
+ for (const e of enums) {
91
+ const value = +e.value;
92
+ if (isNaN(value)) {
93
+ continue; // skipping none number value
94
+ }
95
+ if (value !== 0 && value !== 1 && !powerOfTwo(value)) {
96
+ return false;
97
+ }
98
+ }
99
+ return true;
100
+ }
101
+ function adaptTypescriptEnum(map) {
102
+ if (Array.isArray(map)) {
103
+ let mm = null;
104
+ // create map as flaggable enum
105
+ mm = {};
106
+ for (let i = 0; i < map.length; i++) {
107
+ mm[map[i]] = 1 << i;
108
+ }
109
+ return mm;
110
+ }
111
+ return map;
112
+ }
113
+ exports.adaptTypescriptEnum = adaptTypescriptEnum;
114
+ /**
115
+ * @class Enum
116
+ * @constructor
117
+ * Represents an Enum with enum items.
118
+ * @param {Array || Object} map This are the enum items.
119
+ */
120
+ class Enum {
121
+ constructor(map) {
122
+ this.enumItems = [];
123
+ let mm = null;
124
+ let isFlaggable = null;
125
+ if (Array.isArray(map)) {
126
+ mm = adaptTypescriptEnum(map);
127
+ isFlaggable = true;
128
+ }
129
+ else {
130
+ mm = map;
131
+ }
132
+ for (const key of Object.keys(mm)) {
133
+ if (typeof key !== "string") {
134
+ continue;
135
+ }
136
+ const val = mm[key];
137
+ if (undefined === val) {
138
+ continue;
139
+ }
140
+ const kv = new EnumItem(key, val);
141
+ const pThis = this;
142
+ pThis[key] = kv;
143
+ pThis[val] = kv;
144
+ this.enumItems.push(kv);
145
+ }
146
+ if (!isFlaggable) {
147
+ isFlaggable = checkIsFlaggable(this.enumItems);
148
+ }
149
+ this._isFlaggable = isFlaggable;
150
+ }
151
+ get isFlaggable() {
152
+ return this._isFlaggable;
153
+ }
154
+ /**
155
+ * Returns the appropriate EnumItem.
156
+ * @method get
157
+ * @param key The object to get with.
158
+ * @return the get result.
159
+ */
160
+ get(key) {
161
+ const pThis = this;
162
+ if (key instanceof EnumItem) {
163
+ if (!pThis[key.key]) {
164
+ throw new Error("Invalid key");
165
+ }
166
+ return key;
167
+ }
168
+ if (key === null || key === undefined) {
169
+ return null;
170
+ }
171
+ const prop = pThis[key];
172
+ if (prop) {
173
+ return prop;
174
+ }
175
+ else if (this._isFlaggable) {
176
+ if (typeof key === "string") {
177
+ return this._getByString(key);
178
+ }
179
+ else if (typeof key === "number") {
180
+ return this._getByNum(key);
181
+ }
182
+ }
183
+ return null;
184
+ }
185
+ getDefaultValue() {
186
+ return this.enumItems[0];
187
+ }
188
+ toString() {
189
+ return this.enumItems.join(" , ");
190
+ }
191
+ _getByString(key) {
192
+ const pThis = this;
193
+ const parts = key.split(" | ");
194
+ let val = 0;
195
+ for (const part of parts) {
196
+ const item = pThis[part];
197
+ if (undefined === item) {
198
+ return null;
199
+ }
200
+ val |= item.value;
201
+ }
202
+ const kv = new EnumItem(key, val);
203
+ // add in cache for later
204
+ let prop = pThis[val];
205
+ if (prop === undefined) {
206
+ pThis[val] = kv;
207
+ }
208
+ prop = pThis[key];
209
+ if (prop === undefined) {
210
+ pThis[key] = kv;
211
+ }
212
+ return kv;
213
+ }
214
+ _getByNum(key) {
215
+ if (key === 0) {
216
+ return null;
217
+ }
218
+ const pThis = this;
219
+ let name;
220
+ let c = 1;
221
+ for (let i = 0; c < key; i++) {
222
+ if ((c & key) === c) {
223
+ const item = pThis[c];
224
+ if (undefined === item) {
225
+ return null;
226
+ }
227
+ if (name) {
228
+ name = name + " | " + item.key;
229
+ }
230
+ else {
231
+ name = item.key;
232
+ }
233
+ }
234
+ c *= 2;
235
+ }
236
+ const kv = new EnumItem(name, key);
237
+ // add in cache for later
238
+ pThis[name] = kv;
239
+ pThis[key] = kv;
240
+ return kv;
241
+ }
242
+ }
243
+ exports.Enum = Enum;
232
244
  //# sourceMappingURL=enum.js.map
package/dist/enum.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"enum.js","sourceRoot":"","sources":["../source/enum.ts"],"names":[],"mappings":";AAAA;;;GAGG;AACH,4BAA4B;AAC5B,sCAAsC;;;AAEtC;;;;GAIG;AACH,MAAa,QAAQ;IAIjB;;;;OAIG;IACH,YAAmB,GAAW,EAAE,KAAa;QACzC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACI,EAAE,CAAC,IAA4B;QAClC,IAAI,IAAI,YAAY,QAAQ,EAAE;YAC1B,OAAO,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC;SACpC;aAAM,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YACjC,OAAO,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC;SAC5B;aAAM;YACH,OAAO,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC;SAC9B;IACL,CAAC;IAED;;;;;OAKG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;QAClB,IAAI,IAAI,KAAK,SAAS,EAAE;YACpB,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;SACnB;QACD,OAAO,EAAE,CAAC;IACd,CAAC;IAEO,SAAS,CAAC,GAAW;QACzB,IAAI,GAAG,KAAK,CAAC,EAAE;YACX,OAAO,IAAI,CAAC;SACf;QACD,MAAM,KAAK,GAAG,IAAW,CAAC;QAE1B,IAAI,IAAI,CAAC;QACT,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;YAC1B,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,EAAE;gBACjB,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBACtB,IAAI,SAAS,KAAK,IAAI,EAAE;oBACpB,OAAO,IAAI,CAAC;iBACf;gBACD,IAAI,IAAI,EAAE;oBACN,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC;iBAClC;qBAAM;oBACH,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC;iBACnB;aACJ;YACD,CAAC,IAAI,CAAC,CAAC;SACV;QACD,MAAM,EAAE,GAAG,IAAI,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QACnC,yBAAyB;QACzB,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QACjB,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QAChB,OAAO,EAAE,CAAC;IACd,CAAC;CACJ;AAtID,oBAsIC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- /**
2
- * @module node-opcua-enum
3
- *
4
- */
5
- export * from "./enum";
1
+ /**
2
+ * @module node-opcua-enum
3
+ *
4
+ */
5
+ export * from "./enum";
package/dist/index.js CHANGED
@@ -1,18 +1,22 @@
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
- /**
14
- * @module node-opcua-enum
15
- *
16
- */
17
- __exportStar(require("./enum"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ /**
18
+ * @module node-opcua-enum
19
+ *
20
+ */
21
+ __exportStar(require("./enum"), exports);
18
22
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;GAGG;AACH,yCAAuB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;GAGG;AACH,yCAAuB"}
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "node-opcua-enum",
3
- "version": "2.64.1",
3
+ "version": "2.66.0",
4
4
  "description": "pure nodejs OPCUA SDK - module -enum",
5
5
  "scripts": {
6
6
  "build": "tsc -b",
7
7
  "lint": "eslint source/**/*.ts",
8
- "clean": "node -e \"require('rimraf').sync('dist');\"",
8
+ "clean": "npx rimraf dist *.tsbuildinfo",
9
9
  "test": "mocha"
10
10
  },
11
11
  "main": "./dist/index.js",
12
12
  "@types": "./dist/index.d.ts",
13
13
  "dependencies": {
14
- "node-opcua-assert": "2.64.1"
14
+ "node-opcua-assert": "2.66.0"
15
15
  },
16
16
  "devDependencies": {
17
17
  "enum": "3.0.4",
18
- "node-opcua-benchmarker": "2.64.1",
18
+ "node-opcua-benchmarker": "2.66.0",
19
19
  "should": "^13.2.3"
20
20
  },
21
21
  "author": "Etienne Rossignon",
@@ -33,5 +33,5 @@
33
33
  "internet of things"
34
34
  ],
35
35
  "homepage": "http://node-opcua.github.io/",
36
- "gitHead": "b65b8738603cd475d7d99a2b20b0ae9d32b4110c"
36
+ "gitHead": "97f47e2e242a1fd737495fd64cb65e8fb7a9964b"
37
37
  }
package/source/enum.ts CHANGED
@@ -30,7 +30,7 @@ export class EnumItem {
30
30
  * @param {EnumItem | String | Number} item The object to check with.
31
31
  * @return {Boolean} The check result.
32
32
  */
33
- public is(item: EnumItem|string|number): boolean {
33
+ public is(item: EnumItem | string | number): boolean {
34
34
  if (item instanceof EnumItem) {
35
35
  return this.value === item.value;
36
36
  } else if (typeof item === "string") {
@@ -86,24 +86,40 @@ export class EnumItem {
86
86
  }
87
87
  }
88
88
 
89
- function powerOfTwo(n: number): boolean
90
- {
91
- return n && (!(n & (n-1))) ? true: false;
89
+ function powerOfTwo(n: number): boolean {
90
+ return n && !(n & (n - 1)) ? true : false;
92
91
  }
93
92
  // check if enum is flaggable
94
93
  function checkIsFlaggable(enums: EnumItem[]): boolean {
95
94
  for (const e of enums) {
96
- const value = +e.value;
95
+ const value = +e.value;
97
96
  if (isNaN(value)) {
98
97
  continue; // skipping none number value
99
98
  }
100
- if ((value !== 0 && value !==1) && !powerOfTwo(value)) {
99
+ if (value !== 0 && value !== 1 && !powerOfTwo(value)) {
101
100
  return false;
102
101
  }
103
102
  }
104
103
  return true;
105
104
  }
106
105
 
106
+ export interface _TypescriptEnum {
107
+ [key: string | number]: number | string;
108
+ }
109
+
110
+ export function adaptTypescriptEnum(map: _TypescriptEnum | string[]) {
111
+ if (Array.isArray(map)) {
112
+ let mm: _TypescriptEnum | null = null;
113
+ // create map as flaggable enum
114
+ mm = {};
115
+ for (let i = 0; i < map.length; i++) {
116
+ mm[map[i]] = 1 << i;
117
+ }
118
+ return mm;
119
+ }
120
+ return map as _TypescriptEnum;
121
+ }
122
+
107
123
  /**
108
124
  * @class Enum
109
125
  * @constructor
@@ -111,28 +127,25 @@ function checkIsFlaggable(enums: EnumItem[]): boolean {
111
127
  * @param {Array || Object} map This are the enum items.
112
128
  */
113
129
  export class Enum {
114
-
115
130
  private readonly enumItems: EnumItem[];
116
131
  private readonly _isFlaggable: boolean;
117
132
 
118
- constructor(map: any) {
119
-
133
+ constructor(map: _TypescriptEnum | string[]) {
120
134
  this.enumItems = [];
121
- let mm: any = null;
135
+ let mm: _TypescriptEnum | null = null;
122
136
  let isFlaggable = null;
123
137
  if (Array.isArray(map)) {
124
- // create map as flaggable enum
125
- mm = {};
126
- for (let i = 0; i < map.length; i++) {
127
- mm[map[i]] = 1 << i;
128
- }
138
+ mm = adaptTypescriptEnum(map);
129
139
  isFlaggable = true;
130
140
  } else {
131
141
  mm = map;
132
142
  }
133
143
 
134
144
  for (const key of Object.keys(mm)) {
135
- const val = mm[key];
145
+ if (typeof key !== "string") {
146
+ continue;
147
+ }
148
+ const val = mm[key] as number;
136
149
  if (undefined === val) {
137
150
  continue;
138
151
  }
@@ -150,7 +163,7 @@ export class Enum {
150
163
  }
151
164
  this._isFlaggable = isFlaggable;
152
165
  }
153
-
166
+
154
167
  public get isFlaggable(): boolean {
155
168
  return this._isFlaggable;
156
169
  }
@@ -160,8 +173,7 @@ export class Enum {
160
173
  * @param key The object to get with.
161
174
  * @return the get result.
162
175
  */
163
- public get(key: EnumItem | string | number): (EnumItem | null) {
164
-
176
+ public get(key: EnumItem | string | number): EnumItem | null {
165
177
  const pThis = this as any;
166
178
  if (key instanceof EnumItem) {
167
179
  if (!pThis[key.key]) {
@@ -194,8 +206,7 @@ export class Enum {
194
206
  return this.enumItems.join(" , ");
195
207
  }
196
208
 
197
- private _getByString(key: string): (EnumItem | null) {
198
-
209
+ private _getByString(key: string): EnumItem | null {
199
210
  const pThis = this as any;
200
211
  const parts = key.split(" | ");
201
212
 
@@ -221,8 +232,7 @@ export class Enum {
221
232
  return kv;
222
233
  }
223
234
 
224
- private _getByNum(key: number): (EnumItem | null) {
225
-
235
+ private _getByNum(key: number): EnumItem | null {
226
236
  if (key === 0) {
227
237
  return null;
228
238
  }
@@ -250,6 +260,4 @@ export class Enum {
250
260
  pThis[key] = kv;
251
261
  return kv;
252
262
  }
253
-
254
-
255
263
  }