【问题标题】:How create reusable function with known arguments? [closed]如何创建具有已知参数的可重用函数? [关闭]
【发布时间】:2022-06-15 17:00:50
【问题描述】:

下面的 TypeScript 函数的目的是获取一些参数并将一些错误或信息记录到 Elasticsearch。

假设我有 2 个 Elasticsearch 索引,“indexA”和“indexB”。我在 Elasticsearch 日志中有 3 种不同的类型。当此函数调用时,我只想获取那些索引和类型。我想告诉调用者他们可以将哪些参数传递给这个函数。

我们如何解决这个任务?或者也许有一些更好的方法来处理这类任务。

const elasticLog = (thisIndex: index, thisType: type, thisBody: Object) => {
    elasticClient.index({
        index: thisIndex,
        type: thisType,
        body: {},
    });
};

export default elasticLog;

【问题讨论】:

标签: javascript node.js typescript elasticsearch


猜你喜欢
  • 1970-01-01
  • 2012-10-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-05
  • 2012-02-20
  • 1970-01-01
相关资源
最近更新 更多