當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript common.fromExpression函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。