* Find bindings using a key pattern or filter function * @param pattern - A filter function, a regexp or a wildcard pattern with * optional `*` and `?`. Find returns such bindings where the key matches * the provided pattern. * * For a wildcard: * - `*` matches zero or more charact
(
pattern?: string | RegExp | BindingFilter,
)
| 587 | * - return `false` to exclude it. |
| 588 | */ |
| 589 | find<ValueType = BoundValue>( |
| 590 | pattern?: string | RegExp | BindingFilter, |
| 591 | ): Readonly<Binding<ValueType>>[] { |
| 592 | // Optimize if the binding filter is for tags |
| 593 | if (typeof pattern === 'function' && isBindingTagFilter(pattern)) { |
| 594 | return this._findByTagIndex(pattern.bindingTagPattern); |
| 595 | } |
| 596 | |
| 597 | const bindings: Readonly<Binding<ValueType>>[] = []; |
| 598 | const filter = filterByKey(pattern); |
| 599 | |
| 600 | for (const b of this.registry.values()) { |
| 601 | if (filter(b)) bindings.push(b); |
| 602 | } |
| 603 | |
| 604 | const parentBindings = this._parent?.find(filter); |
| 605 | return this._mergeWithParent(bindings, parentBindings); |
| 606 | } |
| 607 | |
| 608 | /** |
| 609 | * Find bindings using the tag filter. If the filter matches one of the |
no test coverage detected