MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / find

Method find

packages/context/src/context.ts:589–606  ·  view source on GitHub ↗

* 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,
  )

Source from the content-addressed store, hash-verified

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

Callers 2

findByTagMethod · 0.95
mainFunction · 0.95

Calls 7

_findByTagIndexMethod · 0.95
_mergeWithParentMethod · 0.95
isBindingTagFilterFunction · 0.90
filterByKeyFunction · 0.90
findMethod · 0.65
filterFunction · 0.50
valuesMethod · 0.45

Tested by

no test coverage detected