Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bottlejs

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bottlejs - npm Package Compare versions

Comparing version 0.4.2 to 0.5.0

68

dist/bottle.js
;(function(undefined) {
'use strict';
/**
* BottleJS v0.4.2 - 2014-10-02
* BottleJS v0.5.0 - 2014-10-12
* A powerful, extensible dependency injection micro container

@@ -97,2 +97,34 @@ *

/**
* Map of deferred functions by id => name
*
* @type Object
*/
var deferred = [];
/**
* Register a function that will be executed when Bottle#resolve is called.
*
* @param Function func
* @return Bottle
*/
var defer = function defer(func) {
set(deferred, this.id, func);
return this;
};
var getService = function(service) {
return this.container[service];
};
/**
* Immediately instantiates the provided list of services and returns them.
*
* @param array services
* @return array Array of instances (in the order they were provided)
*/
var digest = function digest(services) {
return (services || []).map(getService, this);
};
/**
* Register a factory inside a generic provider.

@@ -278,2 +310,32 @@ *

/**
* Register a service, factory, provider, or value based on properties on the object.
*
* properties:
* * Obj.$name String required ex: `'Thing'`
* * Obj.$type String optional 'service', 'factory', 'provider', 'value'. Default: 'service'
* * Obj.$inject Mixed optional only useful with $type 'service' name or array of names
*
* @param Function Obj
* @return Bottle
*/
var register = function register(Obj) {
return this[Obj.$type || 'service'].apply(this, [Obj.$name, Obj].concat(Obj.$inject || []));
};
/**
* Execute any deferred functions
*
* @param Mixed data
* @return Bottle
*/
var resolve = function resolve(data) {
get(deferred, this.id, '__global__').forEach(function deferredIterator(func) {
func(data);
});
return this;
};
/**
* Map used to inject dependencies in the generic factory;

@@ -345,5 +407,9 @@ *

decorator : decorator,
defer : defer,
digest : digest,
factory : factory,
middleware : middleware,
provider : provider,
register : register,
resolve : resolve,
service : service,

@@ -350,0 +416,0 @@ value : value

3

package.json
{
"name": "bottlejs",
"version": "0.4.2",
"version": "0.5.0",
"description": "A powerful, extensible dependency injection micro container",

@@ -34,3 +34,2 @@ "main": "dist/bottle.js",

"grunt-contrib-uglify": "^0.5.1",
"grunt-template-jasmine-istanbul": "^0.3.0",
"grunt-wrap": "^0.3.0",

@@ -37,0 +36,0 @@ "lodash": "^2.4.1"

![BottleJS](/bottle-logo.jpg)
# BottleJS [![Build Status](https://travis-ci.org/young-steveo/bottlejs.svg?branch=master)](https://travis-ci.org/young-steveo/bottlejs) [![Coverage Status](https://img.shields.io/coveralls/young-steveo/bottlejs.svg)](https://coveralls.io/r/young-steveo/bottlejs)
# BottleJS [![Build Status](https://travis-ci.org/young-steveo/bottlejs.svg?branch=master)](https://travis-ci.org/young-steveo/bottlejs)

@@ -207,2 +207,19 @@ > A powerful, extensible dependency injection micro container

#### defer(func)
Register a function to be executed only when `Bottle#resolve` is called.
Param | Type | Details
:--------|:-----------|:--------
**func** | *Function* | A function to be called later. Will be passed a value given to `Bottle#resolve`.
#### digest(services)
Immediately instantiate an array of services and return their instances
in the order of the array of instances.
Param | Type | Details
:------------|:--------|:--------
**services** | *Array* | Array of services that should be instantiated.
#### factory(name, Factory)

@@ -235,2 +252,18 @@

#### register(Obj)
Used to register a service, factory, provider, or value based on properties of the Obj.
Param | Type | Details
:-------|:-----------|:--------
**Obj** | *Object*\|*Function* | An object or constructor with one of several properties:<br /><ul><li>**Obj.$name** &mdash; *required* &mdash; the name used to register the object</li><li>**Obj.$type** &mdash; *optional* &mdash; the method used to register the object. Defaults to `'service'` in which case the Obj will be treated as a constructor. Valid types are: `'service'`, `'factory'`, `'provider'`, `'value'`</li><li>**Obj.$inject** &mdash; *optional* &mdash; If `Obj.$type` is `'service'`, this property can be a string name or an array of names of dependencies to inject into the constructor.<br />E.g. `Obj.$inject = ['dep1', 'dep2'];`</li></ul>
#### resolve(data)
Execute any deferred functions registered by `Bottle#defer`.
Param | Type | Details
:--------------------------|:--------|:--------
**data**<br />*(optional)* | *Mixed* | Value to be passed to each deferred function as the first parameter.
#### service(name, Constructor [, dependency [, ...]])

@@ -237,0 +270,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc