/** Base class for all Breeze enumerations, such as EntityState, DataType, FetchStrategy, MergeStrategy etc. A Breeze Enum is a namespaced set of constant values. Each Enum consists of a group of related constants, called 'symbols'. Unlike enums in some other environments, each 'symbol' can have both methods and properties. ```ts class DayOfWeek extends BreezeEnum { dayIndex: number; isWeekend?: boolean; nextDay() { let nextIndex = (this.dayIndex + 1) % 7; return DayOfWeek.getSymbols()[nextIndex]; } static Monday = new DayOfWeek( { dayIndex: 0}); static Tuesday = new DayOfWeek( { dayIndex: 1 }); static Wednesday = new DayOfWeek( { dayIndex: 2 }); static Thursday = new DayOfWeek( { dayIndex: 3 }); static Friday = new DayOfWeek( { dayIndex: 4 }); static Saturday = new DayOfWeek( { dayIndex: 5, isWeekend: true }); static Sunday = new DayOfWeek( { dayIndex: 6, isWeekend: true }); } describe("DayOfWeek", () => { test("should support full enum capabilities", function() { // // custom methods let dowSymbols = DayOfWeek.getSymbols(); expect(dowSymbols.length).toBe(7); expect(DayOfWeek.Monday.nextDay()).toBe(DayOfWeek.Tuesday); expect(DayOfWeek.Sunday.nextDay()).toBe(DayOfWeek.Monday); // // custom properties expect(DayOfWeek.Tuesday.isWeekend).toBe(undefined); expect(DayOfWeek.Saturday.isWeekend).toBe(true); // // Standard enum capabilities expect(DayOfWeek.Thursday instanceof DayOfWeek).toBe(true); expect(BreezeEnum.isSymbol(DayOfWeek.Wednesday)).toBe(true); expect(DayOfWeek.contains(DayOfWeek.Thursday)).toBe(true); expect(DayOfWeek.Friday.toString()).toBe("Friday"); }); }); ``` Each enum module calls `resolveSymbols()` at import time. Until v3 those calls were written as `Error['x'] = MyEnum.resolveSymbols()`, to keep a bundler from discarding a call whose result nothing uses. That is no longer needed: `package.json` declares every module but the entity-graph mixin side-effect free, so a module is kept exactly when something uses one of its exports - and whatever needs the resolved symbols does. See the sideEffects section of CHANGES-DEV.md. */ export declare class BreezeEnum { /** The name of this symbol */ name: string; /** Type of the enum; set in prototype of each enum */ _$typeName: string; /** Creates a symbol, copying each property of `propertiesObj` onto it. Used to declare the symbols of an enum, as static members of its class; its name is set when the class calls {@link BreezeEnum.resolveSymbols}. */ constructor(propertiesObj?: Object); /** Returns all of the symbols contained within this Enum. ```ts let symbols = DayOfWeek.getSymbols(); ``` @returns All of the symbols contained within this Enum. */ static getSymbols(this: T): InstanceType[]; /** Returns the names of all of the symbols contained within this Enum. ```ts let symbols = DayOfWeek.getNames(); ``` @returns All of the names of the symbols contained within this Enum. */ static getNames(): string[]; /** Returns an Enum symbol given its name. ```ts let dayOfWeek = DayOfWeek.from("Thursday"); // nowdayOfWeek === DayOfWeek.Thursday ``` @param name - Name for which an enum symbol should be returned. @returns The symbol that matches the name or 'undefined' if not found. */ static fromName(name: string): any; /** Seals this enum so that no more symbols may be added to it. This should only be called after all symbols have already been added to the Enum. This method also sets the 'name' property on each of the symbols. ```ts DayOfWeek.resolveSymbols(); ``` */ static resolveSymbols(): { /** The symbol's name, such as `"Added"`. */ name: string; /** The symbol itself, such as `EntityState.Added`. */ symbol: BreezeEnum; }[]; /** Returns whether an Enum contains a specified symbol. ```ts let symbol = DayOfWeek.Friday; if (DayOfWeek.contains(symbol)) { // do something } ``` @param sym - Object or symbol to test. @returns Whether this Enum contains the specified symbol. */ static contains(sym: BreezeEnum): boolean; /** Returns the string name of this Enum */ toString(): string; /** Return enum name and symbol name */ toJSON(): { /** The name of the enum, such as `"EntityState"`. */ _$typeName: any; /** The name of the symbol, such as `"Added"`. */ name: string; }; }