Skip to content

Commit

Permalink
optimized the is node
Browse files Browse the repository at this point in the history
Co-authored-by: Brandon Kobel <brandon.kobel@gmail.com>
  • Loading branch information
gmmorris and kobelb authored Sep 10, 2020
1 parent eb1ae15 commit cb1fc7a
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import { KueryNode } from '../../../../../src/plugins/data/server';
import { RegistryAlertTypeWithAuth } from './alerts_authorization';

export const is = (fieldName: string, value: string | KueryNode) =>
nodeTypes.function.buildNode('is', fieldName, value);
nodeTypes.function.buildNodeWithArgumentNodes('is', [
nodeTypes.literal.buildNode(fieldName),
typeof value === 'string' ? nodeTypes.literal.buildNode(value) : value,
nodeTypes.literal.buildNode(false),
]);

export const or = ([first, ...args]: KueryNode[]): KueryNode =>
args.length ? nodeTypes.function.buildNode('or', [first, or(args)]) : first;
Expand Down

0 comments on commit cb1fc7a

Please sign in to comment.