npm install konstant
On the server, a simple
is sufficient for defining the type declarations. In a browser environment, the script just needs to be included in your DOM.
When additional constants are needed, the module should be initialized on the server as follows:
// Server environment var Konstant = require('konstant');
Konstant.define (key, value, inGlobal)
Konstant.define (object, inGlobal)
With define, a new constant can be defined. You can provide either a hashmap or key-value-pairs. When inGlobal is set to true, the constant will be made available in the global context (which is the window object in a browser environment).
Returns true or false, depending on whether a constant has been defined or not.
Returns the given constant or throws an error if it hasn't been defined.