Home Reference Source

src/utils/Enum.js

/** @private */
export function Enum(...args) {
	if (!(this instanceof Enum)) {
		return new Enum(...args);
	}
	let list;
	if (args.length === 1 && Array.isArray(args[0])) {
		list = args[0];
	} else {
		list = args;
	}
	list.forEach((arg) => {
		let symbol = Symbol(arg);
		this[arg] = symbol;
		this[symbol] = arg;
	});
	Object.freeze(this);
}