0.0.1 • Published 9 years ago

princess v0.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

Modules

module.exports : Scope

Kind: Exported member

Scope

A dependency injection scope.

Kind: global interface

scope.run(deps, fn) ⇒ *

Run a function using dependencies.

Kind: instance method of Scope
Returns: * - the return value of the provided function

ParamTypeDescription
depsArray.<string>dependencies of this function
fnfunctiona function to invoke with that dependency

scope.get(name) ⇒ *

Look up a dependency from this scope.

Kind: instance method of Scope
Returns: * - the registered object

ParamTypeDescription
namestringname of the object to look up

scope.scope(scopes) ⇒ Scope

Create a new scope.

If no argument is provided, this will be a child of the current scope.

If an array of scopes is provided, this will be a child of those scopes.

An empty array can be provided to create a detached scope which inherits from no other scopes.

Kind: instance method of Scope
Returns: Scope - the new scope

ParamTypeDescription
scopesArray.<Scope>parent scopes

scope.has(name)

Check if something of this name has been registered.

Kind: instance method of Scope

ParamTypeDescription
namestringname of the registered object

scope.register(name, deps, fn, scope) ⇒ Scope

Register an object in this dependency injection scope.

Kind: instance method of Scope
Returns: Scope - the current scope

ParamTypeDescription
namestringname of the object to register
depsArray.<string>dependencies of the registered object
fnfunctionfunction which will return this object
scopeScopescope from which to look up dependencies (if omitted, will use the same scope.)
0.0.1

9 years ago