本文整理汇总了TypeScript中underscore.map函数的典型用法代码示例。如果您正苦于以下问题:TypeScript map函数的具体用法?TypeScript map怎么用?TypeScript map使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了map函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: testUndeclaredImports
function testUndeclaredImports() {
console.log(foo1); // failure on 'foo1'
console.log(foo2); // failure on 'foo2'
console.log(foo3); // failure on 'foo3'
map([], (x) => x); // failure on 'map'
}
示例2: processItems
return processItems({ id: null } as any, saleItems.map((i) => i.item)).then((items) => {
const itemsById = _.indexBy(items, 'id');
const categories = _.compact(
_.map(vendor.saleItemCategories, (category: any) => {
const categoryInfo = vendorDef.categories[category.categoryIndex];
if (_.contains(categoryBlacklist, categoryInfo.categoryHash)) {
return null;
}
const categoryItems = category.saleItems.map((saleItem) => {
const unlocked = isSaleItemUnlocked(saleItem);
return {
index: saleItem.vendorItemIndex,
costs: saleItem.costs
.map((cost) => {
return {
value: cost.value,
currency: _.pick(
defs.InventoryItem.get(cost.itemHash),
'itemName',
'icon',
'itemHash'
)
};
})
.filter((c) => c.value > 0),
item: itemsById[`vendor-${vendorDef.hash}-${saleItem.vendorItemIndex}`],
// TODO: caveat, this won't update very often!
unlocked,
unlockedByCharacter: unlocked ? [store.id] : [],
failureStrings: saleItem.failureIndexes
.map((i) => vendorDef.failureStrings[i])
.join('. ')
};
});
let hasArmorWeaps = false;
let hasVehicles = false;
let hasShadersEmbs = false;
let hasEmotes = false;
let hasConsumables = false;
let hasBounties = false;
categoryItems.forEach((saleItem) => {
const item = saleItem.item;
if (
item.bucket.sort === 'Weapons' ||
item.bucket.sort === 'Armor' ||
item.type === 'Artifact' ||
item.type === 'Ghost'
) {
if (item.talentGrid) {
item.dtrRoll = _.compact(item.talentGrid.nodes.map((i) => i.dtrRoll)).join(';');
}
hasArmorWeaps = true;
}
if (item.type === 'Ship' || item.type === 'Vehicle') {
hasVehicles = true;
}
if (item.type === 'Emblem' || item.type === 'Shader') {
hasShadersEmbs = true;
}
if (item.type === 'Emote') {
hasEmotes = true;
}
if (item.type === 'Material' || item.type === 'Consumable') {
hasConsumables = true;
}
if (item.type === 'Bounties') {
hasBounties = true;
}
});
return {
index: category.categoryIndex,
title: categoryInfo.displayTitle,
saleItems: categoryItems,
hasArmorWeaps,
hasVehicles,
hasShadersEmbs,
hasEmotes,
hasConsumables,
hasBounties
};
})
);
items.forEach((item: any) => {
item.vendorIcon = createdVendor.icon;
});
createdVendor.categories = categories;
createdVendor.hasArmorWeaps = _.any(categories, (c) => c.hasArmorWeaps);
createdVendor.hasVehicles = _.any(categories, (c) => c.hasVehicles);
createdVendor.hasShadersEmbs = _.any(categories, (c) => c.hasShadersEmbs);
createdVendor.hasEmotes = _.any(categories, (c) => c.hasEmotes);
createdVendor.hasConsumables = _.any(categories, (c) => c.hasConsumables);
createdVendor.hasBounties = _.any(categories, (c) => c.hasBounties);
return createdVendor;
//.........这里部分代码省略.........
示例3: ShowChart
ShowChart(summaryData: any) {
var centreName = [];
var bookingData = [];
var expenditureData = [];
var receivableData = [];
var profitData = [];
_.map(summaryData["homeList"], (item) => {
//debugger
centreName.push(item.centreDesc);
bookingData.push(item.bookingAmount);
expenditureData.push(item.maintenance);
receivableData.push(item.receivable);
profitData.push(item.profit);
return item;
});
//var centreName = ['Tariq Rd', 'Nomayesh', 'Joher', 'Korangi', 'Landhi'];
//var bookingData = [18500, 11300, 13700, 22400, 6200];
//var expenditureData = [9000, 5700, 6500, 10200, 3000];
//var receivableData = [3350, 2500, 4000, 6500, 2000];
//var profitData = [9500, 5600, 7200, 12200, 3200];
//this.homeItemView.$el.find("#container").highcharts({
this.homeItemView.$el.find("#container")["highcharts"]({
chart: {
type: 'column',
backgroundColor: 'transparent',
options3d: {
enabled: true,
alpha: 15,
beta: 15,
viewDistance: 25,
depth: 40
},
marginTop: 80,
marginRight: 40
},
title: {
text: 'Booking Summary Report - Centre Wise',
style: {
color: 'grey'
}
},
xAxis: {
categories: centreName
},
legend: {
//layout: 'horizontal',
itemStyle: {
color: 'grey'
}
},
yAxis: {
allowDecimals: false,
min: 0,
title: {
text: 'Amount in Rs'
}
},
tooltip: {
headerFormat: '<b>{point.key}</b><br>',
pointFormat: '<span style="color:{series.color}">\u25CF</span> {series.name}: {point.y}'
},
plotOptions: {
column: {
stacking: 'normal',
depth: 40
}
},
series: [
{
name: 'Booking',
data: bookingData,
stack: 'Booking'
}, {
name: 'Maintenance',
data: expenditureData,
stack: 'Maintenance'
}, {
name: 'Receivable',
data: receivableData,
stack: 'Receivable'
}, {
name: 'Profit',
data: profitData,
stack: 'Profit'
}]
});
var item = this.homeItemView.$el.find("text")[this.homeItemView.$el.find("text").length - 1];
if (item != undefined) {
item.innerHTML = "";
}
//.........这里部分代码省略.........
示例4: map
import { actions } from "common/actions";
import reducer from "common/reducers/reducer";
import { DownloadsState } from "common/types";
import { indexBy, map } from "underscore";
const SPEED_DATA_POINT_COUNT = 60;
const initialState: DownloadsState = {
speeds: map(new Array(SPEED_DATA_POINT_COUNT), x => 0),
items: {},
progresses: {},
paused: true,
};
export default reducer<DownloadsState>(initialState, on => {
on(actions.downloadsListed, (state, action) => {
const { downloads } = action.payload;
return {
...state,
items: indexBy(downloads, "id"),
};
});
on(actions.downloadProgress, (state, action) => {
const { download, progress, speedHistory } = action.payload;
return {
...state,
progresses: {
...state.progresses,
[download.id]: progress,
},
示例5: getDefinitions
getDefinitions().then((defs) => {
const rawRecordBooks = stores[0].advisors.recordBooks;
vm.recordBooks = _.map(rawRecordBooks, (rb) => processRecordBook(defs, rb));
});
示例6: function
if((window as any).appPrefix === undefined){
if(!window.entcore){
window.entcore = {};
}
if(window.location.pathname.split('/').length > 0){
(window as any).appPrefix = window.location.pathname.split('/')[1];
window.entcore.appPrefix = (window as any).appPrefix;
}
}
var xsrfCookie;
if(document.cookie){
var cookies = _.map(document.cookie.split(';'), function(c){
return {
name: c.split('=')[0].trim(),
val: c.split('=')[1].trim()
};
});
xsrfCookie = _.findWhere(cookies, { name: 'XSRF-TOKEN' });
}
export var appPrefix: string = (window as any).appPrefix;
if((window as any).infraPrefix === undefined){
(window as any).infraPrefix = 'infra';
}
export let infraPrefix: string = (window as any).infraPrefix;
export let currentLanguage = '';
export const devices = {
示例7: getFields
getFields() {
var defaultTemplates = _.map(TemplateCache.getDefaultTemplates(), name => TemplateCache.getTemplate(name));
return _.flatten(_.map(defaultTemplates, (template: Template) => template.getFields()));
}
示例8: map
getQuickFilterText: (params: agGridModule.GetQuickFilterTextParams) => {
const allValues = map(params.value.result.raw, val => val.toString());
return Object.keys(params.value.result.raw)
.concat(allValues)
.join(' ');
},