1.0.13 • Published 4 years ago

@nexssp/const v1.0.13

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

@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:

image

nConst("MYCONST", "some value"); // you cannot change it.

// You can use MYCONST everywere after nConst("MYCONST",...)
MYCONST = 369; // will terminate program with the message as below

Usage

Let say you have some kind of config file.

// config.js
const { nConst, hConst } = require("@nexssp/const");

nConst("MYCONST", "some value", process);
nConst("MYCONST2", "OLD CONSTANT VALUE");

hConst("MYCONST3_HIDDEN", "Hidden Constant", myConfig); // NEW! hConst-> Will to been seen on Object.keys etc.

console.log(getConstants()); // Will display defined constants

const myConfig = {};
nConst("MyObjectCONST", "My old object const", myConfig);

module.exports = { myConfig };
// program.js

const { myConfig } = require("./config");

process.MYCONST = 369;
myConfig.MyObjectCONST = 999999;

MYCONST2 = 333366669999;

myObject.MYCONST = "New value1"; // Program terminated
MYCONST2 = "SOMETHING else";
1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago