ts-ioc-container 46.5.0 → 46.6.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.
@@ -10,6 +10,9 @@ class ClassToken extends InjectionToken_1.InjectionToken {
10
10
  this.token = token;
11
11
  this.options = options;
12
12
  }
13
+ select(fn) {
14
+ return (s) => fn(this.resolve(s));
15
+ }
13
16
  resolve(s) {
14
17
  const argsFn = this.options.argsFn ?? (0, InjectionToken_1.setArgs)();
15
18
  return s.resolve(this.token, {
@@ -10,6 +10,9 @@ class GroupAliasToken extends InjectionToken_1.InjectionToken {
10
10
  this.token = token;
11
11
  this.options = options;
12
12
  }
13
+ select(fn) {
14
+ return (s) => this.resolve(s).map(fn);
15
+ }
13
16
  resolve(s) {
14
17
  const argsFn = this.options.argsFn ?? (0, InjectionToken_1.setArgs)();
15
18
  return s.resolveByAlias(this.token, {
@@ -10,6 +10,9 @@ class GroupInstanceToken extends InjectionToken_1.InjectionToken {
10
10
  super();
11
11
  this.predicate = predicate;
12
12
  }
13
+ select(fn) {
14
+ return (s) => this.resolve(s).map(fn);
15
+ }
13
16
  args(...deps) {
14
17
  throw new MethodNotImplementedError_1.MethodNotImplementedError('not implemented');
15
18
  }
@@ -10,6 +10,9 @@ class SingleAliasToken extends InjectionToken_1.InjectionToken {
10
10
  this.token = token;
11
11
  this.options = options;
12
12
  }
13
+ select(fn) {
14
+ return (s) => fn(this.resolve(s));
15
+ }
13
16
  resolve(s) {
14
17
  const argsFn = this.options.argsFn ?? (0, InjectionToken_1.setArgs)();
15
18
  return s.resolveOneByAlias(this.token, {
@@ -10,6 +10,9 @@ class SingleToken extends InjectionToken_1.InjectionToken {
10
10
  this.token = token;
11
11
  this.options = options;
12
12
  }
13
+ select(fn) {
14
+ return (s) => fn(this.resolve(s));
15
+ }
13
16
  resolve(s) {
14
17
  const argsFn = this.options.argsFn ?? (0, InjectionToken_1.setArgs)();
15
18
  return s.resolve(this.token, {
@@ -7,6 +7,9 @@ export class ClassToken extends InjectionToken {
7
7
  this.token = token;
8
8
  this.options = options;
9
9
  }
10
+ select(fn) {
11
+ return (s) => fn(this.resolve(s));
12
+ }
10
13
  resolve(s) {
11
14
  const argsFn = this.options.argsFn ?? setArgs();
12
15
  return s.resolve(this.token, {
@@ -7,6 +7,9 @@ export class GroupAliasToken extends InjectionToken {
7
7
  this.token = token;
8
8
  this.options = options;
9
9
  }
10
+ select(fn) {
11
+ return (s) => this.resolve(s).map(fn);
12
+ }
10
13
  resolve(s) {
11
14
  const argsFn = this.options.argsFn ?? setArgs();
12
15
  return s.resolveByAlias(this.token, {
@@ -7,6 +7,9 @@ export class GroupInstanceToken extends InjectionToken {
7
7
  super();
8
8
  this.predicate = predicate;
9
9
  }
10
+ select(fn) {
11
+ return (s) => this.resolve(s).map(fn);
12
+ }
10
13
  args(...deps) {
11
14
  throw new MethodNotImplementedError('not implemented');
12
15
  }
@@ -7,6 +7,9 @@ export class SingleAliasToken extends InjectionToken {
7
7
  this.token = token;
8
8
  this.options = options;
9
9
  }
10
+ select(fn) {
11
+ return (s) => fn(this.resolve(s));
12
+ }
10
13
  resolve(s) {
11
14
  const argsFn = this.options.argsFn ?? setArgs();
12
15
  return s.resolveOneByAlias(this.token, {
@@ -7,6 +7,9 @@ export class SingleToken extends InjectionToken {
7
7
  this.token = token;
8
8
  this.options = options;
9
9
  }
10
+ select(fn) {
11
+ return (s) => fn(this.resolve(s));
12
+ }
10
13
  resolve(s) {
11
14
  const argsFn = this.options.argsFn ?? setArgs();
12
15
  return s.resolve(this.token, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-ioc-container",
3
- "version": "46.5.0",
3
+ "version": "46.6.0",
4
4
  "description": "Typescript IoC container",
5
5
  "workspaces": [
6
6
  "docs"
@@ -5,6 +5,7 @@ export declare class ClassToken<T = any> extends InjectionToken<T> {
5
5
  private readonly token;
6
6
  private options;
7
7
  constructor(token: constructor<T>, options?: TokenOptions);
8
+ select<R>(fn: (target: T) => R): (s: IContainer) => R;
8
9
  resolve(s: IContainer): T;
9
10
  args(...args: unknown[]): InjectionToken<T>;
10
11
  argsFn(getArgsFn: (s: IContainer) => unknown[]): InjectionToken<T>;
@@ -6,6 +6,7 @@ export declare class GroupAliasToken<T = any> extends InjectionToken<T[]> implem
6
6
  readonly token: string | symbol;
7
7
  private options;
8
8
  constructor(token: string | symbol, options?: TokenOptions);
9
+ select<R>(fn: (target: T) => R): (s: IContainer) => R[];
9
10
  resolve(s: IContainer): T[];
10
11
  bindTo(r: IRegistration<T>): void;
11
12
  args(...args: unknown[]): GroupAliasToken<T>;
@@ -6,6 +6,7 @@ export declare class GroupInstanceToken extends InjectionToken<Instance[]> {
6
6
  private predicate;
7
7
  private isCascade;
8
8
  constructor(predicate: InstancePredicate);
9
+ select<R>(fn: (target: Instance) => R): (s: IContainer) => R[];
9
10
  args(...deps: unknown[]): this;
10
11
  argsFn(getArgsFn: (s: IContainer) => unknown[]): InjectionToken<Instance[]>;
11
12
  lazy(): InjectionToken<Instance[]>;
@@ -6,6 +6,7 @@ export declare class SingleAliasToken<T = any> extends InjectionToken<T> impleme
6
6
  readonly token: string | symbol;
7
7
  private options;
8
8
  constructor(token: string | symbol, options?: TokenOptions);
9
+ select<R>(fn: (target: T) => R): (s: IContainer) => R;
9
10
  resolve(s: IContainer): T;
10
11
  bindTo(r: IRegistration<T>): void;
11
12
  args(...args: unknown[]): InjectionToken<T>;
@@ -5,6 +5,7 @@ export declare class SingleToken<T = any> extends InjectionToken {
5
5
  token: string | symbol;
6
6
  private options;
7
7
  constructor(token: string | symbol, options?: TokenOptions);
8
+ select<R>(fn: (target: T) => R): (s: IContainer) => R;
8
9
  resolve(s: IContainer): T;
9
10
  bindTo(r: IRegistration<T>): void;
10
11
  args(...args: unknown[]): SingleToken<T>;