src/Enum.js
function Enum(name, values) {
  /** The generic Enum instance
   * @constructor
   */
  function EnumInstance(x) {return _.includes(EnumInstance, x)}
  Object.defineProperties(EnumInstance,
    { __jsmf__: {value: {uuid: generateId(), conformsTo: Enum}}
    , __name: {value: name}
    , getName: {value: getName}
    , conformsTo: {value: () => conformsTo(EnumInstance)}
    })
  if (_.isArray(values)) {
    _.forEach(values, (v, k) => EnumInstance[v] = k)
  } else {
    _.forEach(values, (v, k) => EnumInstance[k] = v)
  }
  return EnumInstance
}
function Enum(name, values) {
  /** The generic Enum instance
   * @constructor
   */
  function EnumInstance(x) {return _.includes(EnumInstance, x)}
  Object.defineProperties(EnumInstance,
    { __jsmf__: {value: {uuid: generateId(), conformsTo: Enum}}
    , __name: {value: name}
    , getName: {value: getName}
    , conformsTo: {value: () => conformsTo(EnumInstance)}
    })
  if (_.isArray(values)) {
    _.forEach(values, (v, k) => EnumInstance[v] = k)
  } else {
    _.forEach(values, (v, k) => EnumInstance[k] = v)
  }
  return EnumInstance
}
function Enum ( name , values ) { /** The generic Enum instance
   * @constructor
   */ function EnumInstance ( x ) { return _ . includes ( EnumInstance , x ) } Object . defineProperties ( EnumInstance , { __jsmf__ : { value : { uuid : generateId ( ) , conformsTo : Enum } } , __name : { value : name } , getName : { value : getName } , conformsTo : { value : ( ) => conformsTo ( EnumInstance ) } } ) if ( _ . isArray ( values ) ) { _ . forEach ( values , ( v , k ) => EnumInstance [ v ] = k ) } else { _ . forEach ( values , ( v , k ) => EnumInstance [ k ] = v ) } return EnumInstance }
Define an Enum
@constructor
@param {string} name - The name of the created Enum
@param values - Either an Array of string or an Object.
If an Array is provided, the indexes are used as Enum values.
Define an Enum