Comparing version 1.2.3 to 1.3.0
@@ -1,2 +0,2 @@ | ||
export class Bottle { | ||
declare class Bottle { | ||
static pop: (name?: string) => Bottle | ||
@@ -66,3 +66,5 @@ static config: Object; | ||
export module Bottle { | ||
export = Bottle; | ||
declare module Bottle { | ||
interface IRegisterableObject { | ||
@@ -69,0 +71,0 @@ $name: string; |
;(function(undefined) { | ||
'use strict'; | ||
/** | ||
* BottleJS v1.2.3 - 2016-03-04 | ||
* BottleJS v1.3.0 - 2016-04-29 | ||
* A powerful dependency injection micro container | ||
@@ -97,3 +97,3 @@ * | ||
* @return mixed | ||
* @throws | ||
* @throws Error if Bottle is unable to resolve the requested service. | ||
*/ | ||
@@ -218,2 +218,19 @@ var getNested = function getNested(obj, prop) { | ||
/** | ||
* A filter function for removing bottle container methods and providers from a list of keys | ||
*/ | ||
var byMethod = function byMethod(name) { | ||
return !/^\$(?:register|list)$|Provider$/.test(name); | ||
}; | ||
/** | ||
* List the services registered on the container. | ||
* | ||
* @param Object container | ||
* @return Array | ||
*/ | ||
var list = function list(container) { | ||
return Object.keys(container || this.container || {}).filter(byMethod); | ||
}; | ||
/** | ||
* Map of middleware by index => name | ||
@@ -488,3 +505,3 @@ * | ||
* @param mixed val | ||
* @return | ||
* @return Bottle | ||
*/ | ||
@@ -543,3 +560,6 @@ var value = function value(name, val) { | ||
this.id = id++; | ||
this.container = { $register : register.bind(this) }; | ||
this.container = { | ||
$register : register.bind(this), | ||
$list : list.bind(this) | ||
}; | ||
}; | ||
@@ -556,2 +576,3 @@ | ||
factory : factory, | ||
list : list, | ||
middleware : middleware, | ||
@@ -569,2 +590,3 @@ provider : provider, | ||
Bottle.pop = pop; | ||
Bottle.list = list; | ||
@@ -571,0 +593,0 @@ /** |
{ | ||
"name": "bottlejs", | ||
"version": "1.2.3", | ||
"version": "1.3.0", | ||
"description": "A powerful dependency injection micro container", | ||
@@ -5,0 +5,0 @@ "main": "dist/bottle.js", |
@@ -106,3 +106,3 @@ | ||
This is the meat of the Bottle library. The above methods `Bottle#service` and `Bottle#factory` are just shorthand for the provider function. You usually can get by with the simple functions above, but if you really need more granular control of your services in different environments, regiser them as a provider. To use it, pass a constructor for the provider that exposes a `$get` function. The `$get` function is used as a factory to build your service. | ||
This is the meat of the Bottle library. The above methods `Bottle#service` and `Bottle#factory` are just shorthand for the provider function. You usually can get by with the simple functions above, but if you really need more granular control of your services in different environments, register them as a provider. To use it, pass a constructor for the provider that exposes a `$get` function. The `$get` function is used as a factory to build your service. | ||
@@ -206,3 +206,3 @@ ```js | ||
#### pop([name]) | ||
#### pop(name) | ||
@@ -215,2 +215,14 @@ Used to get an instance of bottle. If a name is passed, bottle will return the same instance. Calling the Bottle constructor as a function will call and return return `Bottle.pop`, so `Bottle.pop('Soda') === Bottle('Soda')` | ||
#### list(container) | ||
#### prototype.list() | ||
#### prototype.container.$list() | ||
Used to list the names of all registered constants, values, and services on the container. Must pass a container to the global static version `Bottle.list(bottle.container)`. The instance and container versions return the services that are registered within. | ||
Returns an array of strings. | ||
Param | Type | Details | ||
:-------------------------------|:-----------|:-------- | ||
**container**<br />*(optional)* | *Object* | A `bottle.container`. Only required when using the global, static `Bottle.list` method. The prototype version uses that instance's container, and the container version uses itself. | ||
#### config | ||
@@ -328,2 +340,2 @@ | ||
A TypeScript declaration file is bundled with this package. To get TypeScript to resolve it automatically, you need to set `moduleResolution` to `node` in your `tsconfig.json`. | ||
A TypeScript declaration file is bundled with this package. To get TypeScript to resolve it automatically, you need to set `moduleResolution` to `node` in your `tsconfig.json`. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37607
655
338