Comparing version 1.6.1 to 1.6.2
@@ -81,2 +81,3 @@ declare class Bottle { | ||
service(name: string, Constructor: ((...any: any[]) => any), ...dependency: string[]): this; | ||
service<T>(name: string, Constructor: new (...any: any[]) => T, ...dependency: string[]): this; | ||
@@ -83,0 +84,0 @@ /** |
;(function(undefined) { | ||
'use strict'; | ||
/** | ||
* BottleJS v1.6.1 - 2017-05-17 | ||
* BottleJS v1.6.2 - 2017-11-27 | ||
* A powerful dependency injection micro container | ||
@@ -51,3 +51,11 @@ * | ||
var getNestedBottle = function getNestedBottle(name) { | ||
return this.nested[name] || (this.nested[name] = Bottle.pop()); | ||
var bottle; | ||
if (!this.nested[name]) { | ||
bottle = Bottle.pop(); | ||
this.nested[name] = bottle; | ||
this.factory(name, function SubProviderFactory() { | ||
return bottle.container; | ||
}); | ||
} | ||
return this.nested[name]; | ||
}; | ||
@@ -318,3 +326,3 @@ | ||
if (parts.length) { | ||
createSubProvider.call(this, name, Provider, parts); | ||
getNestedBottle.call(this, name).provider(parts.join('.'), Provider); | ||
return this; | ||
@@ -385,20 +393,2 @@ } | ||
/** | ||
* Creates a bottle container on the current bottle container, and registers | ||
* the provider under the sub container. | ||
* | ||
* @param String name | ||
* @param Function Provider | ||
* @param Array parts | ||
* @return Bottle | ||
*/ | ||
var createSubProvider = function createSubProvider(name, Provider, parts) { | ||
var bottle; | ||
bottle = getNestedBottle.call(this, name); | ||
this.factory(name, function SubProviderFactory() { | ||
return bottle.container; | ||
}); | ||
return bottle.provider(parts.join('.'), Provider); | ||
}; | ||
/** | ||
* Register a service, factory, provider, or value based on properties on the object. | ||
@@ -405,0 +395,0 @@ * |
{ | ||
"name": "bottlejs", | ||
"version": "1.6.1", | ||
"version": "1.6.2", | ||
"description": "A powerful dependency injection micro container", | ||
@@ -5,0 +5,0 @@ "main": "dist/bottle.js", |
43430
8
673