mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 00:25:46 -06:00
* Templating: __data __field and __series macros * filter out datacontext from json serialization * Fix condition * Update * Added test cases for formatting data, and field macros
17 lines
373 B
TypeScript
17 lines
373 B
TypeScript
import { property } from 'lodash';
|
|
|
|
interface FieldAccessorCache {
|
|
[key: string]: (obj: object) => any;
|
|
}
|
|
|
|
let fieldAccessorCache: FieldAccessorCache = {};
|
|
|
|
export function getFieldAccessor(fieldPath: string) {
|
|
const accessor = fieldAccessorCache[fieldPath];
|
|
if (accessor) {
|
|
return accessor;
|
|
}
|
|
|
|
return (fieldAccessorCache[fieldPath] = property(fieldPath));
|
|
}
|