Chore: Reuse findFieldIndex from findField (#65973)

This commit is contained in:
Ryan McKinley 2023-04-04 16:54:38 -07:00 committed by GitHub
parent fb520edd72
commit 313b3dd2af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -91,20 +91,8 @@ export function getTextDimensionFromData(
}
export function findField(frame?: DataFrame, name?: string): Field | undefined {
if (!frame || !name?.length) {
return undefined;
}
for (const field of frame.fields) {
if (name === field.name) {
return field;
}
const disp = getFieldDisplayName(field, frame);
if (name === disp) {
return field;
}
}
return undefined;
const idx = findFieldIndex(frame, name);
return idx == null ? undefined : frame!.fields[idx];
}
export function findFieldIndex(frame?: DataFrame, name?: string): number | undefined {