{"id":22105607,"url":"https://github.com/btmpl/feature-toggle","last_synced_at":"2025-03-24T02:47:46.751Z","repository":{"id":57360102,"uuid":"77825125","full_name":"BTMPL/feature-toggle","owner":"BTMPL","description":"A simple library allowing you to hide code implementation behind a feature-toggle flag. Allows for nested features and callbacks.","archived":false,"fork":false,"pushed_at":"2017-01-02T11:27:06.000Z","size":6,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-24T11:01:50.301Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/BTMPL.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}},"created_at":"2017-01-02T10:14:04.000Z","updated_at":"2018-01-05T02:59:51.000Z","dependencies_parsed_at":"2022-09-06T21:41:16.806Z","dependency_job_id":null,"html_url":"https://github.com/BTMPL/feature-toggle","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/BTMPL%2Ffeature-toggle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BTMPL%2Ffeature-toggle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BTMPL%2Ffeature-toggle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BTMPL%2Ffeature-toggle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BTMPL","download_url":"https://codeload.github.com/BTMPL/feature-toggle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245200680,"owners_count":20576673,"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":[],"created_at":"2024-12-01T06:47:39.007Z","updated_at":"2025-03-24T02:47:46.719Z","avatar_url":"https://github.com/BTMPL.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## USAGE\n\n```js\nvar featureToggle = require(\"simple-feature-toggle\");\n\nfeatureToggle.set({\n  root: {\n    child: {\n      flag1: false\n    }\n  }\n});\n\nif(featureToggle.isEnabled(\"root.child.flag1\")) {\n  console.log(\"root.child.feature1 is enabled\");\n}\nelse {\n  console.log(\"root.child.feature1 is disabled\");\n}\n```\n\n## API\n\n```js\nfeatureToggle.set(Object flagset)\n```\n\nLoad or update an existing flag set. The value should be an object with each\nleaf being either a boolean or function that when evaluate returns a boolean.\n\nCalling the function multiple time will merge the flag set using [_.merge](https://lodash.com/docs#merge)\n\n```js\nfeatureToggle.reset()\n```\n\nResets the flag set to an empty set. Useful when you want to replace the current\nset with a new one, and not update it.\n\n```js\nfeatureToggle.isEnabled(String, [param1, param2, ....])\n```\n\nChecks the flag set against an selector supplied as a `dot.string.notation`.\nIf the expected value is a function, you can pass additional parameters which\nwill be then passed to the function at runtime.\n\n```js\nfeatureToggle.isDisabled(String, [param1, param2, ...])\n```\n\nReturns the opposite of `isEnabled`\n\n```js\nfeatureToggle.data\n```\n\nObject holding the current flag set. Please use `set()` and `reset()` to alter.\n\n```js\nfeatureToggle.assumeEnabledByDefault\n```\n\nThe value to be returned when the queries key (using `isEnabled`, `isDisabled`)\nfails to find the value in the flag set. By default `true` allowing the lib to\nbe used to disable functionality rather than enable it.\n\n```js\nfeatureToggle.resolveNested\n```\n\nDecides if the app can query for whole flag objects as valid `isEnabled` and\n`isDisabled` response. This can be useful to lock/unlock a whole group of\nfeatures and each individual one later on.\n\n```js\nfeatureToggle.resolveNested()\n```\n\nIf `featureToggle.resolveNested` is enabled, decides on value to be returned when\nresolving with an object. Returns `featureToggle.assumeEnabledByDefault` by\ndefault.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbtmpl%2Ffeature-toggle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbtmpl%2Ffeature-toggle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbtmpl%2Ffeature-toggle/lists"}