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


TypeScript js.default.eq方法代码示例

本文整理汇总了TypeScript中bignumber.js.default.eq方法的典型用法代码示例。如果您正苦于以下问题:TypeScript js.default.eq方法的具体用法?TypeScript js.default.eq怎么用?TypeScript js.default.eq使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bignumber.js.default的用法示例。


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

示例1: BigNumber

 paths.alternatives = _.filter(paths.alternatives, alt => {
   if (!alt.source_amount) {
     return false
   }
   const pathfindSourceAmountValue = new BigNumber(
     pathfind.source.amount.currency === 'XRP' ?
     xrpToDrops(pathfind.source.amount.value) :
     pathfind.source.amount.value)
   const altSourceAmountValue = new BigNumber(
     typeof alt.source_amount === 'string' ?
     alt.source_amount :
     alt.source_amount.value
   )
   return altSourceAmountValue.eq(pathfindSourceAmountValue)
 })
开发者ID:ripple,项目名称:ripple-lib,代码行数:15,代码来源:pathfind.ts

示例2: Error

      _.forEach(txParams.recipients, (expectedOutput, index) => {
        const expectedOutputAddress = this.getAddressDetails(expectedOutput.address);
        const output = outputOperations[index];
        if (output.destination !== expectedOutputAddress.address) {
          throw new Error('transaction prebuild does not match expected recipient');
        }

        const expectedOutputAmount = new BigNumber(expectedOutput.amount);
        // The output amount is expressed as startingBalance in createAccount operations and as amount in payment operations.
        let outputAmount = (output.type === 'createAccount') ? output.startingBalance : output.amount;
        outputAmount = new BigNumber(this.bigUnitsToBaseUnits(outputAmount));

        if (!outputAmount.eq(expectedOutputAmount)) {
          throw new Error('transaction prebuild does not match expected amount');
        }
      });
开发者ID:BitGo,项目名称:BitGoJS,代码行数:16,代码来源:xlm.ts

示例3: percentageDiff

		/**
		 * Calculate the percentage difference
		 * between
		 *
		 * @param {string|BigNumber} newNum The new number
		 * @param {string|BigNumber} oldNum The old number
		 * @returns {{ diff: string; increase: boolean }}
		 */
		percentageDiff(
			newNum: string | BigNumber,
			oldNum: string | BigNumber,
		): { diff: string; increase: boolean } {
			const newNumBig = new BigNumber(newNum);
			const oldNumBig = new BigNumber(oldNum);
			if (newNumBig.eq(oldNumBig)) {
				return { diff: "0", increase: false };
			} else if (newNumBig.comparedTo(oldNumBig) > 0) {
				const inc = newNumBig.minus(oldNumBig);
				return {
					increase: true,
					diff: inc
						.div(oldNumBig)
						.times(100)
						.toString(),
				};
			} else {
				const dec = oldNumBig.minus(newNumBig);
				return {
					increase: false,
					diff: dec
开发者ID:,项目名称:,代码行数:30,代码来源:


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