本文整理汇总了TypeScript中lodash.uniq函数的典型用法代码示例。如果您正苦于以下问题:TypeScript uniq函数的具体用法?TypeScript uniq怎么用?TypeScript uniq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了uniq函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: mapStateToProps
export function mapStateToProps(props: Everything): Props {
const peripherals = uniq(selectAllPeripherals(props.resources.index));
const sensors = uniq(selectAllSensors(props.resources.index));
const resources = props.resources;
const bot2mqtt = props.bot.connectivity["bot.mqtt"];
const botToMqttStatus = bot2mqtt ? bot2mqtt.state : "down";
const fwConfig = validFwConfig(getFirmwareConfig(props.resources.index));
const { mcu_params } = props.bot.hardware;
const installedOsVersion = determineInstalledOsVersion(
props.bot, maybeGetDevice(props.resources.index));
const getWebAppConfigVal = getWebAppConfigValue(() => props);
return {
feeds: selectAllWebcamFeeds(resources.index),
dispatch: props.dispatch,
bot: props.bot,
user: maybeFetchUser(props.resources.index),
peripherals,
sensors,
botToMqttStatus,
firmwareSettings: fwConfig || mcu_params,
shouldDisplay: shouldDisplay(installedOsVersion, props.bot.minOsFeatureData),
getWebAppConfigVal,
sensorReadings: selectAllSensorReadings(props.resources.index),
timeOffset: maybeGetTimeOffset(props.resources.index),
};
}
示例2: function
ElasticResponse.prototype.nameSeries = function(seriesList, target) {
var metricTypeCount = _.uniq(_.map(seriesList, 'metric')).length;
var fieldNameCount = _.uniq(_.map(seriesList, 'field')).length;
for (var i = 0; i < seriesList.length; i++) {
var series = seriesList[i];
series.target = this._getSeriesName(series, target, metricTypeCount, fieldNameCount);
}
};
示例3: my
function my(state: State['my'] = [], action: Action): State['my'] {
switch (action.type) {
case 'RECEIVE_MY_ORGANIZATIONS':
return uniq([...state, ...action.organizations.map(o => o.key)]);
case 'CREATE_ORGANIZATION':
return uniq([...state, action.organization.key]);
case 'DELETE_ORGANIZATION':
return without(state, action.key);
default:
return state;
}
}
示例4: getSelectedItems
getSelectedItems(...filters: BaseEntityType[]): BaseModel<BaseEntity, BaseModelListener>[] {
if (!Array.isArray(filters)) {
filters = [filters];
}
var items = [];
// run through nodes
items = items.concat(
_.flatMap(this.nodes, node => {
return node.getSelectedEntities();
})
);
// find all the links
items = items.concat(
_.flatMap(this.links, link => {
return link.getSelectedEntities();
})
);
//find all points
items = items.concat(
_.flatMap(this.links, link => {
return _.flatMap(link.points, point => {
return point.getSelectedEntities();
});
})
);
items = _.uniq(items);
if (filters.length > 0) {
items = _.filter(_.uniq(items), (item: BaseModel<any>) => {
if (_.includes(filters, "node") && item instanceof NodeModel) {
return true;
}
if (_.includes(filters, "link") && item instanceof LinkModel) {
return true;
}
if (_.includes(filters, "port") && item instanceof PortModel) {
return true;
}
if (_.includes(filters, "point") && item instanceof PointModel) {
return true;
}
return false;
});
}
return items;
}
示例5: fetchForStudy
async function fetchForStudy(queries:Query[], studyId:string, molecularProfileIdDiscrete:string|undefined):Promise<AugmentedData<DiscreteCopyNumberData, string>> {
try {
const uniqueSamples = _.uniq(queries.map(q=>q.sampleId));
const uniqueGenes = _.uniq(queries.map(q=>q.entrezGeneId));
let filters:DiscreteCopyNumberFilter[];
if (uniqueSamples.length < uniqueGenes.length) {
// Make one query per sample, since there are fewer samples than genes
const sampleToEntrezList:{[sampleId:string]:number[]} = {};
for (const query of queries) {
sampleToEntrezList[query.sampleId] = sampleToEntrezList[query.sampleId] || [];
sampleToEntrezList[query.sampleId].push(query.entrezGeneId);
}
filters = Object.keys(sampleToEntrezList).map(sample=>{
return {
sampleIds: [sample],
entrezGeneIds: sampleToEntrezList[sample]
} as DiscreteCopyNumberFilter;
});
} else {
// Make one query per gene
const entrezToSampleList:{[entrez:string]:string[]} = {};
for (const query of queries) {
entrezToSampleList[query.entrezGeneId] = entrezToSampleList[query.entrezGeneId] || [];
entrezToSampleList[query.entrezGeneId].push(query.sampleId);
}
filters = Object.keys(entrezToSampleList).map(entrez=>{
return {
sampleIds: entrezToSampleList[entrez],
entrezGeneIds: [parseInt(entrez, 10)]
} as DiscreteCopyNumberFilter;
});
}
const allData:DiscreteCopyNumberData[][] = await Promise.all(filters.map(filter=>{
if (typeof molecularProfileIdDiscrete === "undefined") {
return Promise.reject("No molecular profile id given.");
} else {
return client.fetchDiscreteCopyNumbersInMolecularProfileUsingPOST({
projection: "DETAILED",
molecularProfileId: molecularProfileIdDiscrete,
discreteCopyNumberFilter: filter,
discreteCopyNumberEventType: "ALL"
});
}
}));
return {data:_.flatten(allData), meta:studyId};
} catch (err) {
throw err;
}
}
示例6: getDuplicateModules
export function getDuplicateModules(classes: VenueLesson[]): ModuleCode[] {
const lessonsByTime: VenueLesson[][] = values(
groupBy(classes, (lesson) => [lesson.startTime, lesson.endTime, lesson.weeks, lesson.day]),
);
for (const lessons of lessonsByTime) {
if (lessons.length > 1) {
// Occasionally two classes share the same venue, so we don't count those
const moduleCodes = uniq(lessons.map((lesson) => lesson.moduleCode));
if (uniq(moduleCodes).length > 1) return moduleCodes;
}
}
return [];
}
示例7: switch
const userLogins = (state: UserLogins = [], action: any = {}) => {
switch (action.type) {
case RECEIVE_CURRENT_USER:
case RECEIVE_USER:
return uniq([...state, action.user.login]);
case membersActions.RECEIVE_MEMBERS:
case membersActions.RECEIVE_MORE_MEMBERS:
return uniq([...state, action.members.map((member: any) => member.login)]);
case membersActions.ADD_MEMBER: {
return uniq([...state, action.member.login]).sort();
}
default:
return state;
}
};
示例8: makeGeneticTrackTooltip_getCoverageInformation
export function makeGeneticTrackTooltip_getCoverageInformation(
profiled_in: {genePanelId?:string, molecularProfileId:string}[]|undefined,
not_profiled_in: {genePanelId?:string, molecularProfileId:string}[]|undefined,
alterationTypesInQuery?: string[],
molecularProfileIdToMolecularProfile?: {[molecularProfileId:string]:MolecularProfile}
):{
dispProfiledGenePanelIds: string[];
dispNotProfiledGenePanelIds: string[];
dispProfiledIn: string[]|undefined;
dispNotProfiledIn: string[]|undefined;
dispAllProfiled:boolean;
dispNotProfiled:boolean;
} {
let dispProfiledGenePanelIds:string[] = [];
let dispProfiledGenePanelIdsMap:{[genePanelId:string]:string} = {};
let dispProfiledIn:string[]|undefined = undefined;
let dispProfiledInMap:{[molecularProfileId:string]:string} = {};
let dispNotProfiledIn:string[]|undefined = undefined;
let dispNotProfiledGenePanelIds:string[] = [];
let profiledInTypes:{[type:string]:string}|undefined = undefined;
if (profiled_in) {
dispProfiledGenePanelIds = _.uniq((profiled_in.map(x=>x.genePanelId) as (string|undefined)[]).filter(x=>!!x) as string[]);
dispProfiledIn = _.uniq(profiled_in.map(x=>x.molecularProfileId));
if (molecularProfileIdToMolecularProfile) {
profiledInTypes = _.keyBy(dispProfiledIn, molecularProfileId=>molecularProfileIdToMolecularProfile[molecularProfileId].molecularAlterationType);
}
dispProfiledInMap = _.keyBy(dispProfiledIn);
dispProfiledGenePanelIdsMap = _.keyBy(dispProfiledGenePanelIds);
}
if (not_profiled_in) {
dispNotProfiledIn = _.uniq(not_profiled_in.map(x=>x.molecularProfileId)).filter(x=>!dispProfiledInMap[x]); // filter out profiles in profiled_in to avoid confusing tooltip (this occurs e.g. w multiple samples, one profiled one not)
if (profiledInTypes && alterationTypesInQuery && molecularProfileIdToMolecularProfile) {
let notProfiledInTypes = _.keyBy(dispNotProfiledIn, molecularProfileId=>molecularProfileIdToMolecularProfile[molecularProfileId].molecularAlterationType);
// add an entry to 'not profiled in' for each alteration type in the query iff the sample is not profiled in a profile of that type, and that type is not already accounted for.
// This is for the case of multiple study query - eg one study has CNA profile, the other doesnt, and we want to show in a tooltip from the other study that
// the sample is not profiled for CNA. If the study actually has a CNA profile, then we wont show "not profiled for copy number alterations" because
// that will be filtered out below because its in profiledInTypes or notProfiledInTypes. Otherwise, CNA will be in alterationTypesInQuery,
// and it wont be covered in profiledInTypes or notProfiledInTypes, so it will make sense to say "copy number alterations" in that generality.
dispNotProfiledIn = dispNotProfiledIn.concat(alterationTypesInQuery.filter(t=>(!profiledInTypes![t] && !notProfiledInTypes[t])).map(t=>alterationTypeToProfiledForText[t]));
}
dispNotProfiledGenePanelIds = _.uniq(not_profiled_in.map(x=>x.genePanelId)).filter(x=>(!!x && !dispProfiledGenePanelIdsMap[x])) as string[] ;
}
const dispAllProfiled = !!(dispProfiledIn && dispProfiledIn.length && dispNotProfiledIn && !dispNotProfiledIn.length);
const dispNotProfiled = !!(dispNotProfiledIn && dispNotProfiledIn.length && dispProfiledIn && !dispProfiledIn.length);
return {
dispProfiledGenePanelIds, dispNotProfiledGenePanelIds, dispProfiledIn, dispNotProfiledIn, dispAllProfiled, dispNotProfiled
};
}
示例9: getTagsWithIds
public async getTagsWithIds(tagIds: string[]): Promise<BeatTag[]> {
try {
return await this.REST.get<BeatTag[]>(`/api/beats/tags/${uniq(tagIds).join(',')}`);
} catch (e) {
return [];
}
}
示例10: intersect
tokens.forEach(token => {
const x = intersect(acc, acc + token.text.length, location.from, location.to);
const p1 = part(token.text, acc, x.from, acc);
const p2 = part(token.text, x.from, x.to, acc);
const p3 = part(token.text, x.to, acc + token.text.length, acc);
if (p1.length) {
nextTokens.push({ ...token, text: p1 });
}
if (p2.length) {
const newClassName =
token.className.indexOf(rootClassName) === -1
? `${token.className} ${rootClassName}`
: token.className;
nextTokens.push({
className: newClassName,
markers:
!markerAdded && location.index != null
? uniq([...token.markers, location.index])
: token.markers,
text: p2
});
markerAdded = true;
}
if (p3.length) {
nextTokens.push({ ...token, text: p3 });
}
acc += token.text.length;
});