FredKSchott/fflip hiện có 649 sao trên GitHub, viết chủ yếu bằng JavaScript. Flexible Feature Flipping/Flagging for Node.js
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Working on an experimental new design? Starting a closed beta? Rolling out a new feature over the next few weeks? Fa-fa-fa-flip it. fflip gives you complete control over releasing new functionality to your users based on their user id, join date, membership status, and whatever else you can think of. fflip's goal is to be the most powerful and extensible feature flipping/toggling module out there.
Create custom criteria to segment users & features based on your audience.
View & edit feature access in one easy place, and not scattered around your code base.
System-Agnostic: Support any database, user representation or web framework you can throw at it.
Extensible: Supports 3rd-party plugins for your favorite libraries (like our Express integration!)
npm install fflip --save
Integrations
As mentioned, fflip's goal is to be flexible enough to integrate with any web framework, database, or ORM. The following integrations are known to exist:
fflip-express: Express.js integration
If you're interested in creating an integration, don't hesitate to reach out or create an issue if some functionality is missing. And if you've created an integration, please add it to the list above!
Getting Started
Below is a simple example that uses fflip to deliver a closed beta to a fraction of users:
// Include fflip
let fflip = require('fflip');
fflip.config({
criteria: ExampleCriteria, // defined below
features: ExampleFeatures // defined below
});
// Get all of a user's enabled features...
someFreeUser.features = fflip.getFeaturesForUser(someFreeUser);
if(someFreeUser.features.closedBeta === true) {
console.log('Welcome to the Closed Beta!');
}
// ... or just check this single feature.
if (fflip.isFeatureEnabledForUser('closedBeta', someFreeUser) === true) {
console.log('Welcome to the Closed Beta!');
}
Criteria
Criteria are the rules that define access to different features. Each criteria takes a user object and some data as arguments, and returns true/false if the user matches that criteria. You will use these criteria to restrict/allow features for different subsets of your userbase.
Features represent some special behaviors in your application. They also define a set of criteria to test users against for each feature. When you ask fflip if a feature is enabled for some user, it will check that user against each rule/criteria, and return "true" if the user passes.
Features are described in the following way:
let ExampleFeatures = [
{
id: 'closedBeta', // required
// if `criteria` is in an object, ALL criteria in that set must evaluate to true to enable for user
criteria: {isPaidUser: true, percentageOfUsers: 0.50}
},
{
id: 'newFeatureRollout',
// if `criteria` is in an array, ANY ONE set of criteria must evaluate to true to enable for user
criteria: [{isPaidUser: true}, {percentageOfUsers: 0.50}]
},
{
id: 'experimentalFeature',
name: 'An Experimental Feature', // user-defined properties are optional but can be used to add important metadata on both criteria & features
description: 'Experimental feature still in development, useful for internal development', // user-defined
owner: 'Fred K. Schott <[email protected]>', // user-defined
enabled: false, // sets the feature on or off for all users, required if `criteria` is not present
},
]
The value present for each rule is passed in as the data argument to it's criteria function. This allows you to write more general, flexible, reusable rules.
Rule sets & lists can be nested and combined. It can help to think of criteria sets as a group of AND operators, and lists as a set of OR operators.
Veto Criteria
If you'd like to allow wider access to your feature while still preventing a specific group of users, you can use the $veto property. If the $veto property is present on a member of a criteria list (array), and that member evaluates to false, the entire list will evaluate to false regardless of it's other members.
{
// Enabled if user is paid OR in the lucky 50% group of other users currently using a modern browser
criteria: [{isPaidUser: true}, {percentageOfUsers: 0.50, usingModernBrowser: true}]
// Enabled if user is paid OR in the lucky 50% group of other users, BUT ONLY if using a modern browser
criteria: [{isPaidUser: true}, {percentageOfUsers: 0.50}, {usingModernBrowser: true, $veto: true}]
}
Usage
.config(options) -> void: Configure fflip (see below)
.isFeatureEnabledForUser(featureName, user) -> boolean: Return true/false if featureName is enabled for user
.getFeaturesForUser(user) -> Object: Return object of true/false for all features for user
.reload() -> void: Force a reload (if loading features dynamically)
Configuration
Configure fflip using any of the following options:
fflip.config({
criteria: {}, // Criteria Array
features: {}, // Features Array | Function (see below)
reload: 30, // Interval for refreshing features, in seconds
});
Loading Features Dynamically
fflip also accepts functions for loading features. If fflip is passed a function with no arguments it will call the function and accept the return value. To load asynchronously, pass a function that sends a features object to a callback. fflip will receive the callback and set the data accordingly. In both cases, fflip will save the function and call it again every X seconds, as set by the reload parameter.
// Load Criteria Synchronously
let getFeaturesSync = function() {
let collection = db.collection('features');
let featuresArr = collection.find().toArray();
/* Process/Format `featuresArr` if needed (format described above) */
return featuresArr;
}
// Load Features Asynchronously
let getFeaturesAsync = function(callback) {
let collection = db.collection('features');
collection.find().toArray(function(err, featuresArr) {
/* Handle err
* Process/Format `featuresArr` if needed (format described above) */
callback(featuresArr);
});
}
fflip.config({
criteria: ExampleCriteriaObject,
features: getFeaturesAsync, // or: getFeaturesSync
reload: 60 // update available features every 60 seconds
});
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/FredKSchott/fflip là nguồn chính thức.
FredKSchott/fflip có phải mã nguồn mở không?
Có — FredKSchott/fflip phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/FredKSchott/fflip.
FredKSchott/fflip có tag gì không?
Bản đồng bộ chưa ghi nhận topic GitHub nào cho FredKSchott/fflip. GitHub topics hiển thị ở thanh bên phải trang repo — đó là nơi đáng kiểm tra nhất.
FredKSchott/fflip có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho FredKSchott/fflip. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
FredKSchott/fflip còn đang phát triển không?
Commit gần nhất trên FredKSchott/fflip là 5.9 năm trước (theo timestamp GitHub). Repo có 31 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
FredKSchott/fflip dùng license gì?
FredKSchott/fflip phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về fflip?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về fflip.