Enum
Direct Subclass:
This is an abstract class that is not intended to be used directly. Extend it to turn your class into an enum
(initialization is performed via MyClass.initEnum()
).
Modified from source provided by enumify (license unlisted / public domain)
Static Method Summary
Static Public Methods | ||
public static |
[Symbol.iterator](): Symbol.iterator Make enum classes iterable |
|
public static |
enumValueOf(name: string): T Given the name of an enum constant, return its value. |
|
public static |
Set up the enum, close the class. |
Static Private Methods | ||
private static |
_enumValuesFromArray(arr: *) |
|
private static |
_enumValuesFromObject(obj: *) |
|
private static |
_pushEnumValue(enumValue: *, name: *) |
Constructor Summary
Public Constructor | ||
public |
constructor(instanceProperties: object)
|
Method Summary
Public Methods | ||
public |
Default |
Static Public Methods
public static [Symbol.iterator](): Symbol.iterator source
Make enum classes iterable
Return:
Symbol.iterator |
public static enumValueOf(name: string): T source
Given the name of an enum constant, return its value.
Params:
Name | Type | Attribute | Description |
name | string | An enum name. |
Return:
T |
public static initEnum(arg: Array | object): Enum source
Set up the enum, close the class.
Params:
Name | Type | Attribute | Description |
arg | Array | object | Either an object whose properties provide the names and values (which must be mutable objects) of the enum constants. Or an Array whose elements are used as the names of the enum constants. The values are create by instantiating the current class. |
Static Private Methods
private static _enumValuesFromArray(arr: *) source
Params:
Name | Type | Attribute | Description |
arr | * |
private static _enumValuesFromObject(obj: *) source
Params:
Name | Type | Attribute | Description |
obj | * |
private static _pushEnumValue(enumValue: *, name: *) source
Params:
Name | Type | Attribute | Description |
enumValue | * | ||
name | * |
Public Constructors
public constructor(instanceProperties: object) source
initEnum()
closes the class. Then calling this constructor throws an exception.
If your subclass has a constructor then you can control what properties are added to this
via the argument you
pass to super()
. No arguments are fine, too.
Params:
Name | Type | Attribute | Description |
instanceProperties | object | Provides initial properties. |