本文整理汇总了TypeScript中lodash/fp.merge函数的典型用法代码示例。如果您正苦于以下问题:TypeScript merge函数的具体用法?TypeScript merge怎么用?TypeScript merge使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了merge函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: get
export const mergeFieldsWithHit = <T>(
fieldName: string,
flattenedFields: T,
fieldMap: Readonly<Record<string, string>>,
hit: { _source: {} }
) => {
if (fieldMap[fieldName] != null) {
const esField = fieldMap[fieldName];
if (has(esField, hit._source)) {
const objectWithProperty = {
node: {
...get('node', flattenedFields),
...fieldName
.split('.')
.reduceRight((obj, next) => ({ [next]: obj }), get(esField, hit._source)),
},
};
return merge(flattenedFields, objectWithProperty);
} else {
return flattenedFields;
}
} else {
return flattenedFields;
}
};
开发者ID:,项目名称:,代码行数:25,代码来源:
示例2: getTimelineDetails
public async getTimelineDetails(
request: FrameworkRequest,
options: RequestDetailsOptions
): Promise<TimelineDetailsData> {
const [mapResponse, searchResponse] = await Promise.all([
this.framework.callWithRequest(request, 'indices.getMapping', {
allowNoIndices: true,
ignoreUnavailable: true,
index: options.indexName,
}),
this.framework.callWithRequest<EventHit, TermAggregation>(
request,
'search',
buildDetailsQuery(options.indexName, options.eventId)
),
]);
const sourceData = getOr({}, 'hits.hits.0._source', searchResponse);
const hitsData = getOr({}, 'hits.hits.0', searchResponse);
delete hitsData._source;
return {
data: getSchemaFromData(
{
...addBasicElasticSearchProperties(),
...getOr({}, [options.indexName, 'mappings', 'properties'], mapResponse),
},
getDataFromHits(merge(sourceData, hitsData)),
getIndexAlias(options.defaultIndex, options.indexName)
),
};
}
开发者ID:,项目名称:,代码行数:32,代码来源:
示例3:
const omitTypenameInTimeline = (
oldTimeline: TimelineModel,
newTimeline: TimelineResult
): TimelineModel => JSON.parse(JSON.stringify(mergeObject(oldTimeline, newTimeline)), omitTypename);
开发者ID:,项目名称:,代码行数:4,代码来源:
注:本文中的lodash/fp.merge函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论