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

kz_loader

v0.0.1

Published

Automatic loads modules in specially appointed configs and locations.

Downloads

3

Readme

Module loader

Automatic loads modules in specially appointed configs and locations.

Somebody says that convention is greater than configuration,so I make some strict conventions to make my projects normalized and easy to extend.

Install

npm i kz_loader -S

Test

npm test

Usage

you should prepare your modules in folders like below:

├─config
│      db.json
│      get_even_number.json
│
├─init
│      db.js
│
├─util
│      get_even_number.js
│
└─worker
        db.js

the modules in folder 'config' should be json files,and module in other folders should be js file.

a json file should be like this:

confA.json

{
  "some_propertise": "some_content"
}

a js file will be like this: module_A.js

module.exports = async (module_name, config, g) => {
  //module_name is the module's filename,here the name is 'module_A'

  //config is all configs  of this application,you can get this by using config['some_propertise'],this will return 'some_content'

  //g is a global variable,you can set anything you want here

  //if you return something,you will get it after load
  return;
};

then you should prepare the config of these modules:

const loader = require('module_loader');

//orders is the loading order of each type modules,modules not in this array won't load

//path point out the run folder,default for current foler
let configs = {
  orders: {
    config: ['db', 'redis'],
    util: ['get_even_number'],
    init: ['db', 'redis'],
    worker: ['db']
  },
  path: 'test/fake2'
};
my_loader = new loader(configs);

//you can get you want if you return something in module
let result = await my_loader.load();

//you can also get notified by event
/*
my_loader.on('ok', result => {
    ...
});
my_loader.load();
*/

you can find the detail usage in test folder