Flags
is a flexible and robust flag management system, designed for use with
UrsaMU in Deno. It allows for easy handling and querying of flags, which can
represent various states or features in an entity component system (ECS).
- Add and manage custom flags.
- Check if flags exist and retrieve their properties.
- Evaluate flag expressions to determine complex state conditions.
- Handle flag groups for organized management.
Since this module is designed for Deno, no package manager is needed. Import it directly into your Deno project:
import { Flags } from "https://raw.githubusercontent.com/UrsaMU/flags/main/mod.ts";
const flags = new Flags(
{ name: "admin", code: "A", lvl: 1 },
{ name: "user", code: "U", lvl: 0 },
);
flags.add({ name: "moderator", code: "M", lvl: 2 });
const hasAdmin = flags.exists("admin");
const isAuthorized = flags.check("admin user", "admin | moderator");
let data = {};
const result = flags.set("user", data, "admin");
Add one or more flags to the system.
Check if a flag exists and return the flag object.
Check a list of flags against a flag expression.
Set and modify flags based on an expression.
To run tests in Deno:
deno test
MIT
Contributions are welcome. Please submit a pull request or an issue if you have any improvements or ideas.