ts-ioc-container 27.2.1 → 27.3.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/README.md CHANGED
@@ -99,7 +99,7 @@ describe('Basic usage', function () {
99
99
  constructor(@inject(by.key('ILogger')) public logger: Logger) {}
100
100
  }
101
101
 
102
- const container = new Container(new ReflectionInjector()).use(Registration.fromClass(Logger).assignTo('ILogger'));
102
+ const container = new Container(new ReflectionInjector()).use(Registration.fromClass(Logger).to('ILogger'));
103
103
 
104
104
  expect(container.resolve(App).logger.name).toBe('Logger');
105
105
  });
@@ -110,8 +110,8 @@ describe('Basic usage', function () {
110
110
  }
111
111
 
112
112
  const container = new Container(new ReflectionInjector())
113
- .use(Registration.fromClass(Logger).assignTo('ILogger1'))
114
- .use(Registration.fromClass(Logger).assignTo('ILogger2'));
113
+ .use(Registration.fromClass(Logger).to('ILogger1'))
114
+ .use(Registration.fromClass(Logger).to('ILogger2'));
115
115
 
116
116
  expect(container.resolve(App).loggers).toHaveLength(2);
117
117
  });
@@ -284,7 +284,7 @@ class Logger {}
284
284
  describe('Disposing', function () {
285
285
  it('should container and make it unavailable for the further usage', function () {
286
286
  const root = new Container(new ReflectionInjector(), { tags: ['root'] }).use(
287
- Registration.fromClass(Logger).assignTo('ILogger'),
287
+ Registration.fromClass(Logger).to('ILogger'),
288
288
  );
289
289
  const child = root.createScope('child');
290
290
 
@@ -331,7 +331,7 @@ class App {
331
331
 
332
332
  describe('Reflection Injector', function () {
333
333
  it('should inject dependencies by @inject decorator', function () {
334
- const container = new Container(new ReflectionInjector()).use(Registration.fromClass(Logger).assignTo('ILogger'));
334
+ const container = new Container(new ReflectionInjector()).use(Registration.fromClass(Logger).to('ILogger'));
335
335
 
336
336
  const app = container.resolve(App);
337
337
 
@@ -354,7 +354,7 @@ describe('SimpleInjector', function () {
354
354
  constructor(public container: IContainer) {}
355
355
  }
356
356
 
357
- const container = new Container(new SimpleInjector()).use(Registration.fromClass(App).assignTo('App'));
357
+ const container = new Container(new SimpleInjector()).use(Registration.fromClass(App).to('App'));
358
358
  const app = container.resolve<App>('App');
359
359
 
360
360
  expect(app.container).toBeInstanceOf(Container);
@@ -365,7 +365,7 @@ describe('SimpleInjector', function () {
365
365
  constructor(container: IContainer, public greeting: string) {}
366
366
  }
367
367
 
368
- const container = new Container(new SimpleInjector()).use(Registration.fromClass(App).assignTo('App'));
368
+ const container = new Container(new SimpleInjector()).use(Registration.fromClass(App).to('App'));
369
369
  const app = container.resolve<App>('App', 'Hello world');
370
370
 
371
371
  expect(app.greeting).toBe('Hello world');
@@ -393,7 +393,7 @@ describe('ProxyInjector', function () {
393
393
  }
394
394
  }
395
395
 
396
- const container = new Container(new ProxyInjector()).use(Registration.fromClass(Logger).assignTo('logger'));
396
+ const container = new Container(new ProxyInjector()).use(Registration.fromClass(Logger).to('logger'));
397
397
 
398
398
  const app = container.resolve(App);
399
399
  expect(app.logger).toBeInstanceOf(Logger);
@@ -423,8 +423,8 @@ describe('ProxyInjector', function () {
423
423
  const greetingTemplate = (name: string) => `Hello ${name}`;
424
424
 
425
425
  const container = new Container(new ProxyInjector())
426
- .use(Registration.fromClass(App).assignTo('App').pipe(args({ greetingTemplate })))
427
- .use(Registration.fromClass(Logger).assignTo('logger'));
426
+ .use(Registration.fromClass(App).to('App').pipe(args({ greetingTemplate })))
427
+ .use(Registration.fromClass(Logger).to('logger'));
428
428
 
429
429
  const app = container.resolve<App>('App', { name: `world` });
430
430
  expect(app.greeting).toBe('Hello world');
@@ -8,8 +8,8 @@ class RegistrationDecorator {
8
8
  getKey() {
9
9
  return this.decorated.getKey();
10
10
  }
11
- assignTo(key) {
12
- this.decorated.assignTo(key);
11
+ to(key) {
12
+ this.decorated.to(key);
13
13
  return this;
14
14
  }
15
15
  pipe(...mappers) {
@@ -19,7 +19,7 @@ class Registration {
19
19
  getKey() {
20
20
  return this.key;
21
21
  }
22
- assignTo(key) {
22
+ to(key) {
23
23
  this.key = key;
24
24
  return this;
25
25
  }
@@ -5,8 +5,8 @@ export class RegistrationDecorator {
5
5
  getKey() {
6
6
  return this.decorated.getKey();
7
7
  }
8
- assignTo(key) {
9
- this.decorated.assignTo(key);
8
+ to(key) {
9
+ this.decorated.to(key);
10
10
  return this;
11
11
  }
12
12
  pipe(...mappers) {
@@ -15,7 +15,7 @@ export class Registration {
15
15
  getKey() {
16
16
  return this.key;
17
17
  }
18
- assignTo(key) {
18
+ to(key) {
19
19
  this.key = key;
20
20
  return this;
21
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-ioc-container",
3
- "version": "27.2.1",
3
+ "version": "27.3.0",
4
4
  "description": "Typescript IoC container",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -60,5 +60,5 @@
60
60
  "ts-node": "^10.9.1",
61
61
  "typescript": "4.4.3"
62
62
  },
63
- "gitHead": "e01a8df7f3eb7ad5563f9f9185c25bbe171e4af7"
63
+ "gitHead": "68462d7b245697342b3250124d4a668c6641fccf"
64
64
  }
@@ -3,14 +3,14 @@ import { MapFn } from '../utils';
3
3
  import { IProvider } from '../provider/IProvider';
4
4
  export interface IRegistration extends IContainerModule {
5
5
  getKey(): DependencyKey;
6
- assignTo(key: DependencyKey): this;
6
+ to(key: DependencyKey): this;
7
7
  pipe(...mappers: MapFn<IProvider>[]): this;
8
8
  }
9
9
  export declare abstract class RegistrationDecorator implements IRegistration {
10
10
  private decorated;
11
11
  constructor(decorated: IRegistration);
12
12
  getKey(): DependencyKey;
13
- assignTo(key: DependencyKey): this;
13
+ to(key: DependencyKey): this;
14
14
  pipe(...mappers: MapFn<IProvider>[]): this;
15
15
  applyTo(container: IContainer): void;
16
16
  }
@@ -10,7 +10,7 @@ export declare class Registration implements IRegistration {
10
10
  static fromClass(Target: constructor<unknown>): Registration;
11
11
  constructor(key: DependencyKey, provider: IProvider);
12
12
  getKey(): DependencyKey;
13
- assignTo(key: DependencyKey): this;
13
+ to(key: DependencyKey): this;
14
14
  throwErrorOnConflict(): ThrowErrorIfNoDependency;
15
15
  pipe(...mappers: MapFn<IProvider>[]): this;
16
16
  applyTo(container: IContainer): void;