0.0.2 • Published 9 years ago
static-vars v0.0.2
Static Variables
Static variables allows for storing global variables including submodules.
Installation
npm install static-vars --save
Usage
index.js
var staticVars = require('static-vars');
var myVar = staticVars.set('myVar', 'hello world');
other.js
var staticVars = require('static-vars');
if (staticVars.has('myVar')) {
console.info(staticVars.get('myVar', 'foo bar')); // 'hello world'
}
Methods
get (String name , Mixed def) : Mixed
Gets the stored value of a static variable, if the variable is not defined then def will be returned.
set (String name, Mixed value) : Object
Sets the value of a static variable, and returns the static-vars object.
has (String name) : Boolean
Determines if a static variable has been defined.
del (String name) : Object
Deletes the static variable, and returns the static-vars object.
Development and testing
Mocha unit tests:
npm test
ESLint and JSHint:
npm run eslint
npm run jshint