Skip to content

javierav/smallbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

a lightweight container library for node.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published