本文整理汇总了TypeScript中underscore.intersection函数的典型用法代码示例。如果您正苦于以下问题:TypeScript intersection函数的具体用法?TypeScript intersection怎么用?TypeScript intersection使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了intersection函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getItemYear
function getItemYear(item) {
// determine what year this item came from based on sourceHash value
// items will hopefully be tagged as follows
// No value: Vanilla, Crota's End, House of Wolves
// The Taken King (year 2): 460228854
// Rise of Iron (year 3): 24296771
// This could be further refined for CE/HoW based on activity. See
// DestinyRewardSourceDefinition and filter on %SOURCE%
// if sourceHash doesn't contain these values, we assume they came from
// year 1
let year = 1;
const ttk = item.sourceHashes.includes(yearHashes.year2[0]);
const roi = item.sourceHashes.includes(yearHashes.year3[0]);
if (ttk || item.infusable || _.intersection(yearHashes.year2, item.sourceHashes).length) {
year = 2;
}
if (
!ttk &&
(item.classified || roi || _.intersection(yearHashes.year3, item.sourceHashes).length)
) {
year = 3;
}
return year;
}
示例2: it
it("should return 7 refs for browseNode on ServerStatus (BrowseDirection.Both)", (done: any) => {
const serverStatus = rootFolder.objects.server.serverStatus;
const references = serverStatus.browseNode({
browseDirection: BrowseDirection.Both,
includeSubtypes: true,
nodeClassMask: 0, // 0 = all nodes
referenceTypeId: "HierarchicalReferences",
resultMask: 0x3F
});
const browseNames = references.map((r) => r.browseName.name);
// xx console.log(" " + browseNames.join(" , "));
const expectedBrowseNames = [
"StartTime", "CurrentTime", "State", "BuildInfo", "SecondsTillShutdown", "ShutdownReason", "Server"];
_.intersection(browseNames, expectedBrowseNames).length.should.eql(expectedBrowseNames.length);
redirectToFile("ReferenceDescription2.log", () => {
_.isArray(references).should.eql(true);
dumpReferenceDescriptions(addressSpace, references);
}, done);
});
示例3: redirectToFile
(done: any) => {
const serverStatus = rootFolder.objects.server.serverStatus;
const references = serverStatus.browseNode({
browseDirection: BrowseDirection.Inverse,
includeSubtypes: true,
nodeClassMask: 0, // 0 = all nodes
referenceTypeId: "HierarchicalReferences",
resultMask: 0x3F
});
const browseNames = references.map((r: ReferenceDescription) => {
return r.browseName!.name;
});
// console.log(" browseNames : " + browseNames.join(" , "));
// xx references.length.should.equal(7);
const expectedBrowseNames = ["Server"];
_.intersection(browseNames, expectedBrowseNames).length.should.eql(expectedBrowseNames.length);
redirectToFile("ReferenceDescription1.log", () => {
_.isArray(references).should.eql(true);
dumpReferenceDescriptions(addressSpace, references);
}, done);
});
示例4: isTextPresentInFeature
function isTextPresentInFeature(searchContext: ISearchContext, feature: IFeature): IFeature {
const tagsScenariosMap = _.map(searchContext.tags, t => isTagPresentInFeature(t, feature));
if (_.any(tagsScenariosMap, a => a === null)) {
return null;
}
const tagsScenarios = _.union(...tagsScenariosMap);
const isTextPresentInTitle = isTextPresent(searchContext, feature.Feature.Name);
const isTextPresentInDescription = isTextPresent(searchContext, feature.Feature.Description);
const isTextPresentInBackground = feature.Feature.Background &&
isTextPresentInScenario(searchContext, feature.Feature.Background);
// Intersection is made to preserve original order between scenarios
let scenarios = !_.any(searchContext.tags)
? feature.Feature.FeatureElements : _.intersection(feature.Feature.FeatureElements, tagsScenarios);
scenarios = _.filter(scenarios, s => isTextPresentInScenario(searchContext, s));
if (!isTextPresentInTitle && !isTextPresentInDescription && !isTextPresentInBackground && !_.any(scenarios)) {
return null;
}
return {
Feature: {
Background: !isTextPresentInBackground ? null : feature.Feature.Background,
Description: feature.Feature.Description,
FeatureElements: scenarios,
Name: feature.Feature.Name,
Result: feature.Feature.Result,
Tags: feature.Feature.Tags
},
RelativeFolder: feature.RelativeFolder,
code: feature.code,
get isExpanded() { return feature.isExpanded; },
set isExpanded(value: boolean) { feature.isExpanded = value; },
isManual: feature.isManual
};
}
示例5:
return this.graph.filter(s => s['@type'] === 'rdf:Property' && s.domain && _.intersection(s.domain, conceptIDs).length > 0);