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 🙏

© 2026 – Pkg Stats / Ryan Hefner

dreamix-loader

v1.0.3

Published

loader

Downloads

29

Readme

dreamix-loader

####fork 自:https://github.com/NetEase/pomelo-loader ###改写为es6语法,并且解决class写法下,对象方法不可被枚举的问题。

dreamix中使用Convention over Configuration的形式管理工程目录,不同的功能按约定放在不同的目录下。dreamix-loader为dreamix提供了按目录加载模块的功能。

dreamix-rpc可以批量加载指定目录下的模块,挂到一个空对象下返回(但不会递归加载子目录),同时提供模块命名机制。

Tags: node.js ##规则说明 模块命名

模块默认以文件名为名。如:加载lib/a.js后,返回的结果为:{a: require('./lib/a')}。

如果模块中定义了name属性,则会以name作为模块的名称。如:

a.js exports.name = 'test'; 返回的结果为:{test: require('./lib/a')}

模块定义

如果模块以function的形式暴露出去,则这个function会被当作构造模块实例的工厂方法,Loader会调用这个function获取模块的实例,同时可以传递一个context参数作为工厂方法的参数。其他情况则直接把加载到的模块返回。

module.exports = function(context) { return {}; // return some module instance }; ##安装

npm install dreamix-loader ##用法

var Loader = require('dreamix-loader');

var res = Loader.load('.'); console.log('res: %j', res); 模块定义成函数,加载

##API ###Loader.load(path, context) 加载path目录下所有模块。如果模本身是一个function,则把这个function作为获取模块的工厂方法,通过调用这个方法获取到模块实例;否则直接返回加载到的模块。 ####参数

path 加载的目录 context 如果通过工厂方法加载模块,会将该参数作为初始化参数传给工厂方法。