Extends
Methods
forEach(_callback, _thisArgopt)
Iterate over all enum name/value pairs. Signature attempts to match Array.prototype.forEach.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
_callback |
function | The callback, called with _value, _name, _enum |
|
_thisArg |
object |
<optional> |
Optional: the scope to call the callback in. |
hasName(_name, _caseInsensitiveopt) → {boolean}
Enum method: check if the enum has the specified name
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
_name |
string | The name to check |
||
_caseInsensitive |
boolean |
<optional> |
false | Optional, set to true to perform a case insensitive search |
Returns:
True if the enum has the name, false otherwise.
- Type
- boolean
hasOwnProperty(_name) → {boolean}
A SpecialType is not instanceof Object, but does have the Object.prototype.hasOwnProperty method.
Parameters:
Name | Type | Description |
---|---|---|
_name |
string | The name of the property to check |
- Inherited From:
- Source:
Returns:
True if the object has a direct property with _name, false otherwise.
- Type
- boolean
hasValue(_value) → {boolean}
Check if the enum has the specified value
Parameters:
Name | Type | Description |
---|---|---|
_value |
object | The enum value to check for |
Returns:
True if the enum has the value, false otherwise.
- Type
- boolean
nameOf(_value)
Enum method: get the name of the specified value. If multiple names lead to the same value, the first found name is returned
Parameters:
Name | Type | Description |
---|---|---|
_value |
string | The value for which to get the name |
Returns:
The name of the value, or null if not found
names() → {Array}
Get the names of an enum
Returns:
The names of an enum
- Type
- Array
parse(_value, _caseInsensitive, _throwopt)
Utility method to parse an enum value, for example from input parsed from JSON. Takes the following steps:
1. if _value is an actual enum value, return _value.
2. if _value is a name of enum, return the value of that name
3. if _throw is true, throw a RangeError
4. return null
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
_value |
The value to parse |
|||
_caseInsensitive |
boolean | Whether name matching should be case insensitive. Defaults to false, specify true for case insensitive. |
||
_throw |
boolean |
<optional> |
false | Optional: set to true to perform strict validation. |
Returns:
The parsed value, or null if the value didn't parse.
toString() → {string}
toString for Enum.
Returns:
The string [enum EnumName], where EnumName is the name of the enum constructor function, or "Enum" for anonymous enumerations.
- Type
- string
valueOf(_name, _caseInsensitiveopt) → {object}
Enum method: get the value of the specified name
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
_name |
string | The name of the value to get |
||
_caseInsensitive |
boolean |
<optional> |
false | Optional, set to true to perform a case insensitive search |
Returns:
The enum value, or null if it wasn't found.
- Type
- object
values() → {Array}
Get the values of an enum
Returns:
The values of an enum
- Type
- Array