kibana/x-pack/plugins/lens/public/indexpattern_datasource/pure_helpers.ts
Marco Liberati 0b99841310
[Lens] Performance refactoring for indexpattern fast lookup and Operation support matrix computation (#82829)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2020-11-10 14:31:04 +01:00

22 lines
756 B
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { keyBy } from 'lodash';
import { IndexPatternField, IndexPatternPrivateState } from './types';
export function fieldExists(
existingFields: IndexPatternPrivateState['existingFields'],
indexPatternTitle: string,
fieldName: string
) {
return existingFields[indexPatternTitle] && existingFields[indexPatternTitle][fieldName];
}
export function getFieldByNameFactory(newFields: IndexPatternField[]) {
const fieldsLookup = keyBy(newFields, 'name');
return (name: string) => fieldsLookup[name];
}