本文整理汇总了TypeScript中underscore.uniq函数的典型用法代码示例。如果您正苦于以下问题:TypeScript uniq函数的具体用法?TypeScript uniq怎么用?TypeScript uniq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了uniq函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: buildModules
function buildModules(modules:any[]) {
var result:any[] = [];
_.each(modules, (value:any, key:string) => {
result.push({
name: key,
type: 'toggle',
classes: _.map(value.classes, (c:any) => {
return {
name: c.name,
url: '/' + key + '/classes/' + c.name,
type: 'link'
};
}),
interfaces: _.map(value.interfaces, (c:any) => {
return {
name: c.name,
url: '/' + key + '/interfaces/' + c.name,
type: 'link'
};
}),
enumerations: _.map(value.enumerations, (c:any) => {
return {
name: c.name,
url: '/' + key + '/enumerations/' + c.name,
type: 'link'
};
})
})
});
return _.uniq(result);
}
示例2: work
async work(): Promise<void> {
const installLocationId = this.space().firstPathElement();
let call = withLogger(this.logger);
const { caves, installLocationPath, installLocationSize } = await call(
messages.FetchCavesByInstallLocationID,
{ installLocationId }
);
let games: Game[] = [];
if (!isEmpty(caves)) {
for (const c of caves) {
games.push(c.game);
}
games = uniq(games, g => g.id);
}
this.pushUnfilteredGames(games, { disableFilters: true });
this.push({
location: {
path: installLocationPath,
size: installLocationSize,
},
});
}
示例3: normalizeQueryString
private static normalizeQueryString(toNormalize: IUrlNormalize) {
let queryNormalized: string[] = [];
if (toNormalize.queryAsString) {
const cleanedUp = this.toArray(toNormalize.queryAsString).map(query => {
query = this.removeProblematicChars(query);
query = this.encodeKeyValuePair(query);
return query;
});
queryNormalized = queryNormalized.concat(cleanedUp);
}
if (toNormalize.query) {
const paired: string[][] = pairs(toNormalize.query);
const mapped = paired.map(pair => {
const [key, value] = pair;
if (Utils.isNullOrUndefined(value) || Utils.isNullOrUndefined(key)) {
return '';
}
if (!this.isEncoded(value)) {
return [this.removeProblematicChars(key), Utils.safeEncodeURIComponent(value)].join('=');
} else {
return [this.removeProblematicChars(key), value].join('=');
}
});
queryNormalized = queryNormalized.concat(mapped);
}
return uniq(queryNormalized);
}
示例4: filterItems
_.each(dimVendorService.vendors, (vendor: any) => {
const vendItems = filterItems(
_.select(
vendor.allItems.map((i) => i.item),
(item) =>
item.bucket.sort === 'Armor' || item.type === 'Artifact' || item.type === 'Ghost'
)
);
vendorItems = vendorItems.concat(vendItems);
// Exclude felwinters if we have them
const felwinters = vendorItems.filter((i) => i.hash === 2672107540);
if (felwinters.length) {
vm.excludeditems.push(...felwinters);
vm.excludeditems = _.uniq(vm.excludeditems, 'id');
}
// Build a map of perks
_.each(vendItems, (item) => {
if (item.classType === 3) {
_.each(['warlock', 'titan', 'hunter'], (classType) => {
vendorPerks[classType][item.type] = filterPerks(
vendorPerks[classType][item.type],
item
);
});
} else {
vendorPerks[item.classTypeName][item.type] = filterPerks(
vendorPerks[item.classTypeName][item.type],
item
);
}
});
});
示例5: getMaxTransactionDepth
function getMaxTransactionDepth(sindex:SindexShortEntry[]) {
const ids = _.uniq(_.pluck(sindex, 'tx'))
let maxTxChainingDepth = 0
for (let id of ids) {
maxTxChainingDepth = Math.max(maxTxChainingDepth, getTransactionDepth(id, sindex, 0))
}
return maxTxChainingDepth
}
示例6: async
checkCertificationUnicity: async (block:BlockDTO, conf:ConfDTO, index:IndexEntry[]) => {
const cindex = Indexer.cindex(index);
const certAtoB = _.uniq(cindex.map((row:CindexEntry) => row.issuer + row.receiver));
if (certAtoB.length !== cindex.length) {
throw Error('Block cannot contain identical certifications (A -> B)');
}
return true;
},
示例7: getTagsFromState
getTagsFromState(state:ITodoState) {
let tags:string[] = _.flatten(state.todos.map(todo => todo.tags));
let nonBlank = tags.filter(t => !!t);
let sorted = _.sortBy(nonBlank);
let unique = _.uniq(sorted, true);
return unique;
}
示例8: shouldCalcTimeAxisLabels
shouldCalcTimeAxisLabels(labels: string[], span: number): boolean {
return (
(
span > this.SECOND && this.axisType === "time"
|| this.axisType === "nanotime" && plotUtils.gt(span, this.UNIT)
)
&& labels.length != _.uniq(labels).length
);
}