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

minioc-loader

v0.3.1

Published

Utility for loading and initializing minioc aware modules (nodejs).

Downloads

8

Readme

minioc-loader Build Status

Utility for loading and initializing minioc aware modules (nodejs).

minioc is a miniature IoC container for nodejs - see the github repo for more info.

Usage

var loader = require('minioc-loader')({ basePath: __dirname })
, minioc = loader.minioc // minioc is exported for convenience
;

loader.loadSync(minioc.root, './config.js');
loader.loadSync(minioc.root, './lib/');

// standard minioc here, our startup function has two
// dependencies that will be injected by minioc...
minioc.fulfill('startup', function($config, $app) {

	// assuming that the two paths loaded above result in registrations
	// being made for both `$config` and `$app` objects, minioc will call
	// this function.

	//... do your stuff ...
	console.log('nothing to see here');

});

Options

  • basePath - required base directory path, used to resolve relative paths during loadSync calls

Operations

  • loadSync - loads a module or a directory according to the minioc-loader convention
  • container (argument 0) - a minioc container used when initializing modules
  • path (argument 1) - a path (relative to loader's basePath) to be loaded. Can be a .js module or a directory.

Conventions

When calling loadSync...

If path is a .js file then the loader will treat the file as a module and load it using node's require function. If the module exports a function with the name $init then the loader will tell minioc to fulfill it. Minioc identifies dependencies by convention; any named argument beginning with a dollar sign $ is considered a dependency and minioc will inject that argument. As soon as minioc is able to fulfill all of the dependencies of the exported $init function minioc does so. When minioc calls the exported $init function, this is bound to the IoC container previously given to loadSync.

If path is a directory, the loader will look for an index.js file. If one is present, only the index.js file is loaded as a module; otherwise, all .js files in the directory are loaded.

Study the example code to understand it fully, in particular, notice that the order in which registrations occur on the container is unimportant because minioc will fulfill all requests as soon as their dependencies can be met.

Building Blocks

You may also find these other projects useful...

  • minioc-broadway - Broadway plugin for adding minioc and minioc-loader to broadway/flatiron apps.