本文整理汇总了TypeScript中underscore.all函数的典型用法代码示例。如果您正苦于以下问题:TypeScript all函数的具体用法?TypeScript all怎么用?TypeScript all使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了all函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: cachedVendorUpToDate
vendorList.map((vendorDef) => {
if (vendorBlackList.includes(vendorDef.hash)) {
return null;
}
if (
service.vendors[vendorDef.hash] &&
_.all(stores, (store) =>
cachedVendorUpToDate(
service.vendors[vendorDef.hash].cacheKeys[store.id],
store,
vendorDef
)
)
) {
service.loadedVendors++;
return service.vendors[vendorDef.hash];
} else {
return $q
.all(
characters.map((store) =>
loadVendorForCharacter(account, store, vendorDef, defs)
)
)
.then((vendors) => {
const nonNullVendors = _.compact(vendors);
if (nonNullVendors.length) {
const mergedVendor = mergeVendors(_.compact(vendors));
service.vendors[mergedVendor.hash] = mergedVendor;
} else {
delete service.vendors[vendorDef.hash];
}
});
}
})
示例2: detectMultiArrayTypes
private detectMultiArrayTypes(value: any, valueType: string[] = []): string[] {
if (_.isArray(value)) {
if (value.length === 0) {
valueType.push("any[];");
} else if (_.isArray(value[0])) {
for (let index = 0, length = value.length; index < length; index++) {
let element = value[index];
let valueTypeResult = this.detectMultiArrayTypes(element, valueType);
valueType.concat(valueTypeResult);
}
} else if (_.all(value, _.isString)) {
valueType.push("string[];");
} else if (_.all(value, _.isNumber)) {
valueType.push("number[];");
} else if (_.all(value, _.isBoolean)) {
valueType.push("boolean[];");
} else {
valueType.push("any[];");
}
}
return valueType;
}
示例3: slides
set slides(value: ISlide[]) {
if (value instanceof Array && _.all(value, isSlide)) {
if (!_.isEqual(this._ticker.ticks, value)) {
let running = this._ticker.isRunning;
this._ticker.stop();
this._ticker.ticks = value;
this._model.slides = value;
this._model.current = 0;
this.emit('changed', {
slides: this._model.slides,
current: this._model.current
});
if (running) {
this._ticker.start();
}
}
}
}
示例4: isAllEqual
private isAllEqual(array: string[]) {
return _.all(array.slice(1), _.partial(_.isEqual, array[0]));
}
示例5: _checkTicks
private static _checkTicks(ticks: ITickItem[]): boolean {
return (ticks instanceof Array) && _.all(ticks, isTickItem);
}
示例6: buildTalentGrid
//.........这里部分代码省略.........
// 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,
// The item level at which this node can be unlocked
activatedAtGridLevel,
// Only one node in this column can be selected (scopes, etc)
exclusiveInColumn,
// Whether there's enough XP in the item to buy the node
xpRequirementMet: activatedAtGridLevel <= totalLevel,
// Whether or not the material cost has been paid for the node
unlocked,
// Some nodes don't show up in the grid, like purchased ascend nodes
hidden: node.hidden,
dtrHash,
dtrRoll
// Whether (and in which order) this perk should be
// "featured" on an abbreviated info panel, as in the
// game. 0 = not featured, positive numbers signify the
// order of the featured perks.
// featuredPerk: (featuredPerkNames.indexOf(nodeName) + 1)
// This list of material requirements to unlock the
// item are a mystery. These hashes don't exist anywhere in
// the manifest database. Also, the activationRequirement
// object doesn't say how much of the material is
// needed. There's got to be some missing DB somewhere with
// this info.
// materialsNeeded: talentNodeSelected.activationRequirement.materialRequirementHashes
// These are useful for debugging or searching for new properties,
// but they don't need to be included in the result.
// talentNodeGroup: talentNodeGroup,
// talentNodeSelected: talentNodeSelected,
// itemNode: node
};
}
) as D1GridNode[];
// We need to unique-ify because Ornament nodes show up twice!
gridNodes = _.uniq(_.compact(gridNodes), false, (n) => n.hash);
if (!gridNodes.length) {
return null;
}
// This can be handy for visualization/debugging
// var columns = _.groupBy(gridNodes, 'column');
const maxLevelRequired = _.max(gridNodes, (n: any) => n.activatedAtGridLevel)
.activatedAtGridLevel;
const totalXPRequired = xpToReachLevel(maxLevelRequired);
const ascendNode: any = _.find(gridNodes, { hash: 1920788875 });
// Fix for stuff that has nothing in early columns
const minColumn = _.min(_.reject(gridNodes, (n: any) => n.hidden), (n: any) => n.column).column;
if (minColumn > 0) {
gridNodes.forEach((node) => {
node.column -= minColumn;
});
}
const maxColumn = _.max(gridNodes, (n: any) => n.column).column;
return {
nodes: _.sortBy(gridNodes, (node: any) => node.column + 0.1 * node.row),
xpComplete: totalXPRequired <= totalXP,
totalXPRequired,
totalXP: Math.min(totalXPRequired, totalXP),
hasAscendNode: Boolean(ascendNode),
ascended: Boolean(ascendNode && ascendNode.activated),
infusable: gridNodes.some((n) => n.hash === 1270552711),
dtrPerks: _.compact(gridNodes.map((i) => i.dtrHash)).join(';'),
dtrRoll: _.compact(gridNodes.map((i) => i.dtrRoll)).join(';'),
complete:
totalXPRequired <= totalXP &&
_.all(gridNodes, (n: any) => n.unlocked || (n.xpRequired === 0 && n.column === maxColumn))
};
}
示例7: buildTalentGrid
function buildTalentGrid(
item: DestinyItemComponent,
talentsMap: { [key: string]: DestinyItemTalentGridComponent },
talentDefs: LazyDefinition<DestinyTalentGridDefinition>
): DimTalentGrid | null {
if (!item.itemInstanceId || !talentsMap[item.itemInstanceId]) {
return null;
}
const talentGrid = talentsMap[item.itemInstanceId];
if (!talentGrid) {
return null;
}
const talentGridDef = talentDefs.get(talentGrid.talentGridHash);
if (!talentGridDef || !talentGridDef.nodes || !talentGridDef.nodes.length) {
return null;
}
const gridNodes = _.compact(talentGridDef.nodes.map((node): DimGridNode | undefined => {
const talentNodeGroup = node;
const talentNodeSelected = node.steps[0];
if (!talentNodeSelected) {
return undefined;
}
const nodeName = talentNodeSelected.displayProperties.name;
// 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.exclusiveWithNodeHashes &&
talentNodeGroup.exclusiveWithNodeHashes.length > 0);
const activatedAtGridLevel = talentNodeSelected.activationRequirement.gridLevel;
// There's a lot more here, but we're taking just what we need
return {
name: nodeName,
hash: talentNodeSelected.nodeStepHash,
description: talentNodeSelected.displayProperties.description,
icon: talentNodeSelected.displayProperties.icon,
// Position in the grid
column: talentNodeGroup.column / 8,
row: talentNodeGroup.row / 8,
// Is the node selected (lit up in the grid)
activated: true,
// The item level at which this node can be unlocked
activatedAtGridLevel,
// Only one node in this column can be selected (scopes, etc)
exclusiveInColumn,
// Whether or not the material cost has been paid for the node
unlocked: true,
// Some nodes don't show up in the grid, like purchased ascend nodes
hidden: false
};
}));
if (!gridNodes.length) {
return null;
}
// Fix for stuff that has nothing in early columns
const minByColumn = _.min(gridNodes.filter((n) => !n.hidden), (n) => n.column);
const minColumn = minByColumn.column;
if (minColumn > 0) {
gridNodes.forEach((node) => { node.column -= minColumn; });
}
return {
nodes: _.sortBy(gridNodes, (node) => node.column + (0.1 * node.row)),
complete: _.all(gridNodes, (n) => n.unlocked)
};
}