node-opcua-enum
Advanced tools
Comparing version 2.0.0-alpha.8 to 2.0.0-alpha.9
/** | ||
* @module opcua.miscellaneous | ||
* @module node-opcua-enum | ||
* | ||
*/ | ||
/** | ||
* Represents an Item of an Enum. | ||
* | ||
* @class Enum | ||
* @constructor | ||
* Represents an Item of an Enum. | ||
* @param {String} key The Enum key. | ||
* @param {Number} value The Enum value. | ||
*/ | ||
@@ -15,2 +13,7 @@ export declare class EnumItem { | ||
value: number; | ||
/** | ||
* | ||
* @param key the enum key | ||
* @param value the enum value | ||
*/ | ||
constructor(key: string, value: number); | ||
@@ -63,10 +66,10 @@ /** | ||
* @method get | ||
* @param {EnumItem || String || Number} key The object to get with. | ||
* @return {EnumItem} The get result. | ||
* @param key The object to get with. | ||
* @return the get result. | ||
*/ | ||
get(key: EnumItem | string | number): (EnumItem | null); | ||
getDefaultValue(): EnumItem; | ||
toString(): string; | ||
private _getByString; | ||
private _getByNum; | ||
getDefaultValue(): EnumItem; | ||
toString(): string; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* @module opcua.miscellaneous | ||
* @module node-opcua-enum | ||
* | ||
*/ | ||
// tslint:disable:no-bitwise | ||
// tslint:disable:max-classes-per-file | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* Represents an Item of an Enum. | ||
* | ||
* @class Enum | ||
* @constructor | ||
* Represents an Item of an Enum. | ||
* @param {String} key The Enum key. | ||
* @param {Number} value The Enum value. | ||
*/ | ||
class EnumItem { | ||
/** | ||
* | ||
* @param key the enum key | ||
* @param value the enum value | ||
*/ | ||
constructor(key, value) { | ||
@@ -110,3 +115,3 @@ this.key = key; | ||
} | ||
for (const key in mm) { | ||
for (const key of Object.keys(mm)) { | ||
const val = mm[key]; | ||
@@ -130,4 +135,4 @@ if (undefined === val) { | ||
* @method get | ||
* @param {EnumItem || String || Number} key The object to get with. | ||
* @return {EnumItem} The get result. | ||
* @param key The object to get with. | ||
* @return the get result. | ||
*/ | ||
@@ -159,2 +164,8 @@ get(key) { | ||
} | ||
getDefaultValue() { | ||
return this.enumItems[0]; | ||
} | ||
toString() { | ||
return this.enumItems.join(" , "); | ||
} | ||
_getByString(key) { | ||
@@ -189,6 +200,6 @@ const pThis = this; | ||
let name; | ||
let c = 1, item; | ||
let c = 1; | ||
for (let i = 0; c < key; i++) { | ||
if ((c & key) === c) { | ||
item = pThis[c]; | ||
const item = pThis[c]; | ||
if (undefined === item) { | ||
@@ -212,10 +223,4 @@ return null; | ||
} | ||
getDefaultValue() { | ||
return this.enumItems[0]; | ||
} | ||
toString() { | ||
return this.enumItems.join(" , "); | ||
} | ||
} | ||
exports.Enum = Enum; | ||
//# sourceMappingURL=enum.js.map |
{ | ||
"name": "node-opcua-enum", | ||
"version": "2.0.0-alpha.8", | ||
"version": "2.0.0-alpha.9", | ||
"description": "pure nodejs OPCUA SDK - module -enum", | ||
@@ -9,10 +9,10 @@ "scripts": { | ||
}, | ||
"main": "./dist/enum.js", | ||
"@types": "./dist/enum.d.ts", | ||
"main": "./dist/index.js", | ||
"@types": "./dist/index.d.ts", | ||
"dependencies": { | ||
"node-opcua-assert": "^2.0.0-alpha.8" | ||
"node-opcua-assert": "^2.0.0-alpha.9" | ||
}, | ||
"devDependencies": { | ||
"enum": "2.5.0", | ||
"node-opcua-benchmarker": "^2.0.0-alpha.8", | ||
"node-opcua-benchmarker": "^2.0.0-alpha.9", | ||
"should": "13.2.3", | ||
@@ -36,3 +36,3 @@ "underscore": "^1.9.1" | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "7bbf38d5a3cd29cb6aed6ca38078f4d89d3f956a" | ||
"gitHead": "cd7120d1840593757f0f3c9e53be4e85883dc0e6" | ||
} |
/** | ||
* @module opcua.miscellaneous | ||
* @module node-opcua-enum | ||
* | ||
*/ | ||
// tslint:disable:no-bitwise | ||
// tslint:disable:max-classes-per-file | ||
/** | ||
* Represents an Item of an Enum. | ||
* | ||
* @class Enum | ||
* @constructor | ||
* Represents an Item of an Enum. | ||
* @param {String} key The Enum key. | ||
* @param {Number} value The Enum value. | ||
*/ | ||
export class EnumItem { | ||
key: string; | ||
value: number; | ||
public key: string; | ||
public value: number; | ||
constructor(key: string, value: number) { | ||
/** | ||
* | ||
* @param key the enum key | ||
* @param value the enum value | ||
*/ | ||
public constructor(key: string, value: number) { | ||
this.key = key; | ||
@@ -27,3 +33,3 @@ this.value = value; | ||
*/ | ||
is(item: any): boolean { | ||
public is(item: any): boolean { | ||
if (item instanceof EnumItem) { | ||
@@ -44,3 +50,3 @@ return this.value === item.value; | ||
*/ | ||
has(value: string | number | EnumItem): boolean { | ||
public has(value: string | number | EnumItem): boolean { | ||
if (value instanceof EnumItem) { | ||
@@ -55,3 +61,2 @@ return (value.value & this.value) !== 0; | ||
/** | ||
@@ -62,3 +67,3 @@ * Returns String representation of this EnumItem. | ||
*/ | ||
toString(): string { | ||
public toString(): string { | ||
return this.key; | ||
@@ -73,3 +78,3 @@ } | ||
toJSON(): any { | ||
public toJSON(): any { | ||
return this.key; | ||
@@ -84,3 +89,3 @@ } | ||
valueOf(): number { | ||
public valueOf(): number { | ||
return this.value; | ||
@@ -127,3 +132,3 @@ } | ||
for (const key in mm) { | ||
for (const key of Object.keys(mm)) { | ||
const val = mm[key]; | ||
@@ -151,6 +156,6 @@ if (undefined === val) { | ||
* @method get | ||
* @param {EnumItem || String || Number} key The object to get with. | ||
* @return {EnumItem} The get result. | ||
* @param key The object to get with. | ||
* @return the get result. | ||
*/ | ||
get(key: EnumItem | string | number): (EnumItem | null) { | ||
public get(key: EnumItem | string | number): (EnumItem | null) { | ||
@@ -181,4 +186,12 @@ const pThis = this as any; | ||
private _getByString(key: string): (EnumItem|null) { | ||
public getDefaultValue(): EnumItem { | ||
return this.enumItems[0]; | ||
} | ||
public toString(): string { | ||
return this.enumItems.join(" , "); | ||
} | ||
private _getByString(key: string): (EnumItem | null) { | ||
const pThis = this as any; | ||
@@ -209,3 +222,3 @@ const parts = key.split(" | "); | ||
private _getByNum(key: number): (EnumItem|null) { | ||
private _getByNum(key: number): (EnumItem | null) { | ||
@@ -218,6 +231,6 @@ if (key === 0) { | ||
let name; | ||
let c = 1, item; | ||
let c = 1; | ||
for (let i = 0; c < key; i++) { | ||
if ((c & key) === c) { | ||
item = pThis[c]; | ||
const item = pThis[c]; | ||
if (undefined === item) { | ||
@@ -241,9 +254,2 @@ return null; | ||
getDefaultValue(): EnumItem { | ||
return this.enumItems[0]; | ||
} | ||
toString() { | ||
return this.enumItems.join(" , "); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
11
21322
531