本文整理汇总了TypeScript中lodash.isNaN函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isNaN函数的具体用法?TypeScript isNaN怎么用?TypeScript isNaN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isNaN函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: parseInt
_.each(entries, (entry: string, i: number) => {
const [instructionIndexStrIfExists, lengthStrIfExists, fileIndexStrIfExists, jumpTypeStrIfExists] = entry.split(
':',
);
const instructionIndexIfExists = parseInt(instructionIndexStrIfExists, RADIX);
const lengthIfExists = parseInt(lengthStrIfExists, RADIX);
const fileIndexIfExists = parseInt(fileIndexStrIfExists, RADIX);
const offset = _.isNaN(instructionIndexIfExists) ? lastParsedEntry.offset : instructionIndexIfExists;
const length = _.isNaN(lengthIfExists) ? lastParsedEntry.length : lengthIfExists;
const fileIndex = _.isNaN(fileIndexIfExists) ? lastParsedEntry.fileIndex : fileIndexIfExists;
const parsedEntry = {
offset,
length,
fileIndex,
};
if (parsedEntry.fileIndex !== -1) {
const sourceRange = {
location: {
start: locationByOffsetByFileIndex[parsedEntry.fileIndex][parsedEntry.offset],
end: locationByOffsetByFileIndex[parsedEntry.fileIndex][parsedEntry.offset + parsedEntry.length],
},
fileName: sources[parsedEntry.fileIndex],
};
instructionIndexToSourceRange[i] = sourceRange;
} else {
// Some assembly code generated by Solidity can't be mapped back to a line of source code.
// Source: https://github.com/ethereum/solidity/issues/3629
}
lastParsedEntry = parsedEntry;
});
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:30,代码来源:source_maps.ts
示例2: parseInt
let parseEnd = (totalEnd, partialend) => {
let end = partialend ? parseInt(partialend, 10) : totalEnd;
if (_.isNaN(end)) {
end = totalEnd;
}
return end;
}
开发者ID:practice-buddy,项目名称:the-practice-buddy,代码行数:7,代码来源:attachmentContent.ts
示例3: transformMetricData
transformMetricData(metricData, options, start, end) {
let dps = [],
metricLabel = null;
metricLabel = this.createMetricLabel(metricData.metric, options);
const stepMs = parseInt(options.step) * 1000;
let baseTimestamp = start * 1000;
if (metricData.values === undefined) {
throw new Error('Prometheus heatmap error: data should be a time series');
}
for (let value of metricData.values) {
let dp_value = parseFloat(value[1]);
if (_.isNaN(dp_value)) {
dp_value = null;
}
const timestamp = parseFloat(value[0]) * 1000;
for (let t = baseTimestamp; t < timestamp; t += stepMs) {
dps.push([null, t]);
}
baseTimestamp = timestamp + stepMs;
dps.push([dp_value, timestamp]);
}
const endTimestamp = end * 1000;
for (let t = baseTimestamp; t <= endTimestamp; t += stepMs) {
dps.push([null, t]);
}
return { target: metricLabel, datapoints: dps };
}
开发者ID:fangjianfeng,项目名称:grafana,代码行数:34,代码来源:result_transformer.ts
示例4: isProperPolyhedron
function isProperPolyhedron(polyhedron: Polyhedron) {
const expectedSideLength = polyhedron.edgeLength();
for (let edge of polyhedron.edges) {
const sideLength: number = edge.length();
if (_.isNaN(sideLength)) {
console.log(`edge ${edge} has length NaN`);
return false;
}
if (Math.abs(sideLength - expectedSideLength) > PRECISION) {
console.log(
`edge ${edge} has length ${sideLength} which is different from ${expectedSideLength}`,
);
return false;
}
// Make sure the whole thing is convex
if (edge.dihedralAngle() > Math.PI - PRECISION) {
console.log(`polyhedron concave at edge ${edge}`);
return false;
}
}
// Make sure all faces are facing the right way
const centroid = polyhedron.centroid();
for (let face of polyhedron.faces) {
const faceCentroid = face.centroid();
const normal = face.normal();
const expectedNormal = faceCentroid.sub(centroid);
if (normal.angleBetween(expectedNormal, true) > Math.PI / 2) {
console.log(`polyhedron inside out at ${face.index}`);
return false;
}
}
return true;
}
开发者ID:tessenate,项目名称:polyhedra-viewer,代码行数:34,代码来源:operationTestUtils.ts
示例5: function
this.transformMetricData = function(md, options, start, end) {
var dps = [],
metricLabel = null;
metricLabel = this.createMetricLabel(md.metric, options);
var stepMs = parseInt(options.step) * 1000;
var baseTimestamp = start * 1000;
for (let value of md.values) {
var dp_value = parseFloat(value[1]);
if (_.isNaN(dp_value)) {
dp_value = null;
}
var timestamp = parseFloat(value[0]) * 1000;
for (let t = baseTimestamp; t < timestamp; t += stepMs) {
dps.push([null, t]);
}
baseTimestamp = timestamp + stepMs;
dps.push([dp_value, timestamp]);
}
var endTimestamp = end * 1000;
for (let t = baseTimestamp; t <= endTimestamp; t += stepMs) {
dps.push([null, t]);
}
return { target: metricLabel, datapoints: dps };
};
开发者ID:postsql,项目名称:grafana,代码行数:29,代码来源:datasource.ts
示例6: buildBuilding
buildBuilding(player, buildingName, slot) {
const guild: Guild = player.guild;
if(!guild.isMod(player)) return 'You do not have enough privileges to do this!';
const buildingProto = Buildings[buildingName];
if(!buildingProto) return 'That building does not exist!';
if(buildingName !== 'GuildHall') {
if(!guild.$buildingInstances.GuildHall) return 'You do not have the guild hall built!';
}
const buildCost = guild.$base.costs.build;
const cost = buildCost[buildingProto.size];
if(guild.gold < cost) return 'You do not have enough gold to construct a building!';
slot = Math.floor(+slot);
if(_.isNaN(slot) || slot < 0 || slot > guild.$base.$slotSizes[buildingProto.size]) return 'Invalid slot.';
guild.gold -= cost;
guild.buildBuilding(buildingName, slot);
player._updateGuild();
player._updateGuildBuildings();
return `Successfully built ${buildingName}.`;
}
开发者ID:IdleLands,项目名称:IdleLands,代码行数:26,代码来源:guilds.ts
示例7:
isNum: (x, { min, max } = { min: undefined, max: undefined }) => {
const test = +x;
if(_.isNaN(+test)) { return false; }
if(min && test < min) { return false; }
if(max && test > max) { return false; }
return true;
},
开发者ID:Linko91,项目名称:posys,代码行数:7,代码来源:validator.ts
示例8: init
init(opts: any) {
_.extend(this, opts);
if(!this.founded) this.founded = Date.now();
if(!this.level) this.level = 1;
if(!this.gold || _.isNaN(this.gold)) this.gold = 0;
if(!this.members) this.members = [];
if(!this.taxRate) this.taxRate = 0;
if(!this.maxMembers) this.maxMembers = 10;
if(!this.motd) this.motd = `Welcome to ${this.name} [${this.tag}]!`;
if(!this.resources) this.resources = { wood: 0, stone: 0, clay: 0, astralium: 0 };
if(!this.baseLocation) this.baseLocation = 'Norkos';
if(!this.buildings) this.buildings = { currentlyBuilt: { sm: {}, md: {}, lg: {} }, levels: {}, properties: {} };
if(!this.buildings.currentlyBuilt) this.buildings.currentlyBuilt = { sm: {}, md: {}, lg: {} };
if(!this.buildings.levels) this.buildings.levels = {};
if(!this.buildings.properties) this.buildings.properties = {};
if(!this.$buildingInstances) this.$buildingInstances = {};
if(!this.$statBoosts) this.$statBoosts = {};
_.each(this.members, member => { if(member.rank > 5) member.rank = 5; });
_.each(_.keys(Buildings), building => this.buildings.levels[building] = this.buildings.levels[building] || 0);
this.buildBase();
this.recalculateStats();
}
开发者ID:IdleLands,项目名称:IdleLands,代码行数:26,代码来源:guild.ts
示例9: setTimeOffset
export function setTimeOffset(ms: number) {
if (isNaN(ms) || !isNumber(ms)) {
warning(t("Time is not properly formatted."), t("Bad Input"));
throw new Error("Bad time input on regimen page: " + JSON.stringify(ms));
} else {
return { type: Actions.SET_TIME_OFFSET, payload: ms };
}
}
开发者ID:RickCarlino,项目名称:farmbot-web-app,代码行数:8,代码来源:actions.ts
示例10: tickFormatter
function tickFormatter(valIndex) {
let valueFormatted = tsBuckets[valIndex];
if (!_.isNaN(_.toNumber(valueFormatted)) && valueFormatted !== '') {
// Try to format numeric tick labels
valueFormatted = tickValueFormatter(decimals)(_.toNumber(valueFormatted));
}
return valueFormatted;
}
开发者ID:fangjianfeng,项目名称:grafana,代码行数:8,代码来源:rendering.ts
注:本文中的lodash.isNaN函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论