本文整理汇总了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;
});
示例2: parseInt
let parseEnd = (totalEnd, partialend) => {
let end = partialend ? parseInt(partialend, 10) : totalEnd;
if (_.isNaN(end)) {
end = totalEnd;
}
return end;
}
示例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 };
}
示例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;
}
示例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 };
};
示例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}.`;
}
示例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;
},
示例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();
}
示例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 };
}
}
示例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;
}