Enum

Enumeration class. Each enum propertiy has the properties "ordinal", "name" and "text".

נכון ליום 03-11-2019. ראה הגרסה האחרונה.

אין להתקין סקריפט זה ישירות. זוהי ספריה עבור סקריפטים אחרים // @require https://update.greatest.deepsurf.us/scripts/391854/746195/Enum.js

יוצר
Gerrit
גרסה
0.2
נוצר
01-11-2019
עודכן
03-11-2019
Size
2.37 קילו-בייט
רישיון
לא זמין
// Usage Example 1
class COLOR extends Enum {};
COLOR.init([ { "RED": "red" }, { "GREEN": "green" }, { "BLUE": "blue" } ]);
let col = COLOR.GREEN;

console.log(col.name);       // "GREEN"
console.log(col.text);       // "green"
console.assert(col.ordinal); // "1"

console.assert(col + "");    // "green"
console.assert(col * 1);     // "1"

// Usage Example 2
class COLOR extends Enum {};
COLOR.init([ "RED", "GREEN", "BLUE" ]);

console.log(col.name);       // "BLUE"
console.log(col.text);       // ""
console.assert(col.ordinal); // "2"

console.assert(col + "");    // "BLUE"
console.assert(col * 1);     // "2"

// Usage Example 3
class FLAGS extends Enum {};
FLAGS.init([ "FIRST", "SECOND", "THIRD", "FOURTH"], 1, ord => ord<<1);
console.log(FLAGS.FOURTH | FLAGS.SECOND);