MCPcopy Create free account
hub / github.com/LeetCode-OpenSource/ayanami / getInstanceWithScope

Function getInstanceWithScope

src/core/scope/index.ts:14–26  ·  view source on GitHub ↗
(
  constructor: ConstructorOf<T>,
  scope: ScopeConfig['scope'] = SingletonScope,
)

Source from the content-addressed store, hash-verified

12export const SingletonScope = Symbol('scope:singleton')
13
14export function getInstanceWithScope<T>(
15 constructor: ConstructorOf<T>,
16 scope: ScopeConfig['scope'] = SingletonScope,
17): T {
18 switch (scope) {
19 case SingletonScope:
20 return InjectableFactory.getInstance(constructor)
21 case TransientScope:
22 return InjectableFactory.initialize(constructor)
23 default:
24 return createOrGetInstanceInScope(constructor, scope)
25 }
26}

Callers 2

useAyanamiFunction · 0.90
scope.spec.tsFile · 0.85

Calls 1

Tested by

no test coverage detected