本文整理汇总了TypeScript中lodash.get函数的典型用法代码示例。如果您正苦于以下问题:TypeScript get函数的具体用法?TypeScript get怎么用?TypeScript get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
.map(data => _.get(data, 'earnings'))
示例2: get
export const getView = (state: AppState, id: string): View => {
return get(state, `views.views.${id}.view`)
}
示例3: addFunctionParameter
addFunctionParameter(func, value) {
if (func.params.length >= func.def.params.length && !_.get(_.last(func.def.params), 'multiple', false)) {
throw { message: 'too many parameters for function ' + func.def.name };
}
func.params.push(value);
}
示例4: return
return (doc: SavedObjectDoc) =>
_.set(doc, path, _.isFunction(value) ? value(_.get(doc, path)) : value) as SavedObjectDoc;
示例5: get
objPaths.forEach(path => {
const id = get(this, path);
if (id) {
ids.push(id._id || id);
}
});
示例6:
circular.forEach(c => {
const ref = _.get(json, c.circuralTargetPath)
_.set(json, c.pathToObj, ref)
})
示例7:
const addFilter = (state: LogsState, action: AddFilterAction): LogsState => {
const {filter} = action.payload
return {...state, filters: [filter, ..._.get(state, 'filters', [])]}
}
示例8: getMonitorChartsData
/**
* Fetches data used to populate monitor charts
* @param request Kibana request
* @param monitorId ID value for the selected monitor
* @param dateRangeStart timestamp bounds
* @param dateRangeEnd timestamp bounds
*/
public async getMonitorChartsData(
request: any,
monitorId: string,
dateRangeStart: string,
dateRangeEnd: string
): Promise<MonitorChart> {
const params = {
index: INDEX_NAMES.HEARTBEAT,
body: {
query: {
bool: {
filter: [
{ range: { '@timestamp': { gte: dateRangeStart, lte: dateRangeEnd } } },
{ term: { 'monitor.id': monitorId } },
],
},
},
size: 0,
aggs: {
timeseries: {
auto_date_histogram: {
field: '@timestamp',
buckets: 25,
},
aggs: {
status: { terms: { field: 'monitor.status', size: 2, shard_size: 2 } },
duration: { stats: { field: 'monitor.duration.us' } },
},
},
},
},
};
const result = await this.database.search(request, params);
const buckets = dropLatestBucket(get(result, 'aggregations.timeseries.buckets', []));
/**
* The code below is responsible for formatting the aggregation data we fetched above in a way
* that the chart components used by the client understands.
* There are five required values. Two are lists of points that conform to a simple (x,y) structure.
*
* The third list is for an area chart expressing a range, and it requires an (x,y,y0) structure,
* where y0 is the min value for the point and y is the max.
*
* Additionally, we supply the maximum value for duration and status, so the corresponding charts know
* what the domain size should be.
*/
const monitorChartsData: MonitorChart = {
durationArea: [],
durationLine: [],
status: [],
durationMaxValue: 0,
statusMaxCount: 0,
};
buckets.forEach(bucket => {
const x = get(bucket, 'key');
const docCount = get(bucket, 'doc_count', 0);
// update the maximum value for each point
monitorChartsData.statusMaxCount = Math.max(docCount, monitorChartsData.statusMaxCount);
monitorChartsData.durationMaxValue = Math.max(
monitorChartsData.durationMaxValue,
get(bucket, 'duration.max', 0)
);
// these points express a range that will be displayed as an area chart
monitorChartsData.durationArea.push({
x,
yMin: get(bucket, 'duration.min', null),
yMax: get(bucket, 'duration.max', null),
});
monitorChartsData.durationLine.push({ x, y: get(bucket, 'duration.avg', null) });
monitorChartsData.status.push(
formatStatusBuckets(x, get(bucket, 'status.buckets', []), docCount)
);
});
return monitorChartsData;
}
示例9: parse
$("[style]").each((idx, elem) => {
const root = parse(_.get(elem.attribs, "style"));
const styles = pickDeclToStyleObject(root.nodes as Declaration[]);
appendStyleProps(elem, styles);
});
示例10: getFilterBar
/**
* Fetch options for the filter bar.
* @param request Kibana request object
* @param dateRangeStart timestamp bounds
* @param dateRangeEnd timestamp bounds
*/
public async getFilterBar(
request: any,
dateRangeStart: string,
dateRangeEnd: string
): Promise<FilterBar> {
const params = {
index: INDEX_NAMES.HEARTBEAT,
body: {
_source: ['monitor.id', 'monitor.type', 'url.full', 'url.port', 'monitor.name'],
size: 1000,
query: {
range: {
'@timestamp': {
gte: dateRangeStart,
lte: dateRangeEnd,
},
},
},
collapse: {
field: 'monitor.id',
},
sort: {
'@timestamp': 'desc',
},
},
};
const result = await this.database.search(request, params);
const ids: MonitorKey[] = [];
const ports = new Set<number>();
const types = new Set<string>();
const names = new Set<string>();
const hits = get(result, 'hits.hits', []);
hits.forEach((hit: any) => {
const key: string = get(hit, '_source.monitor.id');
const url: string | null = get(hit, '_source.url.full', null);
const port: number | undefined = get(hit, '_source.url.port', undefined);
const type: string | undefined = get(hit, '_source.monitor.type', undefined);
const name: string | null = get(hit, '_source.monitor.name', null);
if (key) {
ids.push({ key, url });
}
if (port) {
ports.add(port);
}
if (type) {
types.add(type);
}
if (name) {
names.add(name);
}
});
return {
ids,
ports: Array.from(ports),
schemes: Array.from(types),
names: Array.from(names),
statuses: ['up', 'down'],
};
}