Skip to content

Commit

Permalink
Update findField function (#52)
Browse files Browse the repository at this point in the history
* update findField fn

* version updated

* Update changelog

---------

Co-authored-by: asimonok <[email protected]>
  • Loading branch information
vitPinchuk and asimonok authored Jul 12, 2024
1 parent 1eae071 commit b10ce35
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions packages/grafana-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 1.4.4 (2024-07-12)

### Features / Enhancements

- Update findField function (#52)

## 1.4.3 (2024-06-20)

### Features / Enhancements
Expand Down
2 changes: 1 addition & 1 deletion packages/grafana-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@
"typecheck": "tsc --emitDeclarationOnly false --noEmit"
},
"types": "dist/client.d.ts",
"version": "1.4.3"
"version": "1.4.4"
}
4 changes: 2 additions & 2 deletions packages/grafana-utils/src/utils/frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { DataFrame, Field, FieldType } from '@grafana/data';
*/
export const findField = <TValue = unknown>(
series: DataFrame[],
predicateFn: (field: Field) => boolean
predicateFn: (field: Field, frame: DataFrame) => boolean
): Field<TValue> | undefined => {
for (let i = 0; i < series.length; i += 1) {
const frame = series[i];

const field = frame.fields.find((field) => predicateFn(field));
const field = frame.fields.find((field) => predicateFn(field, frame));

/**
* Field found
Expand Down

0 comments on commit b10ce35

Please sign in to comment.