Home Manual Reference Source
public class | source

Enum

You can directly use an instance of this class. DeletedState JobMonitorFilter JobShareVisibility ResultStatus

Extends:

Unobservable → Enum

Base enum class

Example:

const Colors = new Enum(['RED', 'BLACK', 'GREEN', 'WHITE', 'BLUE']);

const Answers = new Enum({
  YES: true,
  NO: false,
  // Passing functions as values will turn them into getters
  // Getter results will appear in ::values
  MAYBE: () => Math.random() >= 0.5,
});

const FontStyles = new Enum(['italic', 'bold', 'underline', 'regular'], true);
FontStyles.ITALIC === 'italic'
FontStyles.BOLD   === 'bold'

// etc...

Constructor Summary

Public Constructor
public

constructor(enums: Object<String, *>|Array<String>, auto: boolean)

Method Summary

Public Methods
public

keys(): Array

List enum keys

public

values(): Array<*>

List enum values

Inherited Summary

From class Unobservable
public get

Overrides the Object.prototype.toString.call(obj) result

Public Constructors

public constructor(enums: Object<String, *>|Array<String>, auto: boolean) source

Params:

NameTypeAttributeDescription
enums Object<String, *>|Array<String>

Data to build the enum from

auto boolean

Auto generate enum from data making assumptions about the data, requires enums to be of type array.

Public Methods

public keys(): Array source

List enum keys

Return:

Array

Enum keys

public values(): Array<*> source

List enum values

Return:

Array<*>

Enum values