當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript lodash.isNaN函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。