ts-ioc-container 27.2.0 → 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
  });
@@ -130,9 +130,7 @@ describe('Basic usage', function () {
130
130
 
131
131
  it('should not raise an error when key is busy', () => {
132
132
  expect(() => {
133
- new Container(new ReflectionInjector())
134
- .use(Registration.fromClass(Logger).assignTo('ILogger'))
135
- .use(Registration.fromClass(Logger).assignTo('ILogger'));
133
+ new Container(new ReflectionInjector()).use(Registration.fromClass(Logger)).use(Registration.fromClass(Logger));
136
134
  }).not.toThrowError(RegistrationConflictError);
137
135
  });
138
136
 
@@ -286,7 +284,7 @@ class Logger {}
286
284
  describe('Disposing', function () {
287
285
  it('should container and make it unavailable for the further usage', function () {
288
286
  const root = new Container(new ReflectionInjector(), { tags: ['root'] }).use(
289
- Registration.fromClass(Logger).assignTo('ILogger'),
287
+ Registration.fromClass(Logger).to('ILogger'),
290
288
  );
291
289
  const child = root.createScope('child');
292
290
 
@@ -333,7 +331,7 @@ class App {
333
331
 
334
332
  describe('Reflection Injector', function () {
335
333
  it('should inject dependencies by @inject decorator', function () {
336
- 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'));
337
335
 
338
336
  const app = container.resolve(App);
339
337
 
@@ -356,7 +354,7 @@ describe('SimpleInjector', function () {
356
354
  constructor(public container: IContainer) {}
357
355
  }
358
356
 
359
- 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'));
360
358
  const app = container.resolve<App>('App');
361
359
 
362
360
  expect(app.container).toBeInstanceOf(Container);
@@ -367,7 +365,7 @@ describe('SimpleInjector', function () {
367
365
  constructor(container: IContainer, public greeting: string) {}
368
366
  }
369
367
 
370
- 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'));
371
369
  const app = container.resolve<App>('App', 'Hello world');
372
370
 
373
371
  expect(app.greeting).toBe('Hello world');
@@ -395,7 +393,7 @@ describe('ProxyInjector', function () {
395
393
  }
396
394
  }
397
395
 
398
- 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'));
399
397
 
400
398
  const app = container.resolve(App);
401
399
  expect(app.logger).toBeInstanceOf(Logger);
@@ -425,8 +423,8 @@ describe('ProxyInjector', function () {
425
423
  const greetingTemplate = (name: string) => `Hello ${name}`;
426
424
 
427
425
  const container = new Container(new ProxyInjector())
428
- .use(Registration.fromClass(App).assignTo('App').pipe(args({ greetingTemplate })))
429
- .use(Registration.fromClass(Logger).assignTo('logger'));
426
+ .use(Registration.fromClass(App).to('App').pipe(args({ greetingTemplate })))
427
+ .use(Registration.fromClass(Logger).to('logger'));
430
428
 
431
429
  const app = container.resolve<App>('App', { name: `world` });
432
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.0",
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": "24f9e47646271367a7a000814c6fc4f7470d3bf5"
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;