enumerated-type
Advanced tools
Comparing version 0.2.0 to 0.3.0
12
index.js
@@ -32,3 +32,3 @@ // 'use strict'; | ||
const symbol = Symbol(name); | ||
Object.defineProperty(this, '_value', { | ||
Object.defineProperty(this, 'value', { | ||
value: symbol, | ||
@@ -54,3 +54,3 @@ writable: false, | ||
} else { | ||
Object.defineProperty(this, '_value', { | ||
Object.defineProperty(this, 'value', { | ||
value: value, | ||
@@ -85,3 +85,3 @@ writable: false, | ||
if (hint === 'number') return this.enum.values.indexOf(this); | ||
return this._value; | ||
return this.value; | ||
}; | ||
@@ -192,3 +192,3 @@ | ||
} else { | ||
enumValues.sort((a, b) => a._value > b._value ? 1 : -1); | ||
enumValues.sort((a, b) => a.value > b.value ? 1 : -1); | ||
} | ||
@@ -223,3 +223,3 @@ | ||
} else { | ||
const enumKeys = enumValues.map(value => value._value); | ||
const enumKeys = enumValues.map(value => value.value); | ||
Object.defineProperty(this, 'keys', { | ||
@@ -235,3 +235,3 @@ value: enumKeys, | ||
return forEach.call(enumValues, (enumValue) => { | ||
if (enumValue._value === key) return BREAK(enumValue); | ||
if (enumValue.value === key) return BREAK(enumValue); | ||
}); | ||
@@ -238,0 +238,0 @@ }, |
{ | ||
"name": "enumerated-type", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "enum type for javascript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -142,7 +142,7 @@ # enumerated-type | ||
constructor. | ||
* `._value`: Symbol(name) symbol instance for the property name of the enum value. | ||
* `.value`: Symbol(name) symbol instance for the property name of the enum value. | ||
* `.index`: the enum value's index within enum instances values array. | ||
* `.next`: enum value after this enum or `undefined` if last enum value. | ||
* `.previous`: enum value before this enum or `undefined` if first enum value. | ||
* `[Symbol.toPrimitive]`: returns `_value` property for `string` or `default` hint, for `number` | ||
* `[Symbol.toPrimitive]`: returns `value` property for `string` or `default` hint, for `number` | ||
returns the enum value's index within enum instances values array. | ||
@@ -149,0 +149,0 @@ |
@@ -5,2 +5,3 @@ # Version History | ||
- [0.3.0](#030) | ||
- [0.2.0](#020) | ||
@@ -10,2 +11,6 @@ - [0.1.0](#010) | ||
## 0.3.0 | ||
* Change: `_value` to `value` property for enum value `Symbol` or non-object value. | ||
## 0.2.0 | ||
@@ -12,0 +17,0 @@ |
17149