Re: Re: Flags enums

2020-08-26 Thread Matheus Dias de Souza
I was aware of TypeScript, but with Enum/FlagsEnum you can still do: ```o.collisionType = ‘circle’;``` ... As long as there’s this code in O: ```set collisionType(v) { this._type = CollisionType(v); }``` When some f() takes a CollisionType, it takes any argument and calls CollisionType(v). A

Re: Re: Flags enums

2020-08-26 Thread Jacob Bloom
For what it's worth, TypeScript has Enums built-in and I find myself using string literal types instead: ```typescript type CollisionType = 'CIRCLE' | 'CUBIC_BEZIER_CURVE' | 'RIGID_BODY'; function handleCollision(type: CollisionType) { if (type === 'CIRCLE') { // ... } else if (type ===

Re: Re: Flags enums

2020-08-26 Thread Matheus Dias de Souza
 The com.siteblade.util package contains an approximation of this in ECMAScript, with no difference, except the valueOf() method (which returns String for working with equality), so it ends up with an additional getter ‘number’. https://www.npmjs.com/package/com.siteblade.util You can use either

Re: Flags enums

2020-08-26 Thread Hydroper
The com.siteblade.util package contains an approximation of this in ECMAScript. https://www.npmjs.com/package/com.siteblade.util You can use either FlagsEnum or Enum. import { Enum } from 'com.siteblade.util'; const CollisionType = Enum('CollisionType', [ ['CIRCLE'],

Flags enums

2020-08-20 Thread Hydroper
Flags enums would be primitive classes with constants (_name_:String, _value_:Number). It'd be very, very efficient. Of course it's easy to use POJOs (`{}`) instead of numeric values, but this feature would only provide performance advantages. The following program implies: - `String(E.FNX