Plato on Github
Report Home
config/config.js
Maintainability
122.71
Lines of code
36
Difficulty
21.25
Estimated Errors
0.22
Function weight
By Complexity
By SLOC
(function(sc) { "use strict"; require("../libs/"); var strlib = sc.libs.strlib; var values = {}; var setter = {}; sc.config = { add: function(name, defaultValue, func) { values[name] = typeof defaultValue !== "undefined" ? defaultValue : null; if (typeof func === "function") { setter[name] = func; } }, set: function(name, value) { if (values.hasOwnProperty(name)) { value = setter[name] ? setter[name](value) : value; return (values[name] = value); } throw new Error( strlib.format("Config '#{0}' is not found.", name) ); }, get: function(name) { if (values.hasOwnProperty(name)) { return values[name]; } throw new Error( strlib.format("Config '#{0}' is not found.", name) ); } }; })(sc);