本文整理汇总了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];
}
});
}
})
开发者ID:bhollis,项目名称:DIM,代码行数:35,代码来源:vendor.service.ts
示例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;
}
开发者ID:lafe,项目名称:VSCode-json2ts,代码行数:24,代码来源:Json2Ts.ts
示例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();
}
}
}
}
开发者ID:kol-93,项目名称:express-slider,代码行数:18,代码来源:SliderController.ts
示例4: isAllEqual
private isAllEqual(array: string[]) {
return _.all(array.slice(1), _.partial(_.isEqual, array[0]));
}
开发者ID:lafe,项目名称:VSCode-json2ts,代码行数:3,代码来源:Json2Ts.ts
示例5: _checkTicks
private static _checkTicks(ticks: ITickItem[]): boolean {
return (ticks instanceof Array) && _.all(ticks, isTickItem);
}
开发者ID:kol-93,项目名称:express-slider,代码行数:3,代码来源:Ticker.ts
示例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))
};
}
开发者ID:bhollis,项目名称:DIM,代码行数:101,代码来源:d1-item-factory.service.ts
示例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)
};
}
开发者ID:delphiactual,项目名称:DIM,代码行数:77,代码来源:d2-item-factory.service.ts
注:本文中的underscore.all函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论