本文整理汇总了TypeScript中bignumber.js.default.includes方法的典型用法代码示例。如果您正苦于以下问题:TypeScript js.default.includes方法的具体用法?TypeScript js.default.includes怎么用?TypeScript js.default.includes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bignumber.js.default
的用法示例。
在下文中一共展示了js.default.includes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: dropsToXrp
function dropsToXrp(drops: string | BigNumber): string {
if (typeof drops === 'string') {
if (!drops.match(/^-?[0-9]*\.?[0-9]*$/)) {
throw new ValidationError(`dropsToXrp: invalid value '${drops}',` +
` should be a number matching (^-?[0-9]*\.?[0-9]*$).`)
} else if (drops === '.') {
throw new ValidationError(`dropsToXrp: invalid value '${drops}',` +
` should be a BigNumber or string-encoded number.`)
}
}
// Converting to BigNumber and then back to string should remove any
// decimal point followed by zeros, e.g. '1.00'.
// Important: specify base 10 to avoid exponential notation, e.g. '1e-7'.
drops = (new BigNumber(drops)).toString(10)
// drops are only whole units
if (drops.includes('.')) {
throw new ValidationError(`dropsToXrp: value '${drops}' has` +
` too many decimal places.`)
}
// This should never happen; the value has already been
// validated above. This just ensures BigNumber did not do
// something unexpected.
if (!drops.match(/^-?[0-9]+$/)) {
throw new ValidationError(`dropsToXrp: failed sanity check -` +
` value '${drops}',` +
` does not match (^-?[0-9]+$).`)
}
return (new BigNumber(drops)).dividedBy(1000000.0).toString(10)
}