Socket
Book a DemoInstallSign in
Socket

nsobject

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nsobject

A utility to store namespaced objects globally

latest
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

NS Object

An easy to use namespace configuration utility

nsobject makes it easy to configure data you need available in a singleton fashion across all instances of an object or require calls that don't cache for some reason.

Getting Started

Install the module:

npm install --save nsobject

Require the module:

var nsobject = require('nsobject');

Create your namespace:

var namespace = nsobject.create('DB.MONGO', {
    host: 'localhost',
    port: 1000
});

Now that you created your namespace you can access it in any file using the namespace key!!

var namespace = nsobject.get('DB.MONGO');
    console.log(namespace.host); //localhost
    console.log(namespace.port); 1000

Override namespace object properties and they'll stick:

file a -

var namespace = nsobject.get('DB.MONGO');
    namespace.host = 'http://mongo.remote-01.com';

file b -

var namespace = nsobject.get('DB.MONGO');
    console.log(namespace.host); //http://mongo.remote-01.com

OR override the entire ns object:

var namespace = nsobject.set('DB.MONGO', {foo: 'bar'});

FAQs

Package last updated on 22 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts