Necessary Pigeonholing Mechanism
    Have ideas to improve npm?Join in the discussion! »

    aisle

    1.0.1 • Public • Published

    aisle

    Build Status Dependency Status

    Module for global event handling and namespacing.

    $ npm install aisle
    

    Usage

    Programmatically

    var aisle = require("aisle");

    Call your aisle for namespaces or use it as you would an EventEmitter object.

    Namespaces

    If you call aisle without any arguments, then aisle will tap into and return require.main.exports, otherwise aisle will return your namespace and its data. If you provide data with your namespace, then aisle will assign that data to your namespace (namespaces will be created or overwritten.)

    // main.js
    var aisle = require("aisle");
     
    module.exports = {"data": "main"};
     
    aisle("my-namespace",{"abc": 123});
     
    require("./other");
    // other.js
    var aisle = require("aisle");
     
    console.log(aisle()); // { data: 'main' }
    console.log(aisle("my-namespace")); // { abc: 123 }
    console.log(aisle("nonexistent-namespace")); // undefined

    Events

    With your Node's version, use Node's documentation to find its EventEmitter abilities.

    // main.js
    var aisle = require("aisle");
     
    aisle.on("some global event",console.log); // { data: [ 'here', true ] }
     
    require("./other");
    // other.js
    var aisle = require("aisle");
     
    aisle.emit("some global event",{"data": ["here",true]});

    Install

    npm i aisle

    DownloadsWeekly Downloads

    4

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • avatar