本文整理汇总了TypeScript中lodash.map函数的典型用法代码示例。如果您正苦于以下问题:TypeScript map函数的具体用法?TypeScript map怎么用?TypeScript map使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了map函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: map
const format_various_diff = (diff, attrs) => (
`<table border="1">
<tr><th>Champ modifiĂŠ</th><th>Ancienne valeur</th><th>Nouvelle valeur</th></tr>
` +
map(diff, ({ prev, current }, key) => {
const opts = { ...client_conf.default_attrs_opts[key], ...attrs[key] };
return ' <tr>' + [opts && opts.title || key, prev || '<i>aucune</i>', current || '<i>supprimĂŠe</i>'].map(s => `<td>${s}</td>`).join('') + '</tr>'
}).join("\n") + `
</table>`
);
开发者ID:prigaux,项目名称:compte-externe,代码行数:10,代码来源:v_display.ts
示例2: function
return _.flatten(_.map(a, function(x) {
return _.map(b, function(y) {
return _.concat(x,[y]);
});
}), true);
开发者ID:mlukasch,项目名称:indigo,代码行数:5,代码来源:permutations.ts
示例3:
_.map(old.rows, row => {
return _.map(row.panels, 'id');
})
开发者ID:grafana,项目名称:grafana,代码行数:3,代码来源:DashboardMigrator.ts
示例4:
const responseTransform = result => {
return _.map(result, value => {
return { text: value };
});
};
开发者ID:grafana,项目名称:grafana,代码行数:5,代码来源:datasource.ts
示例5:
.map(indices=>_.map(indices,i=>obj[i]))
开发者ID:mlukasch,项目名称:indigo,代码行数:1,代码来源:permutations.ts
示例6: addHistogram
addHistogram(data) {
const xBucket = this.scope.ctrl.data.buckets[data.x];
const yBucketSize = this.scope.ctrl.data.yBucketSize;
let min, max, ticks;
if (this.scope.ctrl.data.tsBuckets) {
min = 0;
max = this.scope.ctrl.data.tsBuckets.length - 1;
ticks = this.scope.ctrl.data.tsBuckets.length;
} else {
min = this.scope.ctrl.data.yAxis.min;
max = this.scope.ctrl.data.yAxis.max;
ticks = this.scope.ctrl.data.yAxis.ticks;
}
let histogramData = _.map(xBucket.buckets, bucket => {
const count = bucket.count !== undefined ? bucket.count : bucket.values.length;
return [bucket.bounds.bottom, count];
});
histogramData = _.filter(histogramData, d => {
return d[0] >= min && d[0] <= max;
});
const scale = this.scope.yScale.copy();
const histXScale = scale.domain([min, max]).range([0, HISTOGRAM_WIDTH]);
let barWidth;
if (this.panel.yAxis.logBase === 1) {
barWidth = Math.floor(HISTOGRAM_WIDTH / (max - min) * yBucketSize * 0.9);
} else {
const barNumberFactor = yBucketSize ? yBucketSize : 1;
barWidth = Math.floor(HISTOGRAM_WIDTH / ticks / barNumberFactor * 0.9);
}
barWidth = Math.max(barWidth, 1);
// Normalize histogram Y axis
const histogramDomain = _.reduce(_.map(histogramData, d => d[1]), (sum, val) => sum + val, 0);
const histYScale = d3
.scaleLinear()
.domain([0, histogramDomain])
.range([0, HISTOGRAM_HEIGHT]);
const histogram = this.tooltip
.select('.heatmap-histogram')
.append('svg')
.attr('width', HISTOGRAM_WIDTH)
.attr('height', HISTOGRAM_HEIGHT);
histogram
.selectAll('.bar')
.data(histogramData)
.enter()
.append('rect')
.attr('x', d => {
return histXScale(d[0]);
})
.attr('width', barWidth)
.attr('y', d => {
return HISTOGRAM_HEIGHT - histYScale(d[1]);
})
.attr('height', d => {
return histYScale(d[1]);
});
}
开发者ID:CorpGlory,项目名称:grafana,代码行数:62,代码来源:heatmap_tooltip.ts
示例7: function
controller: function($scope, $uibModalInstance, Oppiaineet, OsanMuokkausHelper) {
$scope.kohdealueet = _.map(
_.clone(OsanMuokkausHelper.getOppiaine().kohdealueet) || [],
function(ka: any) {
ka.$vanhaNimi = _.clone(ka.nimi);
return ka;
}
);
$scope.poistaKohdealue = function(ka) {
Oppiaineet.poistaKohdealue(
{
perusteId: ProxyService.get("perusteId"),
osanId: OsanMuokkausHelper.getOppiaine().id,
kohdealueId: ka.id
},
function() {
_.remove($scope.kohdealueet, ka);
},
Notifikaatiot.serverCb
);
};
$scope.lisaaKohdealue = function() {
Oppiaineet.lisaaKohdealue(
{
perusteId: ProxyService.get("perusteId"),
osanId: OsanMuokkausHelper.getOppiaine().id
},
{ nimi: { fi: "Uusi tavoitealue" } },
function(res) {
$scope.kohdealueet.push(res);
}
);
};
$scope.ok = function(kohdealueet) {
$q
.all(
_(kohdealueet)
.reject(function(ka) {
return _.isEqual(ka.nimi, ka.$vanhaNimi);
})
.map(function(ka) {
return Oppiaineet.lisaaKohdealue(
{
perusteId: ProxyService.get("perusteId"),
osanId: OsanMuokkausHelper.getOppiaine().id
},
ka
).$promise;
})
.value()
)
.then(
Oppiaineet.kohdealueet(
{
perusteId: ProxyService.get("perusteId"),
osanId: OsanMuokkausHelper.getOppiaine().id
},
$uibModalInstance.close
)
);
};
}
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:62,代码来源:osanmuokkaus.ts
示例8: shouldAddField
return this.get('/_mapping').then(function(result) {
var typeMap = {
'float': 'number',
'double': 'number',
'integer': 'number',
'long': 'number',
'date': 'date',
'string': 'string',
'text': 'string',
'scaled_float': 'number',
'nested': 'nested'
};
function shouldAddField(obj, key, query) {
if (key[0] === '_') {
return false;
}
if (!query.type) {
return true;
}
// equal query type filter, or via typemap translation
return query.type === obj.type || query.type === typeMap[obj.type];
}
// Store subfield names: [system, process, cpu, total] -> system.process.cpu.total
var fieldNameParts = [];
var fields = {};
function getFieldsRecursively(obj) {
for (var key in obj) {
var subObj = obj[key];
// Check mapping field for nested fields
if (_.isObject(subObj.properties)) {
fieldNameParts.push(key);
getFieldsRecursively(subObj.properties);
}
if (_.isObject(subObj.fields)) {
fieldNameParts.push(key);
getFieldsRecursively(subObj.fields);
}
if (_.isString(subObj.type)) {
var fieldName = fieldNameParts.concat(key).join('.');
// Hide meta-fields and check field type
if (shouldAddField(subObj, key, query)) {
fields[fieldName] = {
text: fieldName,
type: subObj.type
};
}
}
}
fieldNameParts.pop();
}
for (var indexName in result) {
var index = result[indexName];
if (index && index.mappings) {
var mappings = index.mappings;
for (var typeName in mappings) {
var properties = mappings[typeName].properties;
getFieldsRecursively(properties);
}
}
}
// transform to array
return _.map(fields, function(value) {
return value;
});
});
开发者ID:PaulMest,项目名称:grafana,代码行数:77,代码来源:datasource.ts
示例9: function
var ticks = _.map(data, function(series, seriesIndex) {
return _.map(series.datapoints, function(point, pointIndex) {
var tickIndex = seriesIndex * series.datapoints.length + pointIndex;
return [tickIndex + 1, point[1]];
});
});
开发者ID:,项目名称:,代码行数:6,代码来源:
示例10: getMinLog
// Get minimum non zero value.
function getMinLog(series) {
let values = _.compact(_.map(series.datapoints, p => p[0]));
return _.min(values);
}
开发者ID:PaulMest,项目名称:grafana,代码行数:5,代码来源:heatmap_data_converter.ts
注:本文中的lodash.map函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论