Flags enums

Hydroper hydroperhh at gmail.com
Wed Aug 26 20:20:45 UTC 2020


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'],
    ['CUBIC_BEZIER_CURVE', [10]],
    ['RIGID_BODY', ['rigidBody', 2]]
]);

var type = CollisionType('cubicBezierCurve');
console.log( type == 'cubicBezierCurve' );

valueOf() in this case will return String. If you need number, use the
'number' property.

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20200826/7d939b7d/attachment.html>


More information about the es-discuss mailing list