di.mjs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * @license Angular v19.2.13
  3. * (c) 2010-2025 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. /**
  7. * Current injector value used by `inject`.
  8. * - `undefined`: it is an error to call `inject`
  9. * - `null`: `inject` can be called but there is no injector (limp-mode).
  10. * - Injector instance: Use the injector for resolution.
  11. */
  12. let _currentInjector = undefined;
  13. function getCurrentInjector() {
  14. return _currentInjector;
  15. }
  16. function setCurrentInjector(injector) {
  17. const former = _currentInjector;
  18. _currentInjector = injector;
  19. return former;
  20. }
  21. /**
  22. * Value returned if the key-value pair couldn't be found in the context
  23. * hierarchy.
  24. */
  25. const NOT_FOUND = Symbol('NotFound');
  26. /**
  27. * Error thrown when the key-value pair couldn't be found in the context
  28. * hierarchy. Context can be attached below.
  29. */
  30. class NotFoundError extends Error {
  31. constructor(message) {
  32. super(message);
  33. }
  34. }
  35. /**
  36. * Type guard for checking if an unknown value is a NotFound.
  37. */
  38. function isNotFound(e) {
  39. return e === NOT_FOUND || e instanceof NotFoundError;
  40. }
  41. export { NOT_FOUND, NotFoundError, getCurrentInjector, isNotFound, setCurrentInjector };
  42. //# sourceMappingURL=di.mjs.map