MCPcopy
hub / github.com/apache/echarts / queryByIdOrName

Function queryByIdOrName

src/model/Global.ts:1047–1068  ·  view source on GitHub ↗
(
    attr: 'id' | 'name',
    idOrName: string | number | (string | number)[],
    cmpts: T[]
)

Source from the content-addressed store, hash-verified

1045}
1046
1047function queryByIdOrName<T extends { id?: string, name?: string }>(
1048 attr: 'id' | 'name',
1049 idOrName: string | number | (string | number)[],
1050 cmpts: T[]
1051): T[] {
1052 // Here is a break from echarts4: string and number are
1053 // treated as equal.
1054 if (isArray(idOrName)) {
1055 const keyMap = createHashMap<boolean>();
1056 each(idOrName, function (idOrNameItem) {
1057 if (idOrNameItem != null) {
1058 const idName = modelUtil.convertOptionIdName(idOrNameItem, null);
1059 idName != null && keyMap.set(idOrNameItem, true);
1060 }
1061 });
1062 return filter(cmpts, cmpt => cmpt && keyMap.get(cmpt[attr]));
1063 }
1064 else {
1065 const idName = modelUtil.convertOptionIdName(idOrName, null);
1066 return filter(cmpts, cmpt => cmpt && idName != null && cmpt[attr] === idName);
1067 }
1068}
1069
1070function filterBySubType(
1071 components: ComponentModel[],

Callers 1

queryComponentsMethod · 0.85

Calls 3

isArrayFunction · 0.85
eachFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…