@nexssp/const
- NEW 1.0.13 - function which list the defined constants: getConstants()
- NEW 1.0.11 - now 2 functions nConst and hConst. hConst will be hidden. So when the for example
Object.keys
will be used will not be displayed however constant is there. - NEW 1.0.10 - now with stack display..
Constants in JavaScript (global, objects)
Installation
npm i @nexssp/const
All below will display error like:
nConst("MYCONST", "some value");
MYCONST = 369;
Usage
Let say you have some kind of config file.
const { nConst, hConst } = require("@nexssp/const");
nConst("MYCONST", "some value", process);
nConst("MYCONST2", "OLD CONSTANT VALUE");
hConst("MYCONST3_HIDDEN", "Hidden Constant", myConfig);
console.log(getConstants());
const myConfig = {};
nConst("MyObjectCONST", "My old object const", myConfig);
module.exports = { myConfig };
const { myConfig } = require("./config");
process.MYCONST = 369;
myConfig.MyObjectCONST = 999999;
MYCONST2 = 333366669999;
myObject.MYCONST = "New value1";
MYCONST2 = "SOMETHING else";