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

    basespacepublic

    basespace

    Functions to create namespaces inside objects.

    Installation

    Node

    npm install basespace
    

    Component

    component install gamtiq/basespace
    

    Jam

    jam install basespace
    

    Bower

    bower install basespace
    

    SPM

    spm install numgen
    

    AMD, script tag

    Use dist/basespace.js or dist/basespace.min.js (minified version).

    Usage

    Node, Component, SPM

    var ns = require("basespace");
    ...

    Jam

    require(["basespace"], function(ns) {
        ...
    });

    AMD

    define(["path/to/dist/basespace.js"], function(ns) {
        ...
    });

    Bower, script tag

    <!-- Use bower_components/basespace/dist/basespace.js if the library was installed via Bower -->
    <script type="text/javascript" src="path/to/dist/basespace.js"></script>
    <script type="text/javascript">
        // basespace is available via basespace field of window object
        var ns = basespace;
        ...
    </script> 

    Example

    var app = {
        space: ns.space
    };
    ns(["model", "ui.dialog", "ui.list", "ui.list.cyclic", "util"], app);
    app.space("ui.menu", "template");
    app.space("data").util = {...};

    API

    ns(namespaces: Array|String, [context: Object], [value])

    Create specified namespaces inside context if they do not exist. context is global object (i.e. window in browser) by default. value specifies a value that will be assigned to a final field. {} by default.

    Return the value for the last of created names/fields.

    .space(namespace: String, ...)

    Create the specified namespace inside this object.

    Return the value for the last of created names/fields.

    Related projects

    Licence

    MIT

    install

    npm i basespace

    Downloadsweekly downloads

    6

    version

    0.1.0

    license

    MIT

    repository

    githubgithub

    last publish

    collaborators

    • avatar