Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    js-namespacepublic

    namespace-js

    Build Status npm version Bower version

    Namespace-js is a lightweight JavaScript helper checking for or creating namespace objects.

    Install

    npm install js-namespace --save

    Usage

    You can create a object chain with

    Namespace.create('be.awesome'); // => be: Object { awesome: Object } 
     
    // or direct assignment 
     
    Namespace.create('be.awesome').Magic = function() {
      // your magic code 
    }; // => function be.awesome.Magic() 

    Check if a namespace exists

    Namespace.is('be.awesome'); // => false 
    Namespace.create('be.awesome');
    Namespace.is('be.awesome'); // => true 

    Check if namespace on a local object exists

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

    Licensing

    MIT

    Keywords

    install

    npm i js-namespace

    Downloadsweekly downloads

    29

    version

    1.3.0

    license

    MIT

    repository

    github.com

    last publish

    collaborators

    • avatar