Comparing version 0.0.3 to 0.2.0
{ | ||
"name": "muton", | ||
"version": "0.0.3", | ||
"version": "0.2.0", | ||
"description": "A feature toggling/throttling and multivariate testing tool", | ||
@@ -5,0 +5,0 @@ "main": "src/muton.js", |
@@ -7,12 +7,12 @@ Muton | ||
This is the Muton project - a feature toggle tool with support for feature throttling and multivariance testing. | ||
You can engineer the genes of your application by meticulously choose what are the best features and create an organic result. With artificial manipulation, or even by random mutations, you will natural select the best version of your application. | ||
___ ___ _ | ||
| \/ | | | | ||
| . . |_ _| |_ ___ _ __ | ||
| |\/| | | | | __/ _ \| '_ \ | ||
| |\/| | | | | __/ _ \| '_ \ | ||
| | | | |_| | || (_) | | | | | ||
\_| |_/\__,_|\__\___/|_| |_| | ||
O o O o O o | ||
@@ -23,4 +23,4 @@ | O o | | O o | | O o | | ||
o O o O o O | ||
In real life, cells replicate DNA using an enzyme called polymerase. During the process, it checks for replication errors doing proof-reading on the fly. But sometimes a random mutation occur... that's life trying to evolve. This tool works in a similar way: random mutations may occur while processing the instructions to toggle features on and off. That's your application trying to evolve. | ||
@@ -30,2 +30,6 @@ | ||
### Dependencies | ||
muton depends on [lodash](https://https://lodash.com/). Please ensure that it's available in your enviroment. | ||
### NPM | ||
@@ -46,5 +50,5 @@ | ||
Currently, you can use Muton as a Node module or an AMD module. To include as an AMD module, please require the `muton-amd.min.js` file. | ||
You can use in the following way: | ||
```javascript | ||
@@ -64,3 +68,3 @@ var features = muton.getMutations(userProperties, featureInstructions); | ||
And where `featureInstructions` is a dictionary of features containing specific instructions, which must follow a specific format. It can be something like this: | ||
```javascript | ||
@@ -91,3 +95,3 @@ var featureInstructions = { | ||
} | ||
``` | ||
``` | ||
@@ -97,13 +101,13 @@ ### Instructions format | ||
The instructions must contain one of the following elements: `toggle`, `throttle` and `bucket` and they can be placed behind every property inside the feature object, and even placed directly under the feature object. Muton will look for a path in the instructions and aggregate all of them that matches the user properties. When no matches are found, it will assume the general instructions. | ||
#### Toggle | ||
The `toggle` instruction activates or deactivates toggles. The default value is false and can be overridden by the `throttle` and `bucket` instructions. The exception to this is when the `toggle` instruction is placed directly under the feature object and it's value is set to false. This allows to deactivate a feature completely. | ||
#### Throttle | ||
The `throttle` instruction will activate or deactivate a toggle based on a percentage. In Muton terms, this is called a mutation. For example, you might want to have 50% of your users to have access to a feature and this instruction is perfect for that. | ||
For example, if you want to have 50% of your Portugal users to see a feature but 100% of the users of the remaining countries to see it (except for France), you could do something like: | ||
```javascript | ||
@@ -138,3 +142,3 @@ var featureInstructions = { | ||
The `bucket` instruction is perfect for A/B testing and it resources to mutations like the `throttle` instruction. This instruction can be written like the following: | ||
```javascript | ||
@@ -155,7 +159,7 @@ var featureInstructions = { | ||
``` | ||
The above snippet would allow you to have your France users to access three different buckets for testing, let's say, three different buttons on a form and test which of them your users react best. | ||
A valid response for a french user could be: | ||
```javascript | ||
@@ -194,5 +198,5 @@ { | ||
Numeric user properties can be matched against an expression. The property value must start with one of the following operators: '>', '<', '>=', '<='. | ||
Picking the bookstore example, a user with over 10000 bought books would have a special feature toggle on: | ||
```javascript | ||
@@ -214,13 +218,13 @@ var featureInstructions = { | ||
This is only applied to instructions that are subject to mutations, namely 'buckets' and 'throttles'. Inherited mutations from ancestors will only work when the new instructions and ancestor genes have the same kind of mutations (e.g.: ancestor and predecessor have a throttle on the same feature). For plain toggles, ancestor genes will be ignored. | ||
To inherit genes from an ancestor, you can use Muton in the following way: | ||
```javascript | ||
var features = muton.inheritMutations(userProperties, featureInstructions, ancestorGenes); | ||
``` | ||
#### Throttle inheritance | ||
#### Throttle inheritance | ||
For example, to inherit throttles, one could pass a set of instructions and a set of ancestor genes: | ||
```javascript | ||
@@ -249,3 +253,3 @@ var featureInstructions = { | ||
If you choose to force mutations when inheriting throttles on a specific context, you can create a throttle object instead of a percentage value and pass a 'mutate' property and ignore the ancestor gene. You must specify it in the instructions: | ||
```javascript | ||
@@ -268,3 +272,3 @@ var featureInstructions = { | ||
To inherit buckets, you can pass a set of ancestor genes to Muton containing buckets: | ||
```javascript | ||
@@ -284,3 +288,3 @@ var featureInstructions = { | ||
The ancestor genes (a previous Muton output) could be passed to Muton and the predecessor will inherit the ancestor bucket. However, if the ancestor gene contains a bucket that is not defined in the predecessor instructions, then a bucket mutation will occur and a random bucket from the new instructions will be picked up. | ||
```javascript | ||
@@ -296,3 +300,3 @@ var ancestorGenes = { | ||
## Build | ||
grunt clean && grunt | ||
@@ -303,3 +307,3 @@ | ||
npm test | ||
## Future work | ||
@@ -324,4 +328,7 @@ | ||
- Adding support for gene inheritance | ||
* 0.2.0 | ||
- Exclude lodash from final bundle | ||
- Return muton on define call to ensure that it's correctly exported | ||
[npm-url]: https://npmjs.org/package/muton | ||
[npm-image]: https://badge.fury.io/js/muton.svg |
@@ -140,6 +140,8 @@ /** | ||
} else { | ||
// Export to AMD | ||
// Export to Global | ||
this.muton = muton; | ||
} | ||
return muton; | ||
}); | ||
}).call(this); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
318
85459
1182
4