• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript util.isNumber函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中util.isNumber函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isNumber函数的具体用法?TypeScript isNumber怎么用?TypeScript isNumber使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了isNumber函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: function

export default function(receivedMap: Map, map: Map): any {
  if (isNumber(receivedMap.id) && isNumber(map.id)) {
    expect(receivedMap.id).to.equal(map.id);
  }
  expect(receivedMap.dimensions).to.deep.equal(map.dimensions);
  if (isString(receivedMap.creator) && isString(map.creator)) {
    expect(receivedMap.creator).to.equal(map.creator);
  }
  expect(receivedMap.category).to.equal(map.category);
  expect(receivedMap.name).to.equal(map.name);
  expect(receivedMap.maximumAmountOfPlayers).to.equal(map.maximumAmountOfPlayers);
  checkIfMapElementsAreEqual(receivedMap.buildings, map.buildings);
  checkIfMapElementsAreEqual(receivedMap.units, map.units);
  checkIfMapElementsAreEqual(receivedMap.terrain, map.terrain);
}
开发者ID:Ruddickmg,项目名称:js-wars,代码行数:15,代码来源:mapEquality.ts


示例2: updateAsync

  async updateAsync(favoriteIndex: number, favorite: Favorite, issuerId: ObjectID): Promise<Favorite> {
    if (!isNumber(favoriteIndex)) {
      throw new Error('favorite index must be a number');
    }
    if (!favorite) {
      throw new Error('favorite must be set');
    }
    if (!issuerId) {
      throw new Error('issuer must be set');
    }

    let updateDbReq = { $set: {} };
    updateDbReq.$set[`favorites.${favoriteIndex}`] = favorite;

    const result = await this.dbContext
      .users
      .findOneAndUpdate(
        { _id: issuerId },
        updateDbReq,
        { projection: { favorites: 1 }, returnOriginal: false }
      );

    const favorites = result.value.favorites as Favorite[];
    return favorites[favoriteIndex];
  }
开发者ID:sebthieti,项目名称:jogplayer-online,代码行数:25,代码来源:favorite.repository.ts


示例3: toInt

export function toInt(raw: any): number {
  if (isNaN(raw)) return 0
  if (isNumber(raw)) return Math.floor(raw)
  if (!raw && !isString(raw)) return 0
  const n = Number.parseInt(raw, 10)
  if (isNaN(n)) return 0
  return n
}
开发者ID:valdirmendesgt,项目名称:vscode_abap_remote_fs,代码行数:8,代码来源:utilities.ts


示例4: assertAndGetFavoriteIndex

 static assertAndGetFavoriteIndex(rawParams: any): number {
   if (!rawParams || !rawParams.favIndex) {
     throw new Error('Index must be set.');
   }
   if (utils.isNumber(rawParams.favIndex)) {
     throw new Error('Index must be a number.');
   }
   return +rawParams.favIndex;
 }
开发者ID:sebthieti,项目名称:jogplayer-online,代码行数:9,代码来源:favorite.validator.ts


示例5: transform

 transform(value: any, args?: any): any {
   console.log(value);
   if (value) {
     let sum = 0.0;
     for (const s of value) {
       if (isNumber(s['price'])) {
         sum += s['price'];
       }
     }
     return sum;
   }
 }
开发者ID:evrimulgen,项目名称:Cryptocurrency-Portfolio-Web,代码行数:12,代码来源:sum.pipe.ts


示例6: assertValidRequest

   private static assertValidRequest(rawRequest: any) {
    if (rawRequest === undefined) {
      throw new Error('No rawRequest has been provided for userState');
    }

    if (rawRequest.playedPosition && !utils.isNumber(rawRequest.playedPosition)) {
      throw new Error('playedPosition must be of type Number');
    }
    if (rawRequest.mediaQueue && !utils.isArray(rawRequest.mediaQueue)) {
      throw new Error('mediaQueue must be of type Array');
    }
    if (rawRequest.browsingFolderPath && !utils.isString(rawRequest.browsingFolderPath)) {
      throw new Error('browsingFolderPath must be of type String');
    }
    if (rawRequest.openedPlaylistPosition && !utils.isNumber(rawRequest.openedPlaylistPosition)) {
      throw new Error('openedPlaylistPosition must be of type String');
    }
    if (rawRequest.playingMediumInQueueIndex && !utils.isNumber(rawRequest.playingMediumInQueueIndex)) {
      throw new Error('playingMediumInQueueIndex must be of type Number');
    }
  }
开发者ID:sebthieti,项目名称:jogplayer-online,代码行数:21,代码来源:userState.validator.ts


示例7: dump

function dump(out: any): void {
    let outText = "";
    if (isBoolean(out)) {
        outText = "| Boolean: ";
    }
    if (isNumber(out)) {
        outText = "| Number: ";
    }
    if (isString(out)) {
        outText = "| String: ";
    }
    if (isArray(out)) {
        outText = "| Array: ";
    }

    console.log(outText, out);
}
开发者ID:zsala,项目名称:testing_typescript,代码行数:17,代码来源:types.ts


示例8: isDecimal

export function isDecimal(value: number): boolean {
    if (!isNumber(value))
        return false;
    else
        return true;
}
开发者ID:KostiaSA,项目名称:BuhtaClient2019,代码行数:6,代码来源:isDecimal.ts


示例9: it

 it('is false if it is not a number', () => {
   expect(isNumber('1')).to.be.false
   expect(isNumber(null)).to.be.false
 })
开发者ID:jkbrzt,项目名称:rrule,代码行数:4,代码来源:helpers.test.ts



注:本文中的util.isNumber函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript util.isObject函数代码示例发布时间:2022-05-25
下一篇:
TypeScript util.isNullOrUndefined函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap