npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bmodulejs

v2.1.1

Published

Browser module Controller, which surpport a good way for code tracking

Downloads

22

Readme

BModuleJs 2.1.0

Bmodulejs Bmodulejs

About

A Controller For Modules.You can use it as javascript module controller, which can help you to make your code more structured. You can also use it to tracking code by use the function "module.tailLog('process')" so that you can see the running log of the modules.

# You can get it by: 
npm install bmodulejs

Optimization of 2.1.0

  1. Simplify the way to define a module.
  2. Simplify the way to use other module function by $M.mods.
  3. Change the way to deal with those variable returned by "create".

API

$M.defineModule( mNameStr );

Define a new module object.The same with old "$M.define".
@param {string} [mNameStr] module name, use "/" to split namespace.
@return {object}
var module = $M.defineModule( 'page/home/main' );

$M.define( mNameStr )

Define a new module and set it.
@param {string} [mNameStr] module name, use "/" to split namespace.
@return {object}
$M.define( 'page/home/main', function (module, $T, mods, ms) {
    // Dependence treatment
    module.require('common/database');
    
    return function () {
        // use the module's function by "mods", the same with $M.mods
        var database = new mods.common.database( dataConf );
        
        // show module's log by "ms", the same with $M.modules.
        ms.common.database.showLog();

        return {
            state: 'finished'
        };
    };
}).create();

If the returned value is a function or depends on other module,you must use a function to wrap it. In other cases, you can just return it.

$M.newM

Get a module object.

$M.create( nameStr, spec, cbk );

Create a module which you have defined by function "$M.define"
@param {string} [nameStr] module name.
@param {array|all} [spec] parameter for modules on creating.
@param {function} [cbk] callback

$M.modules;

A namespace for modules.All of the modules will be added to this object.
So, you can use those modules you added by this way.

$M.mods;

Namespace for the return value by module's "create" function.

$M.destroy( nameStr );

The way to destroy a module.

$M.expendT( fnName, fn );

The way to expend $M.tools.

$M.getModule( nameStr );

The way to get module object by name string.

$M.getMod( nameStr )

The way to get a defined module's function or other data.

$M.jsLoader( src, conf );

Js loader.
@param {object} conf 
            { 
                'cbk' : function (){},
                'isAsync' : false,
                'isClear' : false,
                'sudo' : false'
            }

$M.options();

Settings.

$M.path();

Javascript src setting.

$M.reload( nameStr );

Reloading those modules which loaded by bmodulejs.

$M.tools;

Some tools functions.

Dependence treatment

eg.

$M.define('home/init', function (module, $T, mods, ms) {
    // get it when "create" be called.

    module.require( 'common/database' );

    return function () {

        console.log( arguments );

        var nd = document.getElementById( 'example' );

        var dataConf = {

            // index keys

            'idx' : ['num', 'name', 'age']
        };

        // create database

        var database = new mods.common.database( dataConf );

        for( var i = 0; i < 99999; i++ ) {

            database.create( {

                'num' : i,

                'name' : 'BottleLiu' + i,

                'age' : i % 24

            } );

        }
        var str = '';

        var strTotal = 'Data length: ' + database.total + '<br><br>';

        var strGet = 'The length of data which age equal 23: ' + database.get({'age' : 23}).length;

        str = strTotal + strGet;

        nd.innerHTML = str;

        return database;

    };

}).create('Arguments for init function.');

Strapping Tools

Step 1.the first time you use this tools

# enter dir
cd xxxx
npm install

Step 2.

grunt bmodule:filepath[:target:prefix:isUglify]
# filepath: the file or path you want to strap.
# target: the target path or file path for strapped file.
# prefix: the same with "$M.options('sourceRoot', 'static/js/');" value.
# isUglify: need to compress.use "0" or "1" to turn off or turn on it.
eg.
grunt bmodule:static/js/::static/js/:0

Skills

Script tag

<!--Use bmodule to load js.the attribute "after" will be loaded after "msrc"-->
<script src="source/bmodulejs-2.1.0.js" msrc="static/js/common/base.js" after="static/js/home/init.js"></script>