0.5.0 • Published 3 years ago

xprovide v0.5.0

Weekly downloads
64
License
MIT
Repository
github
Last release
3 years ago

xprovide

模块提供工具,通过define定义模块,通过require获取模块.类似模块依赖注入工具.

Install

npm install xprovide

Usage

xprovide支持xboot引导方式下,作为项目插件使用.在xboot引导加载xboot.js文件时,能够通过xboot加载使用项目,项目引擎及项目插件下的xprovide.js文件.

// {cwd}/xprovide.js
// {cwd}/node_modules/{xxx engine}/xprovide.js
// {cwd}/node_modules/{xxx plugin}/xprovide.js

module.exports = (provider) =>{
    
    // 定义模块
    provider.define("id",["dep1","opt_dep1?"],(dep1,optDep1)=>{
        // 构建生成模块
        const model = {a:1,b:true,c:dep1,dd:optDep1};
        return model;
    });
    
    // 使用模块
    provide.require(["id"],(model)=>{
        console.log(model);
    });
};

Documentations

使用jsdoc生成注释文档

git clone https://github.com/kiba-zhao/xprovide.git
cd xprovide
npm install
npm run docs
open docs/index.html

n

License

MIT

0.5.0

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago