ts-ioc-container 55.3.0 → 55.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjm/hooks/HooksRunner.js
CHANGED
|
@@ -10,6 +10,9 @@ class HooksRunner {
|
|
|
10
10
|
constructor(key) {
|
|
11
11
|
this.key = key;
|
|
12
12
|
}
|
|
13
|
+
hasHooks(target) {
|
|
14
|
+
return (0, hook_1.hasHooks)(target, this.key);
|
|
15
|
+
}
|
|
13
16
|
execute(target, { scope, createContext = HookContext_1.createHookContext, mapContext = (context) => context, predicate = () => true, }) {
|
|
14
17
|
const hooks = Array.from((0, hook_1.getHooks)(target, this.key).entries()).filter(([methodName]) => predicate(methodName));
|
|
15
18
|
const runMethodHooks = (methodName, executions) => {
|
package/esm/hooks/HooksRunner.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHookContext } from './HookContext';
|
|
2
|
-
import { getHooks, toHookFn } from './hook';
|
|
2
|
+
import { getHooks, hasHooks, toHookFn } from './hook';
|
|
3
3
|
import { UnexpectedHookResultError } from '../errors/UnexpectedHookResultError';
|
|
4
4
|
import { promisify } from '../utils/promise';
|
|
5
5
|
export class HooksRunner {
|
|
@@ -7,6 +7,9 @@ export class HooksRunner {
|
|
|
7
7
|
constructor(key) {
|
|
8
8
|
this.key = key;
|
|
9
9
|
}
|
|
10
|
+
hasHooks(target) {
|
|
11
|
+
return hasHooks(target, this.key);
|
|
12
|
+
}
|
|
10
13
|
execute(target, { scope, createContext = createHookContext, mapContext = (context) => context, predicate = () => true, }) {
|
|
11
14
|
const hooks = Array.from(getHooks(target, this.key).entries()).filter(([methodName]) => predicate(methodName));
|
|
12
15
|
const runMethodHooks = (methodName, executions) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-ioc-container",
|
|
3
|
-
"version": "55.
|
|
3
|
+
"version": "55.4.0",
|
|
4
4
|
"description": "Fast, lightweight TypeScript dependency injection container with a clean API, scoped lifecycles, decorators, tokens, hooks, lazy injection, customizable providers, and no global container objects.",
|
|
5
5
|
"workspaces": [
|
|
6
6
|
"docs"
|
|
@@ -10,6 +10,7 @@ export type HooksRunnerContext = {
|
|
|
10
10
|
export declare class HooksRunner {
|
|
11
11
|
private readonly key;
|
|
12
12
|
constructor(key: string | symbol);
|
|
13
|
+
hasHooks(target: object): boolean;
|
|
13
14
|
execute(target: object, { scope, createContext, mapContext, predicate, }: HooksRunnerContext): void;
|
|
14
15
|
executeAsync(target: object, { scope, createContext, mapContext, predicate, }: HooksRunnerContext): Promise<void[]>;
|
|
15
16
|
}
|