🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

dotie

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dotie

tiny, powerful dependency injection container for node and browser

latest
Source
npmnpm
Version
0.0.6
Version published
Maintainers
1
Created
Source

Dotie

tiny, powerful dependency injection container for node and browser inspired on angularJS

Instalation

The installation of this package is very simple: In fact, it can be installed by just running:

$ npm install dotie # if using NodeJS
$ bower install dotie # if you want to use this package in the browser

Reference

API

/**
 * create an new dependency into container
 * @param {string} name - name of dependency
 * @param {any} provider - dependence 
 * @returns {this}
 */
dotie.register(name, provider) /* or */ dotie.<name> = provider

/**
 * find and resolve dependencies and return then
 * @param {string} name - name of dependency
 * @returns {any} - registered provider instance
 */
dotie.resolve(name) /* or */ dotie.<name>

Example


// small sintax
dotie.q = () => $.Deferred() // dotie.<name> = dependence

// default sintax
dotie.register('http', function(q) {
  return (...params) => {
    $.ajax(...params)
      .success(data => q.resolve(data))
      .error(error => q.reject(error))
    return q.promise()    
  }
})

// using angular injection style (option 1)
dotie.register('user', ['http', http => {
  return {
    find: code => http(`localhost:2650/api/users/${code}`) 
  }
}])

// angular injection style (option 2)
function controller(model) {
  user.find(1)
    .then(user => console.log(user))
    .catch(error => console.log(error))
}

controller.$inject = [ 'user' ]

dotie.register('controller', controller) /* or */ dotie.controller = controller

Keywords

dependence

FAQs

Package last updated on 23 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts