本文整理匯總了TypeScript中utilities/tools-util.precisionRound函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript precisionRound函數的具體用法?TypeScript precisionRound怎麽用?TypeScript precisionRound使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了precisionRound函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: xemUSDValue
return new Promise<number>(async (resolve, reject) => {
try {
const usdStr = await xemUSDValue();
const usdVal = parseFloat(usdStr);
resolve(precisionRound((usdVal * xemAmount) / 1e6, 2));
} catch (err) {
reject(err);
}
});
示例2: precisionRound
return new Promise<number>(async (resolve, reject) => {
try {
const xemEquivalent = ((XEM_MARKET_CAP * (tokenAmount * 1e6)) / CHE_TOTAL_QUANTITY) / 1e4;
const unweightedFee = Math.abs(xemEquivalent - SUPPLY_RELATED_ADJUSTMENT);
let fee = precisionRound(unweightedFee * 0.05, 6);
if (fee >= 1.25) { fee = 1.25; }
resolve(fee);
} catch (err) {
reject(err);
}
});
示例3: async
api.get('/tokens-sold', async (req: Request, res: Response) => {
try {
const usdTotals: Array<UsdTotal> = await findAll<UsdTotal>(DB_USD_TOTALS);
if (req.query.currency === 'usd' && usdTotals.length > 0) {
return res.send({amount: precisionRound(usdTotals[0].currentRaised, 2), milestone: usdTotals[0].nextMilestone });
}
res.status(409).json({ message: 'object or parameter not found.'});
} catch (err) {
res.status(409).json(err);
}
});
示例4: Address
return new Promise<any>(async (resolve, reject) => {
try {
const senderAddress = new Address(req.body.tokenRecipientAddress).plain();
const createdDate = new Date();
const hashId = await generateHashId(senderAddress, createdDate.toISOString());
const product = await findById<Product>(DB_PRODUCTS, req.body.productId);
const quotedAmount = await usdToXem(product.priceUSD);
const data: XemTransaction = {
_id: new ObjectID(),
tokenRecipientAddress: senderAddress,
tokenType: req.body.tokenType,
productId: product._id,
totalPaid: 0,
quotedAmount: precisionRound(quotedAmount * 1e6, 0),
usdPaid: 0,
message: MESSAGE_PREFIX + hashId,
createdAt: createdDate
};
await saveWithId<XemTransaction>(DB_PENDING_XEM_CHARGES, data);
resolve({tokenRecipientAddress: tokenHoldingAccountAddress(), message: data.message, usdValue: product.priceUSD, xemAmount: precisionRound(quotedAmount, 6)});
} catch (err) {
reject(err);
}
});