本文整理汇总了TypeScript中@kbn/interpreter/common.fromExpression函数的典型用法代码示例。如果您正苦于以下问题:TypeScript fromExpression函数的具体用法?TypeScript fromExpression怎么用?TypeScript fromExpression使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fromExpression函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: syncFilterExpression
export function syncFilterExpression(
config: Record<string, any>,
filterExpression: string,
fields: string[] = []
) {
let changed = false;
const filterAst = fromExpression(filterExpression);
const newAst = fields.reduce((ast, field) => {
const val = get(ast, `chain[0].arguments.${field}[0]`);
if (val !== config[field]) {
changed = true;
if (!config[field]) {
// remove value if not in expression
return del(ast, `chain.0.arguments.${field}`);
}
return set(ast, `chain.0.arguments.${field}.0`, config[field]);
}
return ast;
}, filterAst);
return { changed, newAst };
}
开发者ID:elastic,项目名称:kibana,代码行数:25,代码来源:sync_filter_expression.ts
示例2: async
): ExpressionRunner => async (expressionOrAst, { element, context, getInitialContext }) => {
// TODO: make interpreter initialization synchronous to avoid this
const interpreter = await interpreterPromise;
const ast =
typeof expressionOrAst === 'string' ? fromExpression(expressionOrAst) : expressionOrAst;
const response = await interpreter.interpretAst(ast, context || { type: 'null' }, {
getInitialContext: getInitialContext || (() => ({})),
inspectorAdapters: {
// TODO connect real adapters
requests: new RequestAdapter(),
data: new DataAdapter(),
},
});
if (element) {
if (response.type === 'render' && response.as) {
renderersRegistry.get(response.as).render(element, response.value, {
onDestroy: fn => {
// TODO implement
},
done: () => {
// TODO implement
},
});
} else {
// eslint-disable-next-line no-console
console.log('Unexpected result of expression', response);
}
}
return response;
};
开发者ID:elastic,项目名称:kibana,代码行数:33,代码来源:expression_runner.ts
示例3: async
export const runPipeline = async (
expression: string,
context: object,
handlers: RunPipelineHandlers
) => {
const ast = fromExpression(expression);
const { interpreter } = await getInterpreter();
const pipelineResponse = await interpreter.interpretAst(ast, context, handlers);
return pipelineResponse;
};
开发者ID:njd5475,项目名称:kibana,代码行数:10,代码来源:run_pipeline.ts
示例4: async
export const runPipeline = async (expression: string, context: any, handlers: any) => {
const ast = fromExpression(expression);
const pipelineResponse = await interpretAst(ast, context, handlers);
return pipelineResponse;
};
开发者ID:gingerwizard,项目名称:kibana,代码行数:5,代码来源:run_pipeline.ts
注:本文中的@kbn/interpreter/common.fromExpression函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论