Passed
Push — develop ( b29f4f...17fc35 )
by Lorenzo
01:11 queued 14s
created

src/decorators/Setup.ts   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 19
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
eloc 12
mnd 0
bc 0
fnc 1
dl 0
loc 19
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
ccs 5
cts 5
cp 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A Setup.ts ➔ Setup 0 15 1
1
import { ExpressBean } from '@/ExpressBeansTypes';
2
import { logger, registeredMethods } from '@/decorators';
3
4
/**
5
   * Hook a function to initialization phase.
6
   * @decorator
7
   */
8
export function Setup<This>(
9
  method: () => void,
10
  context: ClassMethodDecoratorContext<This, () => void>,
11
) {
12 1
  setImmediate(() => {
13 1
    const bean = registeredMethods.get(method) as ExpressBean;
14 1
    logger.debug(`Running setup function ${bean.className}.${String(context.name)}`);
15 1
    method.bind(bean)();
16
  });
17 1
  return method;
18
}
19