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

rf-topmodule

v0.1.6

Published

Simple NodeJS module loading lib, that also initializes rf-config and rf-log.

Readme

rf-topmpdule

  • Simple NodeJS module loading lib, that also initializes rf-config and rf-log
  • Optional dependency: Uses rf-log for error logging if available
  • Optional dependency: Initializes rf-config if available
  • Configurable base dir
  • Can load a list of modules from a directory, or ALL files in a directory
  • Modules are first compiled in a list, and started at a later point together

Getting Started

npm install rf-topmodule

To compile your module list, you have several functions to choose from, for file loading, npm module loading and function loading respectively.

var topModule = require("rf-topmodule");

topModule.init(__dirname);
topModule.setModulePath("myModuleDirectory");

topModule.loadFile("db"); // load myModuleDirectory/db.js
topModule.loadFile("acl", { parameters: 123 }); // provide additional parameters
topModule.loadModule("web", { parameters: 123 }); // load npm module
topModule.loadFunction(function (options, next) {
   console.log("I am a function " + options.whatami);
   next();
}, { whatami: "without name" } ); // load a function

Instead of using loadFile, loadModule and loadFunction individually, you can also compile the information in a list and pass it to loadModules():

// All of the above could have been in an equivalent list as well:
topModule.loadModules([
   "db", // type "file" is assumed implicitly
   { file "acl", type: "file", options: { parameters: 123 } },
   { name: "web", type: "npm", options: { parameters: 123 } },
   { func: function (options, next) {
         console.log(options);
         next();
      }, type: "function", { whatami: "without name" } }
]);

If you intend to load all files in a directory, there's another shortcut function:

topModule.loadModuleDirectory("./modules");

Once you are done preparing your module list, you can start all modules at once:

topModule.startModules();

Module structure

Modules need to provide a 'start' function. The topModule will call it with a list of the remaining module functions and the module parameters.

Note: It is the job of that start function to call the next module. If it fails to do so, the module execution will not finish.

"use strict";

module.exports.start = function (options, next) {
   // ...do your module things

   // call the next module
   next();
}

Accessing modules from other files

Modules can be accessed after they were "loaded" with a special require function. It works the same as the usual require(), but it throws an error if the module hasn't been loaded with the loadModule() et. al. functions previously. The intention is to have a main module that loads and configures all required modules in advance, and receive clear error messages when that approach would otherwise be undermined.

var acl = require("rf-topmodule").require("acl");
// You can now access any module.exports variables and functions from the acl module

Legal Issues

  • Licenese: MIT
  • Author: Julian von Mendel