* Returns the resolver. * @param {string} type type of resolver * @param {ResolveOptionsWithDependencyType=} resolveOptions options * @returns {ResolverWithOptions} the resolver
(type, resolveOptions = EMPTY_RESOLVE_OPTIONS)
| 100 | * @returns {ResolverWithOptions} the resolver |
| 101 | */ |
| 102 | get(type, resolveOptions = EMPTY_RESOLVE_OPTIONS) { |
| 103 | let typedCaches = this.cache.get(type); |
| 104 | if (!typedCaches) { |
| 105 | typedCaches = { |
| 106 | direct: new WeakMap(), |
| 107 | stringified: new Map() |
| 108 | }; |
| 109 | this.cache.set(type, typedCaches); |
| 110 | } |
| 111 | const cachedResolver = typedCaches.direct.get(resolveOptions); |
| 112 | if (cachedResolver) { |
| 113 | return cachedResolver; |
| 114 | } |
| 115 | const ident = JSON.stringify(resolveOptions); |
| 116 | const resolver = typedCaches.stringified.get(ident); |
| 117 | if (resolver) { |
| 118 | typedCaches.direct.set(resolveOptions, resolver); |
| 119 | return resolver; |
| 120 | } |
| 121 | const newResolver = this._create(type, resolveOptions); |
| 122 | typedCaches.direct.set(resolveOptions, newResolver); |
| 123 | typedCaches.stringified.set(ident, newResolver); |
| 124 | return newResolver; |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Returns the resolver. |