{"id":16513763,"url":"https://github.com/wintercounter/fleg","last_synced_at":"2025-03-02T04:32:57.815Z","repository":{"id":143799110,"uuid":"300223469","full_name":"wintercounter/fleg","owner":"wintercounter","description":"🎌 A simple but powerful feature flag handling solution in less than 1Kb (min+gz). Browser + NodeJS.","archived":false,"fork":false,"pushed_at":"2020-10-07T10:09:29.000Z","size":8,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-23T06:11:43.394Z","etag":null,"topics":["browser","cookie","feature-flags","flag","flags","nodejs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wintercounter.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2020-10-01T09:33:36.000Z","updated_at":"2023-03-09T03:30:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"b61a87cb-af03-4590-9b94-e96cafac07d4","html_url":"https://github.com/wintercounter/fleg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wintercounter%2Ffleg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wintercounter%2Ffleg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wintercounter%2Ffleg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wintercounter%2Ffleg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wintercounter","download_url":"https://codeload.github.com/wintercounter/fleg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241460058,"owners_count":19966511,"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":["browser","cookie","feature-flags","flag","flags","nodejs"],"created_at":"2024-10-11T16:10:13.334Z","updated_at":"2025-03-02T04:32:57.796Z","avatar_url":"https://github.com/wintercounter.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fleg (https://en.wiktionary.org/wiki/fleg)\n\n🎌 A simple but powerful feature flag handling solution.\n\n-   Control through Cookies.\n-   Control through Query String.\n-   Automatic value conversion.\n-   Browser support.\n-   NodeJS support.\n-   0 dependency.\n-   Less than 1Kb (min+gz).\n\n## Installation\n\n```bash\nnpm i fleg\n```\n\n## Usage\n\nFleg is meant to be initialized **ONLY ONCE**!\n\nDuring bootstrap stage (at the very beginning) of your application, import Fleg and define your initial flags.\n\n```js\nimport { Fleg } from 'fleg'\n\nnew Fleg({\n    enableFoo: true,\n    enableBar: false,\n    stringFlag: 'string'\n})\n```\n\nFurther on at any other part of the application use the default import. It will be the Fleg instance you created previously.\n\n```js\nimport fleg from 'fleg'\n\nfleg.enableFoo // true\n```\n\n## API\n\nFleg is extending `Map` which means all Map APIs are available. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map\n\n```js\nfleg.get('enableFoo')\nfleg.set('enableFoo', false)\n// ...\n```\n\n### `set(key: string|array|object, value: any, writeCookie?: boolean)`\n\nFleg overrides the default `set` method of `Map` to extend its functionality.\n\n```js\n// Passing true will write this flag to cookies\nfleg.set('key', 'value', true)\n\n// You may pass an \"entries shaped\" array\nfleg.set([\n    ['key', 'value'],\n    ['foo', 'bar']\n])\n\n// Pass object\nfleg.set({\n    enableFoo: 1,\n    enableBar: 2\n})\n```\n\n### `delete(key: string)`\n\nDelete a flag. It'll also remove associated cookies.\n\n```js\nfleg.delete('enableFoo')\n```\n\n### `reset()`\n\nReset flags back to initial state (what was passed to the constructor).\n\n### `resetFleg` Query String option\n\nFor convenience, you can add `resetFleg` query string to your URL to remove all cookie flags.\n\n```\ne.g. yourdomain.com?resetFleg\n```\n\n### Globals\n\nFor convenience, the created Fleg instance can be accessed on the global scope both in NodeJS and the Browser.\n\n```js\nglobal.__fleg\nwindow.__fleg\n```\n\n## Layered control\n\nFleg has **3 layers** in the following order of loading:\n\n1. **Initial flags**: what is passed to the constructor.\n2. **Cookie flags**: cookie flags will override initial flags.\n3. **Query String flags**: will override all other flags AND will also set it as cookie, so it'll remain on next reload.\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update tests as appropriate.\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwintercounter%2Ffleg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwintercounter%2Ffleg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwintercounter%2Ffleg/lists"}