Comparing version 0.0.4 to 0.0.5
// Generated by CoffeeScript 1.6.3 | ||
var featured, fs, functionName, generatedFunctionName, path, rules; | ||
featured = void 0; | ||
fs = require('fs'); | ||
fs = void 0; | ||
path = require('path'); | ||
functionName = void 0; | ||
generatedFunctionName = void 0; | ||
path = void 0; | ||
rules = void 0; | ||
fs = require("fs"); | ||
path = require("path"); | ||
featured = exports; | ||
@@ -24,21 +12,19 @@ | ||
functionName = ""; | ||
functionName = ''; | ||
generatedFunctionName = ""; | ||
generatedFunctionName = ''; | ||
featured.configure = function(opts) { | ||
var defaults, key, val; | ||
defaults = void 0; | ||
key = void 0; | ||
val = void 0; | ||
var defaults, key; | ||
if (opts == null) { | ||
opts = {}; | ||
} | ||
defaults = { | ||
file: "./rules.js", | ||
functionName: "__featured", | ||
generatedFunctionName: "__featuredStatic" | ||
file: './rules.js', | ||
functionName: '__featured', | ||
generatedFunctionName: '__featuredStatic' | ||
}; | ||
opts = (opts != null ? opts : {}); | ||
for (key in defaults) { | ||
val = defaults[key]; | ||
if (opts[key] == null) { | ||
opts[key] = val; | ||
opts[key] = defaults[key]; | ||
} | ||
@@ -56,15 +42,11 @@ } | ||
featured.init = function(req, res, next) { | ||
var key, value, __featured; | ||
key = void 0; | ||
value = void 0; | ||
__featured = void 0; | ||
var key, __featured; | ||
__featured.defaults = {}; | ||
__featured = function(featureName) { | ||
return featured.checkFeature(featureName, req.session); | ||
return __featured.defaults[featureName]; | ||
}; | ||
__featured.defaults = {}; | ||
for (key in rules) { | ||
value = rules[key]; | ||
__featured.defaults[key] = featured.checkFeature(key, req.session); | ||
__featured.defaults[key] = featured.checkFeature(key, req.session, __featured.defaults); | ||
} | ||
res.locals[generatedFunctionName] = "var " + functionName + " = function(featureName){var s = " + functionName + "; if (s[\"defaults\"] === undefined) { s.defaults = JSON.parse(decodeURIComponent(s.encodedDefaults.d)); s.encodedDefaults = null;} return s.defaults[featureName] || false;}" + "; " + functionName + ".encodedDefaults = " + JSON.stringify({ | ||
res.locals[generatedFunctionName] = "var " + functionName + " = function(featureName){var s = " + functionName + "; " + "if (s[\"defaults\"] === undefined) { s.defaults = JSON.parse(decodeURIComponent(s.encodedDefaults.d)); " + "s.encodedDefaults = null;} return typeof s.defaults[featureName] !== \"undefined\" ? s.defaults[featureName] : false;}" + "; " + functionName + ".encodedDefaults = " + JSON.stringify({ | ||
d: encodeURIComponent(JSON.stringify(__featured.defaults)) | ||
@@ -77,20 +59,18 @@ }); | ||
featured.checkFeature = function(featureName, session) { | ||
featured.checkFeature = function(featureName, session, previousFlags) { | ||
var rule, _ref; | ||
rule = void 0; | ||
_ref = void 0; | ||
if ((session != null ? ((_ref = session[functionName]) != null ? _ref[featureName] : void 0) : void 0) != null) { | ||
if ((session != null ? (_ref = session[functionName]) != null ? _ref[featureName] : void 0 : void 0) != null) { | ||
return session[functionName][featureName]; | ||
} | ||
rule = rules[featureName]; | ||
if (typeof rule === "undefined") { | ||
if (typeof rule === 'undefined') { | ||
return false; | ||
} | ||
if (typeof rule === "boolean") { | ||
if (typeof rule === 'boolean') { | ||
return rule; | ||
} | ||
if (typeof rule === "function") { | ||
return rule(session); | ||
if (typeof rule === 'function') { | ||
return rule(session, previousFlags); | ||
} | ||
return false; | ||
}; |
{ | ||
"name": "featured", | ||
"description": "feature flags for node", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"homepage": "http://github.com/proksoup/featured", | ||
@@ -6,0 +6,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
8084
73