Home Reference Source Test Repository
public class | source

Jsimple

Test:

Constructor Summary

Public Constructor
public
Builds a new Jsimple instance

Member Summary

Protected Members
protected
protected
protected
protected

Method Summary

Public Methods
public

define(name: String, value: * | Function(container: Jsimple): *, tags: Array<String>): Jsimple

Sets a parameter or an object factory
public
public

extend(name: String, code: Function(service: *, container: Jsimple): *, tags: Array<String>): Jsimple

public

factory(name: String, code: Function(container: Jsimple): *, tags: Array<String>): Jsimple

public

get(name: String): *

public
this method was deprecated. Use {@link Jsimple#tagged} instead
public

keys(): Array

this method was deprecated.
public

protect(code: Function(): *): Function(): *

public
public

raw(name: String): Function(container: Jsimple): *

public

share(name: String, code: Function(container: Jsimple): *, tags: Array<String>): Jsimple

public
public

use(deps: Array<String> | Function(deps: *, container: Jsimple): *, code: Function(deps: *, container: Jsimple): *): *

Public Constructors

public constructor source

Builds a new Jsimple instance

Test:

Protected Members

protected frozen: Set<String> source

protected shared: Map<String, *> source

protected tagmap: Map<String, Set> source

protected values: Map<String, *> source

Public Methods

public define(name: String, value: * | Function(container: Jsimple): *, tags: Array<String>): Jsimple source

Sets a parameter or an object factory

Params:

NameTypeAttributeDescription
name String

The unique identifier for the parameter or factory

value * | Function(container: Jsimple): *

The parameter value or a factory function

tags Array<String>
  • optional

An array of tags to associate to the parameter or factory

Return:

Jsimple

The current Jsimple instance

Test:

public exists(name: String): Boolean source

Params:

NameTypeAttributeDescription
name String

The unique identifier for the parameter, service or factory

Return:

Boolean

Wether the parameter, service or factory exists

public extend(name: String, code: Function(service: *, container: Jsimple): *, tags: Array<String>): Jsimple source

Params:

NameTypeAttributeDescription
name String

The unique identifier for the parameter or factory to extend

code Function(service: *, container: Jsimple): *

The executable extended function

tags Array<String>
  • optional

An array of tags to associate to the the parameter or factory to extend

Return:

Jsimple

The current Jsimple instance

Test:

public factory(name: String, code: Function(container: Jsimple): *, tags: Array<String>): Jsimple source

Params:

NameTypeAttributeDescription
name String

The unique identifier for the factory

code Function(container: Jsimple): *

The executable factory function

tags Array<String>
  • optional

An array of tags to associate to the factory

Return:

Jsimple

The current Jsimple instance

Test:

public get(name: String): * source

Params:

NameTypeAttributeDescription
name String

The unique identifier for the parameter, service or factory to fetch

Return:

*

Result of executing the factory function

public getTagged(tag: String): Array source

this method was deprecated. Use {@link Jsimple#tagged} instead

Params:

NameTypeAttributeDescription
tag String

The tag name for which to fetch parameters, services or factories

Return:

Array

Service names associated with the provided tag

See:

public keys(): Array source

this method was deprecated.

Return:

Array

Declared parameter, service and factory names

public protect(code: Function(): *): Function(): * source

Params:

NameTypeAttributeDescription
code Function(): *

Function to be protected from becoming a factory

Return:

Function(): *

Function wrapping the provided function as code

Test:

public proxify(): Jsimple source

Return:

Jsimple

The current Jsimple instance wrapped in a Proxy

Test:

public raw(name: String): Function(container: Jsimple): * source

Params:

NameTypeAttributeDescription
name String

The unique identifier for the factory to fetch

Return:

Function(container: Jsimple): *

The declared factory function

Test:

public share(name: String, code: Function(container: Jsimple): *, tags: Array<String>): Jsimple source

Params:

NameTypeAttributeDescription
name String

The unique identifier for the factory

code Function(container: Jsimple): *

The executable factory function

tags Array<String>
  • optional

An array of tags to associate to the factory

Return:

Jsimple

The current Jsimple instance

Test:

public tagged(tags: String | Array<String>): Array source

Params:

NameTypeAttributeDescription
tags String | Array<String>

The tag names for which to fetch parameters, services or factories

Return:

Array

Service names associated with the provided tags

Test:

public use(deps: Array<String> | Function(deps: *, container: Jsimple): *, code: Function(deps: *, container: Jsimple): *): * source

Params:

NameTypeAttributeDescription
deps Array<String> | Function(deps: *, container: Jsimple): *

List of dependencies to inject or executable function

code Function(deps: *, container: Jsimple): *
  • optional

Executable function

Return:

*

Result of executing the provided function as code

Test: