当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript lodash.parseInt函数代码示例

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


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

示例1: parseRoundScore

function parseRoundScore(g: LbDataGolfer): number {
  const str = g.round;
  if (isNullStr(str)) return 0;
  if (str === 'E') return 0;
  if (str.startsWith('+')) return parseInt(str.substr(1));
  if (str.startsWith('-')) return parseInt(str);
  throw new Error(`Unexpected round score: ${str}`);
}
开发者ID:odetown,项目名称:golfdraft,代码行数:8,代码来源:pgaTourLbDataReader.ts

示例2: signPersonalMessageAsync

    public async signPersonalMessageAsync(msgParams: SignPersonalMessageParams,
                                          callback: (err: Error, result?: string) => void) {
        if (!_.isUndefined(this.ledgerEthConnection)) {
            callback(new Error('Another request is in progress.'));
            return;
        }
        this.ledgerEthConnection = await this.createLedgerConnectionAsync();

        try {
            const derivationPath = this.getDerivationPath();
            const result = await this.ledgerEthConnection.signPersonalMessage_async(
                derivationPath, ethUtil.stripHexPrefix(msgParams.data),
            );
            const v = _.parseInt(result.v) - 27;
            let vHex = v.toString(16);
            if (vHex.length < 2) {
                vHex = `0${v}`;
            }
            const signature = `0x${result.r}${result.s}${vHex}`;
            await this.closeLedgerConnectionAsync();
            callback(null, signature);
        } catch (err) {
            await this.closeLedgerConnectionAsync();
            callback(err, null);
        }
    }
开发者ID:NickMinnellaCS96,项目名称:website,代码行数:26,代码来源:ledger_wallet_subprovider_factory.ts

示例3: onPageLoadInitFireAndForgetAsync

    private async onPageLoadInitFireAndForgetAsync() {
        await this.onPageLoadAsync(); // wait for page to load

        // Hack: We need to know the networkId the injectedWeb3 is connected to (if it is defined) in
        // order to properly instantiate the web3Wrapper. Since we must use the async call, we cannot
        // retrieve it from within the web3Wrapper constructor. This is and should remain the only
        // call to a web3 instance outside of web3Wrapper in the entire dapp.
        // In addition, if the user has an injectedWeb3 instance that is disconnected from a backing
        // Ethereum node, this call will throw. We need to handle this case gracefully
        const injectedWeb3 = (window as any).web3;
        let networkId: number;
        if (!_.isUndefined(injectedWeb3)) {
            try {
                networkId = _.parseInt(await promisify(injectedWeb3.version.getNetwork)());
            } catch (err) {
                // Ignore error and proceed with networkId undefined
            }
        }

        const provider = await this.getProviderAsync(injectedWeb3, networkId);
        this.zeroEx = new ZeroEx(provider);
        await this.updateProviderName(injectedWeb3);
        const shouldPollUserAddress = true;
        this.web3Wrapper = new Web3Wrapper(this.dispatcher, provider, networkId, shouldPollUserAddress);
        await this.postInstantiationOrUpdatingProviderZeroExAsync();
    }
开发者ID:NickMinnellaCS96,项目名称:website,代码行数:26,代码来源:blockchain.ts

示例4: parseDayScore

function parseDayScore(td: Element, par: number): number | 'MC' {
  const text = td.textContent.trim();
  if (isEmpty(text)) {
    // TODO: Turn this into typescript compatible
    return constants.MISSED_CUT as 'MC';
  }
  return parseInt(text) - par;
}
开发者ID:odetown,项目名称:golfdraft,代码行数:8,代码来源:pgaTourHistoricHtmlReader.ts

示例5:

 trs.forEach(tr => {
   const tds = tr.querySelectorAll('td');
   const wgr = _.parseInt(tds.item(0).textContent);
   const name = tr.querySelector('td.name')
     .textContent
     .trim()
     .replace(AMATEUR_REGEX, '');
   wgrs.push({ wgr, name } as WGR);
 });
开发者ID:odetown,项目名称:golfdraft,代码行数:9,代码来源:rawWgrReader.ts

示例6: switch

  configComponents.forEach(component => {
    const [ key, value ] = component.split('=');

    const lKey = key.toLowerCase();

    switch (lKey[ 0 ]) {
      case 'c': {
        if (primordialCharacter.className === 'None') {
          const chosenCharacterClass = _.find(Character.CHARACTER_CLASS_NAMES, (name) => {
            return Helpers.isApproximateString(value, name);
          });

          if (chosenCharacterClass) {
            primordialCharacter.className = chosenCharacterClass;
          } else {
            log.push(`Unrecognized character class: ${value}`);
          }
        }

        break;
      }
      case 'a': {
        if (primordialCharacter.allegiance === 'None') {
          const chosenAllegiance = _.find(Character.ALLEGIANCES, (allegiance) => {
            return Helpers.isApproximateString(value, allegiance);
          });

          if (chosenAllegiance) {
            primordialCharacter.allegiance = chosenAllegiance;
          } else {
            log.push(`Unrecognized allegiance: ${value}`);
          }
        }

        break;
      }
      case 'm': {
        updatedNumModifiers = true;
        if (primordialCharacter.numModifiers === 0) {
          const chosenNumModifiers = _.parseInt(value, 10);

          if (_.isFinite(chosenNumModifiers) && chosenNumModifiers >= 0) {
            primordialCharacter.numModifiers = chosenNumModifiers;
          } else {
            log.push(`Bad number of modifiers: ${value}`);
          }

          break;
        }
      }
      default: {
        log.push(`Unrecognized key: ${key}`);
        break;
      }
    }
  });
开发者ID:zthomae,项目名称:xanadu,代码行数:56,代码来源:lobby.ts

示例7: createPeruste

 _.each(T.Koulutustyypit(), kt => {
     const ktkoodi = _.parseInt(kt.split("_")[1]);
     $httpBackend
         .when("GET", "/eperusteet-service/api/perusteprojektit/" + ktkoodi)
         .respond(createPerusteprojekti(ktkoodi));
     $httpBackend.when("GET", "/eperusteet-service/api/perusteet/" + ktkoodi).respond(
         createPeruste(("koulutustyyppi_" + ktkoodi) as T.Koulutustyyppi, {
             id: ktkoodi
         })
     );
 });
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:11,代码来源:perusteprojekti.test.ts

示例8: parseNetworkId

function parseNetworkId(networkIdStrIfExists?: string): number {
    if (_.isUndefined(networkIdStrIfExists)) {
        return NETWORK_ID;
    } else {
        const networkId = _.parseInt(networkIdStrIfExists);
        if (networkId !== NETWORK_ID) {
            const validationErrorItem = {
                field: 'networkId',
                code: 1004,
                reason: `Incorrect Network ID: ${networkIdStrIfExists}`,
            };
            throw new ValidationError([validationErrorItem]);
        }
        return networkId;
    }
}
开发者ID:YuitoSato,项目名称:0x-launch-kit,代码行数:16,代码来源:url_params_parsing.ts

示例9: _onPageLoadInitFireAndForgetAsync

    private async _onPageLoadInitFireAndForgetAsync() {
        await utils.onPageLoadAsync(); // wait for page to load

        // Hack: We need to know the networkId the injectedWeb3 is connected to (if it is defined) in
        // order to properly instantiate the web3Wrapper. Since we must use the async call, we cannot
        // retrieve it from within the web3Wrapper constructor. This is and should remain the only
        // call to a web3 instance outside of web3Wrapper in the entire dapp.
        // In addition, if the user has an injectedWeb3 instance that is disconnected from a backing
        // Ethereum node, this call will throw. We need to handle this case gracefully
        const injectedWeb3 = (window as any).web3;
        let networkIdIfExists: number;
        if (!_.isUndefined(injectedWeb3)) {
            try {
                networkIdIfExists = _.parseInt(await promisify<string>(injectedWeb3.version.getNetwork)());
            } catch (err) {
                // Ignore error and proceed with networkId undefined
            }
        }

        const provider = await Blockchain._getProviderAsync(injectedWeb3, networkIdIfExists);
        this.networkId = !_.isUndefined(networkIdIfExists)
            ? networkIdIfExists
            : configs.IS_MAINNET_ENABLED ? constants.NETWORK_ID_MAINNET : constants.NETWORK_ID_KOVAN;
        this._dispatcher.updateNetworkId(this.networkId);
        const zeroExConfigs = {
            networkId: this.networkId,
        };
        this._zeroEx = new ZeroEx(provider, zeroExConfigs);
        this._updateProviderName(injectedWeb3);
        const shouldPollUserAddress = true;
        this._web3Wrapper = new Web3Wrapper(provider);
        this._blockchainWatcher = new BlockchainWatcher(
            this._dispatcher,
            this._web3Wrapper,
            this.networkId,
            shouldPollUserAddress,
        );

        const userAddresses = await this._web3Wrapper.getAvailableAddressesAsync();
        this._userAddressIfExists = userAddresses[0];
        this._dispatcher.updateUserAddress(this._userAddressIfExists);
        await this.fetchTokenInformationAsync();
        this._blockchainWatcher.startEmittingNetworkConnectionAndUserBalanceState();
        await this._rehydrateStoreWithContractEvents();
    }
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:45,代码来源:blockchain.ts

示例10: generateNewTitle

 generateNewTitle(oldTitle, aes, titleName){
     let newTitle;
     if (_.endsWith(oldTitle, '_CLONE')){
         newTitle = oldTitle + '(1)';
     }else{
         if (_.endsWith(oldTitle, ')')){
             let split = _.split(oldTitle,  '(');
             let index = _.last(split);
             split.pop();
             index = _.replace(index, ')', '');
             let indexInt = _.parseInt(index);
             newTitle = split + '(' + _.add(indexInt, 1) + ')';
         }else{
             newTitle = oldTitle + '_CLONE';
         }
     }
     if(aes && _.findIndex(aes, function(o) { return (_.hasIn(o,titleName) && o[titleName] == newTitle); }) > -1){
         return this.generateNewTitle(newTitle, aes, titleName);
     }else{
         return newTitle;
     }
 }
开发者ID:PyJava1984,项目名称:dcm4chee-arc-light,代码行数:22,代码来源:devices.service.ts


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