本文整理匯總了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);