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

noder.io

v1.2.0

Published

A lightweight IoC container to build the core of a scalable and modular API (inspired by Angular and Pimple). No dependencies, works on Node.js and in the browser (only 2kb minified gzipped).

Downloads

109,770

Readme

Noder.io

Actual version published on NPM npm module downloads per month

Noder.io provides a lightweight and flexible core to create a scalable API of a lib, a module, an application or a framework. Noder.io is inspired (among others) by Angular and Pimple.

It is useful for starting a project quickly with a modular API ready to use.

Noder.io (and any object built on top of Noder.io) integrates:

No dependencies, works on Node.js and in the browser (only 7kb minified - 2kb gzipped).

Quick start

See quickstart.

Usage

Get common instance of Noder:

var noder = require('noder.io');

Best practice, create an instance of Noder class for your project:

// ./api/index.js
var Noder = require('noder.io').Noder;
var api   = new Noder();

// code body that constructs your API

module.exports = api;

or shortcut:

// ./api/index.js
module.exports = require('noder.io').createNoder();

Use your API in another file:

var api = require('./api');

// load a plugin
api.use('pluginName');

// create an item in the container
api.$di.set('someItem', 'value of the item');

// ...

Collection

Noder.io provides a class to handle a collection of items.

// create a collection
var items = noder.createCollection();

items.set('keyName', 'key value');

// keyName value
console.log(items.get('keyName'));

// get all items
var all = items.getAll();

// true
console.log(items instanceof noder.Collection);

See collection.

Dependency Injection

See dependency injection.

Lazy loading

noder.$require method provides a lazy require():

// define the property without loading the mongoose module
noder.$require('mongoose');

// false
console.log(noder.$require.isLoaded('mongoose'));

// lazy loading
var mongoose = noder.mongoose;

// true
console.log(noder.$require.isLoaded('mongoose'));

// true
console.log(noder.mongoose === require('mongoose'));

Aliases:

noder.$require('promise', 'bluebird');

// true
console.log(noder.promise === require('bluebird'));

Custom loader:

// factory: promisify the "fs" module
noder.$require('fs', function() {
  return noder.promise.promisifyAll(require('fs'));
});

fs.readFileAsync('./any-file.js')
  .then(function(contents) {
    console.log(contents);
  })
  .catch(function(err) {
    console.error(err);
  })
;

See lazy loading.

Plugins

Noder.io provides a plugin system to make a package works as a plugin for Noder.io and also as a standalone module or library.

Example of a Noder plugin:

/**
 * Initialization for use as a standalone module.
 * @return {Noder} New `Noder` instance
 */
module.exports = function blog() {

  var Noder = require('noder.io').Noder;
  var noder = new Noder();

  // or use the shortcut:
  // var noder = require('noder.io').createNoder();

  return module.exports.__noder(noder);
};

/**
 * Init `blog` plugin.
 * @param  {Noder} noder  `Noder` instance
 * @return {Noder}        Current `Noder` instance
 */
module.exports.__noder = function blogPlugin(noder) {

  // create config object only if not exists
  noder.$di.addOnce('config', {}, true);

  // sub-modules of blogPlugin
  // that add features to the instance of Noder
  noder.use(require('./api/article'));
  noder.use(require('./api/comment'));
  noder.use(require('./api/admin'));

  // Always return the instance of Noder to allow chaining
  return noder;
};

See plugins.

Unit Tests

Noder.io is fully tested with Unit.js and Mocha.

License

MIT (c) 2013, Nicolas Tallefourtane.

Author

| Nicolas Tallefourtane - Nicolab.net | |---| | Nicolas Talle | | Make a donation via Paypal |