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.2.0 to 1.3.0

47

index.js

@@ -1,28 +0,29 @@

var _toggles = {};
var featureToggles = {
_toggles: {},
load: function(toggles) {
this._toggles = toggles;
},
var slice = Array.prototype.slice;
isFeatureEnabled: function(featureName) {
var toggle = this._toggles[featureName];
if (typeof toggle == 'function') {
try {
var toggleArguments = slice.call(arguments, 1);
toggle = toggle.apply(this, toggleArguments);
}
catch (error) {
return false;
}
}
return toggle === true;
},
exports.load = function(toggles) {
_toggles = toggles;
};
exports.isFeatureEnabled = function(name) {
var toggleValue = _toggles[name];
if (typeof toggleValue == 'function') {
try {
var toggleArguments = slice.call(arguments, 1);
toggleValue = toggleValue.apply(this, toggleArguments);
}
catch (error) {
return false;
}
middleware: function(request, response, next) {
response.locals.isFeatureEnabled = function(featureName) {
return featureToggles.isFeatureEnabled(featureName, request, response);
};
next();
}
return toggleValue === true;
};
exports.middleware = function(request, response, next) {
response.locals.isFeatureEnabled = function(name) {
return exports.isFeatureEnabled(name, request, response);
};
next();
};
module.exports = featureToggles;
{
"name": "feature-toggles",
"version": "1.2.0",
"description": "Feature Toggles for Node.js",
"version": "1.3.0",
"description": "Feature Toggles for JavaScript",
"main": "index.js",

@@ -6,0 +6,0 @@ "repository": "https://github.com/alexlawrence/feature-toggles.git",

@@ -5,8 +5,8 @@ # feature-toggles

[feature toggles](http://martinfowler.com/bliki/FeatureToggle.html)
for Node.js (also called feature flipping).
for JavaScript (also called feature flipping).
### Features
This module offers one additional feature over using a simple plain JavaScript object:
computed feature toggle values in form of functions.
This module encapsulates all calls to check if a certain feature (toggle) is enabled.
Furthermore it provides the possibility to have computed feature toggle values in form of functions.

@@ -13,0 +13,0 @@ ### Simple toggle values

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