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


TypeScript util.isNumber函數代碼示例

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