{"id":24530080,"url":"https://github.com/dipunm/smart-feature-toggles","last_synced_at":"2025-03-15T18:21:48.578Z","repository":{"id":57363845,"uuid":"140895051","full_name":"dipunm/smart-feature-toggles","owner":"dipunm","description":"A smart feature toggle library with housekeeping and dependency features","archived":false,"fork":false,"pushed_at":"2018-08-24T12:31:15.000Z","size":194,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-22T14:37:18.862Z","etag":null,"topics":["alerting","expiration","feature-flags","feature-toggles","housekeeping","multi-source"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/dipunm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-13T21:37:26.000Z","updated_at":"2018-08-24T12:31:16.000Z","dependencies_parsed_at":"2022-09-16T17:00:33.053Z","dependency_job_id":null,"html_url":"https://github.com/dipunm/smart-feature-toggles","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dipunm%2Fsmart-feature-toggles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dipunm%2Fsmart-feature-toggles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dipunm%2Fsmart-feature-toggles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dipunm%2Fsmart-feature-toggles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dipunm","download_url":"https://codeload.github.com/dipunm/smart-feature-toggles/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243770861,"owners_count":20345360,"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":["alerting","expiration","feature-flags","feature-toggles","housekeeping","multi-source"],"created_at":"2025-01-22T07:53:32.777Z","updated_at":"2025-03-15T18:21:48.549Z","avatar_url":"https://github.com/dipunm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Smart feature toggles\n\n[![Build Status](https://travis-ci.com/dipunm/smart-feature-toggles.svg?branch=master)](https://travis-ci.com/dipunm/smart-feature-toggles) ![Client bundle size](https://img.badgesize.io/https://s3.eu-west-2.amazonaws.com/smart-feature-toggles/bundle-web-lite.js?label=client%20size) ![Client bundle size](https://img.badgesize.io/https://s3.eu-west-2.amazonaws.com/smart-feature-toggles/bundle-web-lite.js?label=client%20size%20gzipped\u0026compression=gzip)\n\n_Client sizes are based on a webpack bundle using the lite version of the library. (See [Lite Client](#lite-client))_\n\n## Contents\n\n- [Installation](#installation)\n- [Defining toggles](#defining-toggles)\n- [Usage](#usage)\n- [Features](#features)\n\n## Installation\n\n```bash\nnpm install smart-feature-toggles\n```\n\n## Defining toggles\n\n- A feature toggle may only be `active` or `inactive`.\n- Feature toggles can be scoped (eg. to a http request, or to an\n  application context).\n- A feature toggle _should not_ change value between calls\\*.\n- A feature toggle cannot be given arguments when being queried. All\n  [dependencies](#dependencies) should be defined and ready before a toggle\n  is queried.\n- A feature toggle can be set up to alert developers when it is becoming\n  old.\n\n\\*Smart feature toggles will cache the calculated value based on this\nassumption, but the [auto reset feature](#auto-resets) exists to satisfy\nmore dynamic toggles.\n\n## Usage\n\n#### Require `smart-feature-toggles`:\n\n```js\nconst FeatureToggles = require('smart-feature-toggles');\n```\n\n#### Set up alert handling: (see: [Housekeeping](#housekeeping))\n\n```js\nFeatureToggles.onHealthAlert((name, alert) =\u003e console.log(name, alert));\n```\n\n#### Name and configure your features:\n\n```js\nconst features = [\n  {\n    name: 'my-feature',\n\n    dependencies: ['request'],\n\n    test: request =\u003e request.query.test_mode,\n\n    health: () =\u003e {\n      // If the toggle is getting old, return an alert\n      if (new Date().getFullYear() \u003e 2018) {\n        return 'my-feature toggle is getting old!';\n      }\n    },\n  },\n];\n```\n\n#### Create your toggle client:\n\n```js\nconst toggles = FeatureToggles.create(features);\n```\n\n#### Define your dependencies: (see: [Dependencies](#dependencies))\n\n```js\nconst request = { query: { test_mode: true } };\ntoggles.defineDependency('request', request);\n```\n\n#### Use your feature toggle:\n\n```js\nif (toggles.get('my-feature')) { // true\n    ...\n}\n\n// alternative syntax.\ntoggles.values['my-feature']; // true\n\n// once evaluated, the toggle will\n// always return it's original value\nrequest.query.test_mode = false;\ntoggles.get('my-feature'); // true\n```\n\n#### Toggles _can_ be set up to auto update (see: [Auto Resets](#auto-resets))\n\n# Features\n\n### Scoping:\n\nRead about [Scoping](docs/features/SCOPING.md)\n\n### Housekeeping:\n\nRead about [Housekeeping](docs/features/HOUSEKEEPING.md)\n\n### Dependencies:\n\nRead about [Dependencies](docs/features/DEPENDENCIES.md)\n\n### Serialization:\n\nRead about [Serialization](docs/features/SERIALIZATION.md)\n\n### Auto Resets:\n\nRead about [Auto Resets](docs/features/AUTO_RESETS.md)\n\n### Browser Compatibility:\n\nRead about the [Browser Compatibility](docs/features/BROWSER_COMPATIBILITY.md)\n\n### Lite Client:\n\nRead about the [Lite Client](docs/features/LITE_CLIENT.md)\n\n# API\n\nsee the [API docs](#api). (coming soon)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdipunm%2Fsmart-feature-toggles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdipunm%2Fsmart-feature-toggles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdipunm%2Fsmart-feature-toggles/lists"}