本文整理汇总了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)
})
示例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');
}
});
示例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