micro-definition

0.0.5 • Public • Published

npm npm npm bitHound Code

micro-definition

(<2kb) A lite module loader and cache module in localStorage.

Try it now

Getting started

$ npm install micro-definition

Dependency

How to use

#Define a module

Define( id : String, method : Function )

Define('mod', function () {
    // some code;
    return value;
});

#Define a module with dependencies

Define( id : String, dependency : Array, method : Function )

Define('mod-a', ['mod-b', 'mod-c'], function ( b, c ) {
    // some code;
    return value;
});

#Require modules

Define( dependency : Array, callback : Function )

Define(['jQuery', 'lodash'], function ( $, _ ) {
    // some code;
});

#Config of alias

Define.alias( alias : Object )

Define.alias({
    'mod-a' : 'a.js',
    'mod-b' : 'b.js',
});

#Show all defined modules

More Define.storage api see micro-storage.

Define.storage.list();

#Remove a defined module

More Define.storage api see micro-storage.

Define.storage.remove('mod-a');

License

MIT

Package Sidebar

Install

npm i micro-definition

Weekly Downloads

5

Version

0.0.5

License

MIT

Last publish

Collaborators

  • lixinliang