本文整理匯總了TypeScript中underscore.compact函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript compact函數的具體用法?TypeScript compact怎麽用?TypeScript compact使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了compact函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: mergeVendors
.then((vendors) => {
const nonNullVendors = _.compact(vendors);
if (nonNullVendors.length) {
const mergedVendor = mergeVendors(_.compact(vendors));
service.vendors[mergedVendor.hash] = mergedVendor;
} else {
delete service.vendors[vendorDef.hash];
}
});
示例2: buildHiddenStats
function buildHiddenStats(itemDef: DestinyInventoryItemDefinition, statDefs: LazyDefinition<DestinyStatDefinition>): DimStat[] {
const itemStats = itemDef.stats.stats;
if (!itemStats) {
return [];
}
return _.compact(_.map(itemStats, (stat: DestinyInventoryItemStatDefinition): DimStat | undefined => {
const def = statDefs.get(stat.statHash);
// only aim assist and zoom for now
if (![1345609583, 3555269338, 2715839340].includes(stat.statHash) || !stat.value) {
return undefined;
}
return {
base: stat.value,
bonus: 0,
statHash: stat.statHash,
name: def.displayProperties.name,
id: stat.statHash,
sort: statWhiteList.indexOf(stat.statHash),
value: stat.value,
maximumValue: 100,
bar: true
};
}));
}
示例3: buildDefaultStats
function buildDefaultStats(itemDef: DestinyInventoryItemDefinition, statDefs: LazyDefinition<DestinyStatDefinition>): DimStat[] {
const itemStats = itemDef.stats.stats;
if (!itemStats) {
return [];
}
return _.compact(_.map(itemStats, (stat: DestinyInventoryItemStatDefinition): DimStat | undefined => {
const def = statDefs.get(stat.statHash);
if (!statWhiteList.includes(stat.statHash) || !stat.value) {
return undefined;
}
return {
base: stat.value,
bonus: 0,
statHash: stat.statHash,
name: def.displayProperties.name,
id: stat.statHash,
sort: statWhiteList.indexOf(stat.statHash),
value: stat.value,
maximumValue: 100,
bar: stat.statHash !== 4284893193 &&
stat.statHash !== 3871231066 &&
stat.statHash !== 2961396640
};
})) as DimStat[];
}
示例4: buildStats
function buildStats(
item: DestinyItemComponent,
stats: { [key: string]: DestinyItemStatsComponent },
statDefs: LazyDefinition<DestinyStatDefinition>
): DimStat[] {
if (!item.itemInstanceId || !stats[item.itemInstanceId]) {
return [];
}
const itemStats = stats[item.itemInstanceId].stats;
return _.compact(_.map(itemStats, (stat: DestinyStat): DimStat | undefined => {
const def = statDefs.get(stat.statHash);
const itemStat = itemStats[stat.statHash];
if (!def || !itemStat) {
return undefined;
}
const val = itemStat ? itemStat.value : stat.value;
return {
base: val,
bonus: 0,
statHash: stat.statHash,
name: def.displayProperties.name,
id: stat.statHash,
sort: statWhiteList.indexOf(stat.statHash),
value: val,
maximumValue: itemStat.maximumValue,
bar: stat.statHash !== 4284893193 &&
stat.statHash !== 3871231066 &&
stat.statHash !== 2961396640
};
}));
}
示例5: buildInvestmentStats
function buildInvestmentStats(
itemStats: DestinyItemInvestmentStatDefinition[],
statDefs: LazyDefinition<DestinyStatDefinition>
): DimStat[] {
return _.compact(_.map(itemStats, (itemStat): DimStat | undefined => {
const def = statDefs.get(itemStat.statTypeHash);
/* 1935470627 = Power */
if (!def || !itemStat || itemStat.statTypeHash === 1935470627) {
return undefined;
}
return {
base: itemStat.value,
bonus: 0,
statHash: itemStat.statTypeHash,
name: def.displayProperties.name,
id: itemStat.statTypeHash,
sort: statWhiteList.indexOf(itemStat.statTypeHash),
value: itemStat.value,
maximumValue: 0,
bar: def.hash !== 4284893193 &&
def.hash !== 3871231066 &&
def.hash !== 2961396640
};
}));
}
示例6: copy
const farm = () => {
const consolidateHashes = [
417308266, // three of coins
211861343, // heavy ammo synth
928169143, // special ammo synth
2180254632 // primary ammo synth
];
this.consolidate = _.compact(
consolidateHashes.map((hash) => {
const ret = copy(
D1StoresService.getItemAcrossStores({
hash
})
);
if (ret) {
ret.amount = sum(D1StoresService.getStores(), (s) => s.amountOfItem(ret));
}
return ret;
})
);
this.farmItems().then(() => {
if (settings.farming.makeRoomForItems) {
this.makeRoomForItems();
}
});
};
示例7: getNotificationObjectByGerritEvent
function getNotificationObjectByGerritEvent(event: GerritEvent): NotificationObject {
let gerritEventFormatter: GerritEventFormatter = getGerritEventFormatter(event);
if (!gerritEventFormatter) {
return null;
}
let text = di.inject(gerritEventFormatter.text, event)();
let url = di.inject(gerritEventFormatter.getUrl, event)();
let authorIcon = di.inject(gerritEventFormatter.getAuthorIcon, event)();
let rows = _.compact(text.split('\n').map((row) => row.trim()));
let title = rows[0];
let subtitle = rows[1];
let message = rows.splice(2).join('\n');
return {
title,
subtitle,
message,
url,
authorIconPath: authorIcon ? path.join(__dirname, '../../../images/', authorIcon) : null
} as NotificationObject;
}
示例8:
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;
}
});
示例9:
_.each(D1Categories, (types, category) => {
buckets.byCategory[category] = _.compact(
types.map((type) => {
return buckets.byType[type];
})
);
});
示例10: getBreadcrumbTooltip
public getBreadcrumbTooltip(): string {
const tooltipParts = [
this.facet.getValueCaption(this.facetValue),
this.facetValue.getFormattedCount(),
this.facetValue.getFormattedComputedField(this.facet.options.computedFieldFormat)
];
return _.compact(tooltipParts).join(' ');
}