@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/es/index.mjs CHANGED
@@ -660,7 +660,7 @@ function isDisposable(value) {
660
660
  if (!registration && isConstructor(token)) {
661
661
  registration = this.autoRegisterClass(token, localName);
662
662
  }
663
- return this.resolveRegistration(token, registration, localOptional, localName);
663
+ return this.resolveRegistration(token, registration, localOptional, localName)?.value;
664
664
  }
665
665
  resolveAll(token, optional) {
666
666
  this.checkDisposed();
@@ -678,8 +678,7 @@ function isDisposable(value) {
678
678
  token
679
679
  ]);
680
680
  }
681
- return registrations //
682
- .map((registration)=>this.resolveRegistration(token, registration, optional)).filter((value)=>value != null);
681
+ return registrations.map((registration)=>this.resolveRegistration(token, registration, optional)).filter((result)=>result !== undefined).map((result)=>result.value);
683
682
  }
684
683
  dispose() {
685
684
  if (this.myDisposed) {
@@ -739,7 +738,9 @@ function isDisposable(value) {
739
738
  ]);
740
739
  }
741
740
  try {
742
- return this.resolveProviderValue(token, registration);
741
+ return {
742
+ value: this.resolveProviderValue(token, registration)
743
+ };
743
744
  } catch (e) {
744
745
  throwResolutionError([
745
746
  token,
@@ -935,7 +936,7 @@ function isDisposable(value) {
935
936
  }
936
937
 
937
938
  /**
938
- * Class decorator that enables auto-registration of an unregistered class,
939
+ * Class decorator that enables auto-registration of an unregistered class
939
940
  * when the class is first resolved from the container.
940
941
  *
941
942
  * @example
@@ -1243,14 +1244,14 @@ function OptionalAll(token) {
1243
1244
  injectAll: (token)=>runInContext(()=>injectAll(token)),
1244
1245
  optional: (token, name)=>runInContext(()=>optional(token, name)),
1245
1246
  optionalAll: (token)=>runInContext(()=>optionalAll(token)),
1246
- runInContext
1247
+ runInContext: runInContext
1247
1248
  };
1248
1249
  }, "Injector");
1249
1250
 
1250
1251
  /**
1251
1252
  * Applies middleware functions to a container.
1252
1253
  *
1253
- * Middlewares are applied in array order, but execute in reverse order.
1254
+ * Middlewares are applied in array order but execute in reverse order.
1254
1255
  *
1255
1256
  * @example
1256
1257
  * ```ts