smallbox

0.2.1 • Public • Published

smallbox

NPM

a lightweight container library for node.js

Build Status

Installation

$ npm install smallbox

Usage

var container = require('smallbox');
 
// register components
container.define('user:name', 'Javier');
container.define('user:surname', 'Aranda');
container.define('files:storage', 's3');
 
// get components
if ( container.has('user:name') ) {
  console.log( container.require('user:name') );
}
 
// using wildcard
container.require('user:*'); //=> { 'user:name': 'Javier', 'user:surname': 'Aranda' }

Share a container between two modules

// module_a.js
 
var container = require('smallbox');
container.define('user:location', 'Spain');
// module_b.js
 
var container = require('smallbox');
container.require('user:location'); // => 'Spain'

More examples are available inside the code or tests.

Testing

The library is tested using Mocha.

$ npm test

Contributing

  1. Fork it ( https://github.com/javierav/smallbox/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Versioning

smallbox uses Semantic Versioning 2.0.0

License

Copyright (c) 2016 Javier Aranda - Released under MIT license

Readme

Keywords

Package Sidebar

Install

npm i smallbox

Weekly Downloads

3

Version

0.2.1

License

MIT

Last publish

Collaborators

  • javierav