Skip to content

Latest commit

 

History

History
269 lines (164 loc) · 8.59 KB

README.md

File metadata and controls

269 lines (164 loc) · 8.59 KB

pumpit

pumpit

Table of contents

Classes

Type Aliases

Variables

Functions

Type Aliases

AvailableScopes

Ƭ AvailableScopes: keyof typeof SCOPE

Available scopes that can be used

Defined in

types.ts:9


AvailableTypes

Ƭ AvailableTypes: keyof typeof TYPE

Available types that can be binded

Defined in

types.ts:6


BindKey

Ƭ BindKey: string | symbol | Record<string, any>

Type of values that can be used for the bind key

Defined in

types.ts:15


ClassOptions

Ƭ ClassOptions<T, K>: Object

Class bind options

Type parameters

Name Type
T extends ClassValue
K extends AvailableScopes = "TRANSIENT"

Type declaration

Name Type Description
afterResolve? (data: { container: PumpIt ; ctx?: ResolveCtx ; value: any }) => void callback that is called after the value is resolved, number of calls depends on scope used when registering
beforeResolve? (data: { container: PumpIt ; ctx?: ResolveCtx ; value: T extends (...args: any[]) => any ? (...args: ConstructorParameters<T>) => T : (...args: ConstructorParameters<T["value"]>) => T["value"] }, ...deps: T extends (...args: any[]) => any ? ConstructorParameters<T> : ConstructorParameters<T["value"]>) => any callback that is called before the value is resolved, number of calls depends on scope used when registering
scope K Scope that is going to be used AvailableScopes
type typeof CLASS Class constant type AvailableTypes
unbind? (data: { container: PumpIt ; dispose: boolean ; value: K extends "SINGLETON" ? any : undefined }) => void callback that is called before the value is removed from the container. This is only executed for values that are SINGLETONS

Defined in

types.ts:26


ClassValue

Ƭ ClassValue: (...args: any[]) => any | { inject: InjectionData ; value: (...args: any[]) => any }

Defined in

types.ts:21


FactoryOptions

Ƭ FactoryOptions<T, K>: Object

Type parameters

Name Type
T extends FactoryValue
K extends AvailableScopes

Type declaration

Name Type Description
afterResolve? (data: { container: PumpIt ; ctx?: ResolveCtx ; value: any }) => void callback that is called after the value is resolved, number of calls depends on scope used when registering
beforeResolve? (data: { container: PumpIt ; ctx?: ResolveCtx ; value: T extends (...args: any[]) => any ? T : T["value"] }, ...deps: T extends (...args: any[]) => any ? Parameters<T> : Parameters<T["value"]>) => any callback that is called before the value is resolved, number of calls depends on scope used when registering
scope K Scope that is going to be used AvailableScopes
type typeof FACTORY Factory constant type
unbind? (data: { container: PumpIt ; dispose: boolean ; value: K extends "SINGLETON" ? any : undefined }) => void callback that is called before the value is removed from the container. This is only executed for values that are SINGLETONS

Defined in

types.ts:73


FactoryValue

Ƭ FactoryValue: (...args: any[]) => any | { inject: InjectionData ; value: (...args: any[]) => any }

Defined in

types.ts:17


ResolveCtx

Ƭ ResolveCtx: Record<string, any>

Resolve context that is used per request and passed to the callbacks

Defined in

types.ts:12

Variables

SCOPE

Const SCOPE: Object

Constants that represent the type of scopes that can be used SINGLETON - value is resolved only once TRANSIENT - value is resolved everytime it is requested REQUEST - value is resolved once per request PumpIt.resolve() CONTAINER_SINGLETON - the child container will create it's own version of the singleton instance

Type declaration

Name Type
CONTAINER_SINGLETON "CONTAINER_SINGLETON"
REQUEST "REQUEST"
SINGLETON "SINGLETON"
TRANSIENT "TRANSIENT"

Defined in

pumpit.ts:36


TYPE

Const TYPE: Object

Constants that represent the type of values that can be binded

Type declaration

Name Type
CLASS "CLASS"
FACTORY "FACTORY"
VALUE "VALUE"

Defined in

pumpit.ts:24

Functions

get

get(key, options?): () => { key: BindKey ; options: { optional?: boolean } }

get dependency by key

Parameters

Name Type Description
key BindKey dependency BindKey
options? Object options for the resove process
options.optional? boolean if the dependency cannot be resolved undefined will be used

Returns

fn

▸ (): Object

Returns

Object

Name Type
key BindKey
options { optional?: boolean }
options.optional? boolean
Name Type
[INJECTION_FN] typeof INJECTION_FN

Defined in

utils.ts:32


transform

transform(deps, fn): Object

Wrapper function for registering dependencies that can be manipulated before being injected It gets an array of dependencies in injection order, and it should return an array

Parameters

Name Type Description
deps (BindKey | (key: BindKey, options?: { optional?: boolean }) => () => { key: BindKey ; options: { optional?: boolean } })[] array of dependencies that need to be satisfied see: BindKey get()
fn (data: { container: PumpIt ; ctx: ResolveCtx }, ...deps: any[]) => any[] function that will be called with the resolved dependencies

Returns

Object

Name Type
action symbol
deps (BindKey | (key: BindKey, options?: { optional?: boolean }) => () => { key: BindKey ; options: { optional?: boolean } })[]
fn (data: { container: PumpIt ; ctx: ResolveCtx }, ...deps: any[]) => any[]

Defined in

utils.ts:74