{"id":23385963,"url":"https://github.com/dubisdev/flaggyjs","last_synced_at":"2025-04-08T12:15:51.339Z","repository":{"id":269096403,"uuid":"906412180","full_name":"dubisdev/flaggyjs","owner":"dubisdev","description":"FlaggyJS 🚩 - Manage bitewise flags wisely","archived":false,"fork":false,"pushed_at":"2024-12-27T19:10:42.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-14T08:15:36.219Z","etag":null,"topics":["binary-flags","bitwise-operations","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/flaggyjs","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dubisdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-20T21:11:49.000Z","updated_at":"2024-12-27T19:10:45.000Z","dependencies_parsed_at":"2024-12-20T22:23:31.761Z","dependency_job_id":"d5adc886-f111-4b06-8293-89c09af29a02","html_url":"https://github.com/dubisdev/flaggyjs","commit_stats":null,"previous_names":["dubisdev/flaggyjs"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dubisdev%2Fflaggyjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dubisdev%2Fflaggyjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dubisdev%2Fflaggyjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dubisdev%2Fflaggyjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dubisdev","download_url":"https://codeload.github.com/dubisdev/flaggyjs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247838447,"owners_count":21004580,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binary-flags","bitwise-operations","typescript"],"created_at":"2024-12-22T00:30:09.285Z","updated_at":"2025-04-08T12:15:51.311Z","avatar_url":"https://github.com/dubisdev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eFlaggyJS 🚩\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cstrong\u003eManage bitewise flags \u003ci\u003ewisely\u003c/i\u003e\u003c/strong\u003e\n  \u003cbr/\u003e\n  \u003ci\u003eBuilt with ❤️‍🔥 by \u003ca href=\"https://github.com/dubisdev\"\u003e@dubisdev\u003c/a\u003e\u003c/i\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg\n      src=\"https://img.shields.io/github/package-json/v/dubisdev/flaggyjs?label=Version\u0026style=flat-square\"\n      alt=\"Last available version\" /\u003e\n  \u003cimg\n      src=\"https://img.shields.io/badge/Dependencies-0-blue?style=flat-square\"\n      alt=\"Dependency count showing zero dependencies\" /\u003e\n  \u003cimg\n      src=\"https://img.shields.io/npm/d18m/flaggyjs?style=flat-square\u0026logoColor=blue\u0026label=Downloads\u0026color=blue\"\n      alt=\"Total downloads\" /\u003e\n\u003c/p\u003e\n\n\u003chr /\u003e\n\n`FlaggyJS` is a lightweight TypeScript library for managing bitwise flags.\nPowerful and efficient binary flags managing for permission systems, feature toggles, or any use-case.\n\n```typescript\n// 1. Import the library\nimport { useFlags } from \"flaggyjs\";\n\n// 2. Define your flags\nconst { flags, FlagsContainer } = useFlags([\"AMAZING\", \"SIMPLE\", \"BORING\"] as const);\n\n// 3. Create as many containers as you need\nconst flaggy = new FlagsContainer();\nconst documentation = new FlagsContainer([flags.SIMPLE, flags.BORING]); // Initialize with flags 🚀\n\n// 4. Start working with fully Typed flags\nflaggy.addFlag(flags.AMAZING); // Add one flag 🚩\nflaggy.addFlags(flags.SIMPLE, flags.BORING); // or many flags at once 🚄\nflaggy.removeFlag(flags.BORING); // Flaggy is not boring! 🎉\n\n// 🔒 FlaggyJS is type safe\n                   // v Argument of type \"Too Long\" is not assignable... // Fails type checking\ndocumentation.addFlag(\"Too Long\") // ⚠️ Error! =\u003e Invalid flag provided  // Also on runtime\n\n// 5. Evaluate your flags when needed\nconsole.log(flaggy.hasFlag(flags.AMAZING)); // true\nconsole.log(documentation.hasFlag(flags.SIMPLE)); // true\nconsole.log(flaggy.hasFlag(flags.BORING)); // false\n\nconsole.log(flags)\n// {\n//     AMAZING: \"AMAZING\",\n//     SIMPLE: \"SIMPLE\",\n//     BORING: \"BORING\"\n// }\n```\n\n## Features\n\n- 🔒 **Type-safe flag management** [without Enums](https://www.totaltypescript.com/why-i-dont-like-typescript-enums).\n- 🤏 **Zero dependencies** - No extra packages are used.\n- 🧙‍♂️ **Bitwise operations**: Efficiently manage flags with bitwise operations under the hood.\n- 🔎 **Validation**: Ensures invalid flags are caught early.\n- 💎 **Immutable flag definitions**: Prevent accidental changes to the flag definitions.\n\n## Installation\n\n```bash\nnpm install flaggyjs\n```\n\n## API\n\n- **`hasFlag(flag: FlagId): boolean`**\n  Checks if a flag is currently set.\n\n- **`addFlag(flag: FlagId): void`**\n  Adds a flag to the current set.\n\n- **`removeFlag(flag: FlagId): void`**\n  Removes a flag from the current set.\n\n- **`addFlags(...flags: FlagId[]): void`**\n  Adds multiple flags at once.\n\n## Testing\n\nThe package uses [Vitest](https://vitest.dev/) for testing. To run the tests:\n\n```bash\nbun run test\n```\n\n## Development\n\n### Building\n\nThe package uses `tsc` for building TypeScript into JavaScript:\n\n```bash\nbun run build\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdubisdev%2Fflaggyjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdubisdev%2Fflaggyjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdubisdev%2Fflaggyjs/lists"}