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


TypeScript tools-util.precisionRound函数代码示例

本文整理汇总了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);
		}
	});
开发者ID:joseabril25,项目名称:nem-coinbase-token-sale-api,代码行数:9,代码来源:nem-util.ts

示例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);
		}
	});
开发者ID:joseabril25,项目名称:nem-coinbase-token-sale-api,代码行数:11,代码来源:nem-util.ts

示例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);
		}
	});
开发者ID:joseabril25,项目名称:nem-coinbase-token-sale-api,代码行数:11,代码来源:info.ts

示例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);
		}
	});
开发者ID:joseabril25,项目名称:nem-coinbase-token-sale-api,代码行数:24,代码来源:nem-service.ts


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