node package manager

js-namespace

namespace-js

Build Status npm version Bower versiondependencies Status

Namespace-js is a lightweight JavaScript helper checking for or creating namespace objects. Is compatible with all new and old browsers like IE6.

Usage

You can create a object chain with

Namespace.create('be.awesome').Magic = function() {
  // your magic code 
};

Check if a namespace exists

Namespace.is('be.awesome');

Check if namespace on a local object exists

var localObj = { be: { awesome: 'bam' } };
if (Namespace.is(localObj, 'be.awesome')) {
  Namespace.create('be.awesome');
}