@lppedd/di-wise-neo 0.11.1 → 0.11.2

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.
@@ -431,9 +431,9 @@ interface Container {
431
431
  *
432
432
  * @see The documentation for `resolve(token: Token)`
433
433
  */
434
- resolveAll<Value>(token: Token<Value>, optional?: false): NonNullable<Value>[];
435
- resolveAll<Value>(token: Token<Value>, optional: true): NonNullable<Value>[];
436
- resolveAll<Value>(token: Token<Value>, optional?: boolean): NonNullable<Value>[];
434
+ resolveAll<Value>(token: Token<Value>, optional?: false): Value[];
435
+ resolveAll<Value>(token: Token<Value>, optional: true): Value[];
436
+ resolveAll<Value>(token: Token<Value>, optional?: boolean): Value[];
437
437
  /**
438
438
  * Disposes this container and all its cached values.
439
439
  *
@@ -450,7 +450,7 @@ interface Container {
450
450
  declare function createContainer(options?: Partial<ContainerOptions>): Container;
451
451
 
452
452
  /**
453
- * Class decorator that enables auto-registration of an unregistered class,
453
+ * Class decorator that enables auto-registration of an unregistered class
454
454
  * when the class is first resolved from the container.
455
455
  *
456
456
  * @example
@@ -536,7 +536,7 @@ declare function Inject<Value>(token: Token<Value>): ParameterDecorator;
536
536
  declare function Inject<Value>(tokens: TokenRef<Value>): ParameterDecorator;
537
537
 
538
538
  /**
539
- * Class decorator that registers additional aliasing tokens for the decorated type,
539
+ * Class decorator that registers additional aliasing tokens for the decorated type
540
540
  * when the type is first registered in the container.
541
541
  *
542
542
  * The container uses {@link ExistingProvider} under the hood.
@@ -549,7 +549,7 @@ declare function Inject<Value>(tokens: TokenRef<Value>): ParameterDecorator;
549
549
  */
550
550
  declare function Injectable<This extends object, Value extends This>(...tokens: Tokens<Value>): ClassDecorator;
551
551
  /**
552
- * Class decorator that registers additional aliasing tokens for the decorated type,
552
+ * Class decorator that registers additional aliasing tokens for the decorated type
553
553
  * when the type is first registered in the container.
554
554
  *
555
555
  * The container uses {@link ExistingProvider} under the hood.
@@ -651,19 +651,19 @@ declare function Optional<Value>(tokens: TokenRef<Value>): ParameterDecorator;
651
651
 
652
652
  /**
653
653
  * Parameter decorator that injects all instances provided by the registrations
654
- * associated with the given class, or an empty array if the class is not registered
654
+ * associated with the given class or an empty array if the class is not registered
655
655
  * in the container.
656
656
  */
657
657
  declare function OptionalAll<Instance extends object>(Class: Constructor<Instance>): ParameterDecorator;
658
658
  /**
659
659
  * Parameter decorator that injects all values provided by the registrations
660
- * associated with the given token, or an empty array if the token is not registered
660
+ * associated with the given token or an empty array if the token is not registered
661
661
  * in the container.
662
662
  */
663
663
  declare function OptionalAll<Value>(token: Token<Value>): ParameterDecorator;
664
664
  /**
665
665
  * Parameter decorator that injects all values provided by the registrations
666
- * associated with the given token, or an empty array if the token is not registered
666
+ * associated with the given token or an empty array if the token is not registered
667
667
  * in the container.
668
668
  *
669
669
  * Allows referencing a token declared later in the file by using the
@@ -776,7 +776,7 @@ declare function injectAll<Instance extends object>(Class: Constructor<Instance>
776
776
  *
777
777
  * Throws an error if the token is not registered in the container.
778
778
  */
779
- declare function injectAll<Value>(token: Token<Value>): NonNullable<Value>[];
779
+ declare function injectAll<Value>(token: Token<Value>): Value[];
780
780
 
781
781
  /**
782
782
  * Injector API.
@@ -805,7 +805,7 @@ interface Injector {
805
805
  *
806
806
  * Throws an error if the token is not registered in the container.
807
807
  */
808
- injectAll<Value>(token: Token<Value>): NonNullable<Value>[];
808
+ injectAll<Value>(token: Token<Value>): Value[];
809
809
  /**
810
810
  * Injects the instance associated with the given class,
811
811
  * or `undefined` if the class is not registered in the container.
@@ -817,15 +817,15 @@ interface Injector {
817
817
  */
818
818
  optional<Value>(token: Token<Value>, name?: string): Value | undefined;
819
819
  /**
820
- * Injects all instances provided by the registrations associated with the given class,
820
+ * Injects all instances provided by the registrations associated with the given class
821
821
  * or an empty array if the class is not registered in the container.
822
822
  */
823
823
  optionalAll<Instance extends object>(Class: Constructor<Instance>): Instance[];
824
824
  /**
825
- * Injects all values provided by the registrations associated with the given token,
825
+ * Injects all values provided by the registrations associated with the given token
826
826
  * or an empty array if the token is not registered in the container.
827
827
  */
828
- optionalAll<Value>(token: Token<Value>): NonNullable<Value>[];
828
+ optionalAll<Value>(token: Token<Value>): Value[];
829
829
  /**
830
830
  * Runs a function inside the injection context of this injector.
831
831
  *
@@ -909,7 +909,7 @@ interface Middleware {
909
909
  /**
910
910
  * Applies middleware functions to a container.
911
911
  *
912
- * Middlewares are applied in array order, but execute in reverse order.
912
+ * Middlewares are applied in array order but execute in reverse order.
913
913
  *
914
914
  * @example
915
915
  * ```ts
@@ -967,15 +967,15 @@ declare function optionalBy<Instance extends object>(thisArg: any, Class: Constr
967
967
  declare function optionalBy<Value>(thisArg: any, token: Token<Value>, name?: string): Value | undefined;
968
968
 
969
969
  /**
970
- * Injects all instances provided by the registrations associated with the given class,
970
+ * Injects all instances provided by the registrations associated with the given class
971
971
  * or an empty array if the class is not registered in the container.
972
972
  */
973
973
  declare function optionalAll<Instance extends object>(Class: Constructor<Instance>): Instance[];
974
974
  /**
975
- * Injects all values provided by the registrations associated with the given token,
975
+ * Injects all values provided by the registrations associated with the given token
976
976
  * or an empty array if the token is not registered in the container.
977
977
  */
978
- declare function optionalAll<Value>(token: Token<Value>): NonNullable<Value>[];
978
+ declare function optionalAll<Value>(token: Token<Value>): Value[];
979
979
 
980
980
  export { AutoRegister, EagerInstantiate, Inject, InjectAll, Injectable, Injector, Named, Optional, OptionalAll, Scope, Scoped, applyMiddleware, build, createContainer, createType, forwardRef, inject, injectAll, injectBy, optional, optionalAll, optionalBy, setClassIdentityMapping };
981
981
  export type { ClassProvider, Constructor, Container, ContainerOptions, ExistingProvider, FactoryProvider, Middleware, MiddlewareComposer, Provider, RegistrationOptions, Token, TokenRef, Tokens, TokensRef, Type, ValueProvider };
package/dist/cjs/index.js CHANGED
@@ -662,7 +662,7 @@ function isDisposable(value) {
662
662
  if (!registration && isConstructor(token)) {
663
663
  registration = this.autoRegisterClass(token, localName);
664
664
  }
665
- return this.resolveRegistration(token, registration, localOptional, localName);
665
+ return this.resolveRegistration(token, registration, localOptional, localName)?.value;
666
666
  }
667
667
  resolveAll(token, optional) {
668
668
  this.checkDisposed();
@@ -680,8 +680,7 @@ function isDisposable(value) {
680
680
  token
681
681
  ]);
682
682
  }
683
- return registrations //
684
- .map((registration)=>this.resolveRegistration(token, registration, optional)).filter((value)=>value != null);
683
+ return registrations.map((registration)=>this.resolveRegistration(token, registration, optional)).filter((result)=>result !== undefined).map((result)=>result.value);
685
684
  }
686
685
  dispose() {
687
686
  if (this.myDisposed) {
@@ -741,7 +740,9 @@ function isDisposable(value) {
741
740
  ]);
742
741
  }
743
742
  try {
744
- return this.resolveProviderValue(token, registration);
743
+ return {
744
+ value: this.resolveProviderValue(token, registration)
745
+ };
745
746
  } catch (e) {
746
747
  throwResolutionError([
747
748
  token,
@@ -937,7 +938,7 @@ function isDisposable(value) {
937
938
  }
938
939
 
939
940
  /**
940
- * Class decorator that enables auto-registration of an unregistered class,
941
+ * Class decorator that enables auto-registration of an unregistered class
941
942
  * when the class is first resolved from the container.
942
943
  *
943
944
  * @example
@@ -1245,14 +1246,14 @@ function OptionalAll(token) {
1245
1246
  injectAll: (token)=>runInContext(()=>injectAll(token)),
1246
1247
  optional: (token, name)=>runInContext(()=>optional(token, name)),
1247
1248
  optionalAll: (token)=>runInContext(()=>optionalAll(token)),
1248
- runInContext
1249
+ runInContext: runInContext
1249
1250
  };
1250
1251
  }, "Injector");
1251
1252
 
1252
1253
  /**
1253
1254
  * Applies middleware functions to a container.
1254
1255
  *
1255
- * Middlewares are applied in array order, but execute in reverse order.
1256
+ * Middlewares are applied in array order but execute in reverse order.
1256
1257
  *
1257
1258
  * @example
1258
1259
  * ```ts