本文整理汇总了TypeScript中underscore.any函数的典型用法代码示例。如果您正苦于以下问题:TypeScript any函数的具体用法?TypeScript any怎么用?TypeScript any使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了any函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: isTextPresentInTable
function isTextPresentInTable(searchContext: ISearchContext, table: ITable): boolean {
if (_.any(table.HeaderRow, s => isTextPresent(searchContext, s))) {
return true;
}
return _.any(table.DataRows, r => _.any(r, s => isTextPresent(searchContext, s)));
}
示例2: isTagPresentInFeature
function isTagPresentInFeature(tag: RegExp, feature: IFeature): IScenario[] {
if (_.any(feature.Feature.Tags, t => isTextPresentRegEx(tag, t))) {
return feature.Feature.FeatureElements;
}
const scenarios = _.filter(
feature.Feature.FeatureElements, s => _.any(s.tagsInternal, t => isTextPresentRegEx(tag, t)));
return !_.any(scenarios) ? null : scenarios;
}
示例3: isTextPresentInFolder
function isTextPresentInFolder(searchContext: ISearchContext, folder: IFolder): IFolder {
const isTextPresentInTitle = !folder.isRoot && !_.any(searchContext.tags) &&
isTextPresent(searchContext, splitWords(folder.name));
const features = _.filter(_.map(folder.features, f => isTextPresentInFeature(searchContext, f)), f => !!f);
const folders = _.filter(_.map(folder.children, f => isTextPresentInFolder(searchContext, f)), f => !!f);
if (!isTextPresentInTitle && !_.any(features) && !_.any(folders)) {
return null;
}
return {
children: folders,
features: features,
isRoot: folder.isRoot,
name: folder.name
};
}
示例4: isInfiniteScrollMode
private static isInfiniteScrollMode(root: HTMLElement) {
const resultListSelector = `.${Component.computeCssClassNameForType('ResultList')}`;
const resultLists = $$(root).findAll(resultListSelector);
return any(resultLists, resultList => {
const options: IResultListOptions = (get(resultList) as any).options;
return options && options.enableInfiniteScroll;
});
}
示例5:
let candidates = store.items.filter((i) => {
return i.canBeEquippedBy(target) &&
i.location.id === item.location.id &&
!i.equipped &&
// Not the same item
i.id !== item.id &&
// Not on the exclusion list
!_.any(exclusionsList, { id: i.id, hash: i.hash });
});
示例6: 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
};
}
示例7: isTextPresentInScenario
function isTextPresentInScenario(searchContext: ISearchContext, scenario: IScenario): boolean {
if (isTextPresent(searchContext, scenario.Name)) {
return true;
}
if (isTextPresent(searchContext, scenario.Description)) {
return true;
}
if (scenario.Examples) {
if (isTextPresent(searchContext, scenario.Examples.Description)) {
return true;
}
if (isTextPresentInTable(searchContext, scenario.Examples.TableArgument)) {
return true;
}
}
return _.any(scenario.Steps, s => isTextPresentInStep(searchContext, s));
}
示例8: searchFilters
//.........这里部分代码省略.........
3592189221, // -leg-armor
738642122,
3797169075, // -helmet
838904328
];
return sublimeEngrams.includes(item.hash);
},
// Incomplete will show items that are not fully leveled.
incomplete(item: DimItem) {
return item.talentGrid && !item.complete;
},
// Complete shows items that are fully leveled.
complete(item: DimItem) {
return item.complete;
},
// Upgraded will show items that have enough XP to unlock all
// their nodes and only need the nodes to be purchased.
upgraded(item: D1Item) {
return item.talentGrid && item.talentGrid.xpComplete && !item.complete;
},
xpincomplete(item: D1Item) {
return item.talentGrid && !item.talentGrid.xpComplete;
},
xpcomplete(item: D1Item) {
return item.talentGrid && item.talentGrid.xpComplete;
},
ascended(item: D1Item) {
return item.talentGrid && item.talentGrid.hasAscendNode && item.talentGrid.ascended;
},
unascended(item: D1Item) {
return item.talentGrid && item.talentGrid.hasAscendNode && !item.talentGrid.ascended;
},
reforgeable(item: DimItem) {
return item.talentGrid && _.any(item.talentGrid.nodes, { hash: 617082448 });
},
ornament(item: D1Item, predicate: string) {
const complete = item.talentGrid && item.talentGrid.nodes.some((n) => n.ornament);
const missing = item.talentGrid && item.talentGrid.nodes.some((n) => !n.ornament);
if (predicate === 'ornamentunlocked') {
return complete;
} else if (predicate === 'ornamentmissing') {
return missing;
} else {
return complete || missing;
}
},
untracked(item: D1Item) {
return item.trackable && !item.tracked;
},
tracked(item: D1Item) {
return item.trackable && item.tracked;
},
unlocked(item: DimItem) {
return (item.lockable && !item.locked) || !item.lockable;
},
locked(item: DimItem) {
return item.lockable && item.locked;
},
masterwork(item: DimItem) {
return item.masterwork;
},
maxpower(item: DimItem) {
if (!_maxPowerItems.length) {
storeService.getStores().forEach((store) => {
_maxPowerItems.push(
示例9: Boolean
(node): D1GridNode | undefined => {
const talentNodeGroup = possibleNodes[node.nodeHash];
const talentNodeSelected = talentNodeGroup.steps[node.stepIndex];
if (!talentNodeSelected) {
return undefined;
}
const nodeName = talentNodeSelected.nodeStepName;
// Filter out some weird bogus nodes
if (!nodeName || nodeName.length === 0 || talentNodeGroup.column < 0) {
return undefined;
}
// Only one node in this column can be selected (scopes, etc)
const exclusiveInColumn = Boolean(
talentNodeGroup.exlusiveWithNodes && talentNodeGroup.exlusiveWithNodes.length > 0
);
// Unlocked is whether or not the material cost has been paid
// for the node
const unlocked =
node.isActivated ||
talentNodeGroup.autoUnlocks ||
// If only one can be activated, the cost only needs to be
// paid once per row.
(exclusiveInColumn &&
_.any(talentNodeGroup.exlusiveWithNodes, (nodeIndex: number) => {
return item.nodes[nodeIndex].isActivated;
}));
// Calculate relative XP for just this node
const startProgressionBarAtProgress = talentNodeSelected.startProgressionBarAtProgress;
const activatedAtGridLevel = talentNodeSelected.activationRequirement.gridLevel;
const xpRequired = xpToReachLevel(activatedAtGridLevel) - startProgressionBarAtProgress;
const xp = Math.max(0, Math.min(totalXP - startProgressionBarAtProgress, xpRequired));
// Build a perk string for the DTR link. See https://github.com/DestinyItemManager/DIM/issues/934
let dtrHash: string | null = null;
if (node.isActivated || talentNodeGroup.isRandom) {
dtrHash = (node.nodeHash as number).toString(16);
if (dtrHash.length > 1) {
dtrHash += '.';
}
if (talentNodeGroup.isRandom) {
dtrHash += node.stepIndex.toString(16);
if (node.isActivated) {
dtrHash += 'o';
}
}
}
// Generate a hash that identifies the weapons permutation and selected perks.
// This is used by the Weapon Reviewing system.
const generateNodeDtrRoll = (node, talentNodeSelected): string => {
let dtrRoll = node.nodeHash.toString(16);
if (dtrRoll.length > 1) {
dtrRoll += '.';
}
dtrRoll += node.stepIndex.toString(16);
if (node.isActivated) {
dtrRoll += 'o';
}
if (talentNodeSelected.perkHashes && talentNodeSelected.perkHashes.length > 0) {
dtrRoll += `,${talentNodeSelected.perkHashes.join(',')}`;
}
return dtrRoll;
};
const dtrRoll = generateNodeDtrRoll(node, talentNodeSelected);
// hacky way to determine if the node is a weapon ornament
let ornamentComplete = false;
if (talentNodeGroup.column > 1 && !xpRequired && !exclusiveInColumn && item.primaryStat) {
ornamentComplete = node.isActivated;
}
// There's a lot more here, but we're taking just what we need
return {
name: nodeName,
ornament: ornamentComplete,
hash: talentNodeSelected.nodeStepHash,
description: talentNodeSelected.nodeStepDescription,
icon: talentNodeSelected.icon,
// XP put into this node
xp,
// XP needed for this node to unlock
xpRequired,
// Position in the grid
column: talentNodeGroup.column,
row: talentNodeGroup.row,
// Is the node selected (lit up in the grid)
activated: node.isActivated,
//.........这里部分代码省略.........
示例10: canMoveToStore
/**
* Is there anough space to move the given item into store? This will refresh
* data and/or move items aside in an attempt to make a move possible.
* @param item The item we're trying to move.
* @param store The destination store.
* @param options.triedFallback True if we've already tried reloading stores
* @param options.excludes A list of items that should not be moved in
* order to make space for this move.
* @param options.reservations A map from store => type => number of spaces to leave open.
* @param options.numRetries A count of how many alternate items we've tried.
* @return a promise that's either resolved if the move can proceed or rejected with an error.
*/
function canMoveToStore(item: DimItem, store: DimStore, amount: number, options: {
triedFallback?: boolean;
excludes?: DimItem[];
reservations?: { [storeId: number]: number };
numRetries?: number;
} = {}): IPromise<void> {
const { triedFallback = false, excludes = [], reservations = {}, numRetries = 0 } = options;
const storeService = getStoreService(item);
function spaceLeftWithReservations(s, i) {
let left = s.spaceLeftForItem(i);
// minus any reservations
if (reservations[s.id] && reservations[s.id][i.type]) {
left -= reservations[s.id][i.type];
}
// but not counting the original item that's moving
if (s.id === item.owner && i.type === item.type && !item.location.inPostmaster) {
left--;
}
return Math.max(0, left);
}
if (item.owner === store.id && !item.location.inPostmaster) {
return $q.resolve(true);
}
const stores = storeService.getStores();
// How much space will be needed (in amount, not stacks) in the target store in order to make the transfer?
const storeReservations: { [storeId: string]: number } = {};
storeReservations[store.id] = amount;
// guardian-to-guardian transfer will also need space in the vault
if (item.owner !== 'vault' && !store.isVault && item.owner !== store.id) {
storeReservations.vault = amount;
}
// How many moves (in amount, not stacks) are needed from each
const movesNeeded = {};
stores.forEach((s) => {
if (storeReservations[s.id]) {
movesNeeded[s.id] = Math.max(0, storeReservations[s.id] - spaceLeftWithReservations(s, item));
}
});
if (!_.any(movesNeeded)) {
return $q.resolve(true);
} else if (store.isVault || triedFallback) {
// Move aside one of the items that's in the way
const moveContext: MoveContext = {
originalItemType: item.type,
excludes,
spaceLeft(s, i) {
let left = spaceLeftWithReservations(s, i);
if (i.type === this.originalItemType) {
left = left - storeReservations[s.id];
}
return Math.max(0, left);
}
};
// Move starting from the vault (which is always last)
const moves = _.pairs(movesNeeded)
.reverse()
.find(([_, moveAmount]) => moveAmount > 0)!;
const moveAsideSource = storeService.getStore(moves[0])!;
const { item: moveAsideItem, target: moveAsideTarget } = chooseMoveAsideItem(moveAsideSource, item, moveContext);
if (!moveAsideTarget || (!moveAsideTarget.isVault && moveAsideTarget.spaceLeftForItem(moveAsideItem) <= 0)) {
const itemtype = (moveAsideTarget.isVault
? (moveAsideItem.destinyVersion === 1
? moveAsideItem.bucket.sort
: '')
: moveAsideItem.type);
const error: DimError = new Error($i18next.t(`ItemService.BucketFull.${moveAsideTarget.isVault ? 'Vault' : 'Guardian'}`,
{ itemtype, store: moveAsideTarget.name, context: moveAsideTarget.gender }));
error.code = 'no-space';
return $q.reject(error);
} else {
// Make one move and start over!
return moveTo(moveAsideItem, moveAsideTarget, false, moveAsideItem.amount, excludes)
.then(() => canMoveToStore(item, store, amount, options))
.catch((e) => {
if (numRetries < 3) {
// Exclude this item and try again so we pick another
excludes.push(moveAsideItem);
options.excludes = excludes;
options.numRetries = numRetries + 1;
//.........这里部分代码省略.........