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

TypeScript lodash.round函数代码示例

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

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



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

示例1: character

export function character(character: Character, camera: Camera, context: any): void {
    // assume the character should be centered
    let screenX: number = character.centerPosition.x;
    let screenY: number = character.centerPosition.y;
    if (character.is.leftOfCenter) {
        screenX = character.x;
    };
    if (character.is.rightOfCenter) {
        // character's max screenX - character's distance from the map's right edge
        screenX = (camera.width - character.width) - (character.maxX - character.x);
    }
    if (character.is.upOfCenter) {
        screenY = character.y;
    }
    if (character.is.downOfCenter) {
        // character's max screenY - character's distance from the map's bottom edge
        screenY = (camera.height - character.height) - (character.maxY - character.y);
    }

    context.drawImage(
        character.image,
        _.round(screenX),
        _.round(screenY),
        character.width,
        character.height
    );
}
开发者ID:rbcasperson,项目名称:canvas-tile-map,代码行数:27,代码来源:draw.ts


示例2: generateCourtOfferedPaymentIntention

  static generateCourtOfferedPaymentIntention (draft: DraftClaimantResponse, claim: Claim, decisionType: DecisionType): PaymentIntention {
    const courtOfferedPaymentIntention = new PaymentIntention()
    const claimResponse = claim.response as FullAdmissionResponse | PartialAdmissionResponse
    const admittedClaimAmount: number = AdmissionHelper.getAdmittedAmount(claim)

    if (decisionType === DecisionType.CLAIMANT || decisionType === DecisionType.CLAIMANT_IN_FAVOUR_OF_DEFENDANT) {
      courtOfferedPaymentIntention.paymentOption = PaymentOption.IMMEDIATELY
      courtOfferedPaymentIntention.paymentDate = MomentFactory.currentDate().add(5, 'days')
    }

    if (decisionType === DecisionType.COURT) {
      const paymentPlanFromDefendantFinancialStatement: PaymentPlan = PaymentPlanHelper.createPaymentPlanFromDefendantFinancialStatement(claim, draft)

      if (claimResponse.paymentIntention.paymentOption === PaymentOption.INSTALMENTS) {
        const defendantFrequency: Frequency = Frequency.of(claimResponse.paymentIntention.repaymentPlan.paymentSchedule)
        const paymentPlanConvertedToDefendantFrequency: PaymentPlan = paymentPlanFromDefendantFinancialStatement.convertTo(defendantFrequency)

        courtOfferedPaymentIntention.paymentOption = PaymentOption.INSTALMENTS
        courtOfferedPaymentIntention.repaymentPlan = {
          firstPaymentDate: paymentPlanConvertedToDefendantFrequency.startDate,
          instalmentAmount: paymentPlanConvertedToDefendantFrequency.instalmentAmount > admittedClaimAmount ?
            admittedClaimAmount : _.round(paymentPlanConvertedToDefendantFrequency.instalmentAmount,2),
          paymentSchedule: Frequency.toPaymentSchedule(paymentPlanConvertedToDefendantFrequency.frequency),
          completionDate: paymentPlanConvertedToDefendantFrequency.calculateLastPaymentDate(),
          paymentLength: paymentPlanConvertedToDefendantFrequency.calculatePaymentLength()
        }
      } else {
        const paymentPlanConvertedToMonthlyFrequency: PaymentPlan = paymentPlanFromDefendantFinancialStatement.convertTo(Frequency.MONTHLY)

        courtOfferedPaymentIntention.paymentOption = PaymentOption.INSTALMENTS
        courtOfferedPaymentIntention.repaymentPlan = {
          firstPaymentDate: paymentPlanConvertedToMonthlyFrequency.startDate,
          instalmentAmount: paymentPlanConvertedToMonthlyFrequency.instalmentAmount > admittedClaimAmount ?
            admittedClaimAmount : _.round(paymentPlanConvertedToMonthlyFrequency.instalmentAmount,2),
          paymentSchedule: Frequency.toPaymentSchedule(paymentPlanConvertedToMonthlyFrequency.frequency),
          completionDate: paymentPlanConvertedToMonthlyFrequency.calculateLastPaymentDate(),
          paymentLength: paymentPlanConvertedToMonthlyFrequency.calculatePaymentLength()
        }
      }
    }

    if (decisionType === DecisionType.DEFENDANT) {

      if (claimResponse.paymentIntention.paymentOption === PaymentOption.BY_SPECIFIED_DATE) {
        courtOfferedPaymentIntention.paymentDate = claimResponse.paymentIntention.paymentDate
        courtOfferedPaymentIntention.paymentOption = PaymentOption.BY_SPECIFIED_DATE
      }

      if (claimResponse.paymentIntention.paymentOption === PaymentOption.INSTALMENTS) {

        courtOfferedPaymentIntention.paymentOption = PaymentOption.INSTALMENTS
        courtOfferedPaymentIntention.repaymentPlan = claimResponse.paymentIntention.repaymentPlan
      }
    }
    return courtOfferedPaymentIntention
  }
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:56,代码来源:payment-option.ts


示例3: drawView

 drawView(): void {
     let offsetX: number = _.round(-this.camera.x + (this.tilesInView.startCol * this.map.tileWidth));
     let offsetY: number = _.round(-this.camera.y + (this.tilesInView.startRow * this.map.tileHeight));
     _.each(_.range(this.map.layers.length), (layer: number) => {
         // if it is the correct layer, draw the character
         if(this.character && layer === this.character.layer) {
             this.drawCharacter();
         };
         // draw the layer
         this.drawLayer(layer, offsetX, offsetY);
     });
     if(this.character && this.map.layers.length <= this.character.layer) {
         this.drawCharacter();
     };
 }
开发者ID:rbcasperson,项目名称:canvas-tile-map,代码行数:15,代码来源:game.ts


示例4: calculateTotalAmount

 static calculateTotalAmount (sources: IncomeExpenseSource[]): number {
   const totalMonthlyAmount = _.reduce(sources, function (total: number, source: IncomeExpenseSource) {
     const monthlyAmount = source.amount * source.schedule.valueInMonths
     return total + monthlyAmount
   }, 0)
   return _.round(totalMonthlyAmount, 2)
 }
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:7,代码来源:calculateMonthlyIncomeExpense.ts


示例5: constructor

 constructor(id: number, factory: string, name: string, type: string,
     storage: number, schema: Array<DatabaseSchema>) {
   this.id = id;
   this.factory = factory;
   this.name = name;
   this.type = type;
   this.storage = storage;
   this.schema = schema;
   this.usedSpace = 0;
   let ref = this;
   _.forEach(this.schema, function(s) {
       ref.usedSpace = ref.usedSpace + s.memoryUsedInGB;
   });
   this.availSpace = _.round(this.storage - this.usedSpace, 2);
   this.usedSpace = _.round(this.usedSpace, 2);
 }
开发者ID:railsstudent,项目名称:angular2-appcheck,代码行数:16,代码来源:database-instance.ts


示例6: toString

 toString(): string {
   const isOk = b => (b ? 'OK' : 'NG');
   return (
     `${padEnd(this.broker, 10)}: ${padStart(_.round(this.btc, 3), 5)} BTC, ` +
     `${t`LongAllowed`}: ${isOk(this.longAllowed)}, ` +
     `${t`ShortAllowed`}: ${isOk(this.shortAllowed)}`
   );
 }
开发者ID:HarryTmetic,项目名称:r2,代码行数:8,代码来源:BrokerPositionImpl.ts


示例7:

 _.each(_.range(tiles.startCol, tiles.endCol + 1), (col: number) => {
     let tile = map.layers[layer][row][col];
     if (tile !== 0) {
         let source = map.spriteSheet[tile];
         let destX = ((col - tiles.startCol) * map.tileWidth) + offsetX;
         let destY = ((row - tiles.startRow) * map.tileHeight) + offsetY;
         context.drawImage(
             map.spriteSheet.image,
             source.x,
             source.y,
             source.width,
             source.height,
             _.round(destX),
             _.round(destY),
             map.tileWidth,
             map.tileHeight
         )
     }
 })
开发者ID:rbcasperson,项目名称:canvas-tile-map,代码行数:19,代码来源:draw.ts


示例8: function

 _.forEach(data.values, function(value: number) {
   let percentage = _.round(value / total * 100, 2);
   values.push({
     name: that.parent.widget.chart.labels[idx],
     y: percentage,
     color: that.parent.widget.chart.colors[idx],
     hits: value
   });
   idx++;
 });
开发者ID:gravitee-io,项目名称:gravitee-management-webui,代码行数:10,代码来源:widget-chart-pie.component.ts


示例9: checkCommandsEqual

function checkCommandsEqual(actual: ReadonlyArray<Command>, expected: ReadonlyArray<Command>) {
  expect(actual.length).toEqual(expected.length);
  for (let i = 0; i < actual.length; i++) {
    const a = actual[i];
    const e = expected[i];
    expect(a.type).toEqual(e.type);
    expect(a.points.length).toEqual(e.points.length);
    for (let j = 0; j < a.points.length; j++) {
      const ap = a.points[j];
      const ep = e.points[j];
      if (!ap || !ep) {
        expect(ap).toEqual(undefined);
        expect(ep).toEqual(undefined);
      } else {
        expect(_.round(ap.x, 8)).toEqual(ep.x);
        expect(_.round(ap.y, 8)).toEqual(ep.y);
      }
    }
  }
}
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:20,代码来源:Path.spec.ts


示例10: format_number

 format_number(n: any, divisor: number, units: string[], decimals: number = 1): string {
   if (_.isString(n)) {
     n = Number(n);
   }
   if (!_.isNumber(n)) {
     return '-';
   }
   const unit = n < 1 ? 0 : Math.floor(Math.log(n) / Math.log(divisor));
   const truncatedFloat = _.round(n / Math.pow(divisor, unit), decimals).toString();
   return truncatedFloat === '' ? '-' : truncatedFloat + units[unit];
 }
开发者ID:prallabh,项目名称:ceph-1,代码行数:11,代码来源:formatter.service.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript lodash.sample函数代码示例发布时间:2022-05-25
下一篇:
TypeScript lodash.reverse函数代码示例发布时间: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