Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

feature-toggles

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

feature-toggles - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

7

index.js

@@ -21,2 +21,9 @@ var _toggles = {};

return toggleValue === true;
};
exports.middleware = function(request, response, next) {
response.locals.isFeatureEnabled = function(name) {
return exports.isFeatureEnabled(name, request, response);
};
next();
};

2

package.json
{
"name": "feature-toggles",
"version": "1.1.0",
"version": "1.2.0",
"description": "Feature Toggles for Node.js",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -25,3 +25,3 @@ # feature-toggles

// check if a feature is enabled
if (featureToggles.isFeatureEnabled('foo') {
if (featureToggles.isFeatureEnabled('foo')) {
// do something

@@ -73,3 +73,3 @@ }

app.get('/', function() {
app.get('/', function(request, response) {
if (featureToggles.isFeatureEnabled('foo', request)) {

@@ -85,3 +85,3 @@ // do something

var toggles = {
foo: function(request) {
foo: function() {
var date = new Date();

@@ -95,3 +95,3 @@ return date.getDate() > 15;

if (featureToggles.isFeatureEnabled('foo', request)) {
if (featureToggles.isFeatureEnabled('foo')) {
// do something

@@ -101,2 +101,27 @@ }

#### Express integration
Use the middleware to easily toggle features per request.
This way a special version of `isFeatureEnabled()` is exposed to all views (res.locals).
Computed toggles will automatically receive the current request and response as arguments.
```javascript
var toggles = {
foo: function(request, response) {
return request.param('enableFoo');
}
}
```
```javascript
var application = express();
application.use(featureToggles.middleware);
```
```jade
- if (isFeatureEnabled('foo'))
Foo is enabled
```
### Alternative modules

@@ -103,0 +128,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc