Giter Club home page Giter Club logo

const's Introduction

@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";

const's People

Contributors

mapoart avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar Nexss Programmer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.