当前位置:网站首页>I've seen a piece of code in the past. I don't know what I'm doing. I can review it when I have time
I've seen a piece of code in the past. I don't know what I'm doing. I can review it when I have time
2022-07-03 04:35:00 【hamimelon2020】
const digitsRE = /(\d{3})(?=\d)/g
export function factPrice(value, discount){
value = parseFloat(value);
discount = parseFloat(discount);
if(!discount) return value
return value * discount;
}
export function currency (value, currency, decimals) {
value = parseFloat(value)
if (!isFinite(value) || (!value && value !== 0)) return ''
currency = currency != null ? currency : '¥'
decimals = decimals != null ? decimals : 2
var stringified = Math.abs(value).toFixed(decimals)
var _int = decimals
? stringified.slice(0, -1 - decimals)
: stringified
var i = _int.length % 3
var head = i > 0
? (_int.slice(0, i) + (_int.length > 3 ? ',' : ''))
: ''
var _float = decimals
? stringified.slice(-1 - decimals)
: ''
var sign = value < 0 ? '-' : ''
return sign + currency + head +
_int.slice(i).replace(digitsRE, '$1,') +
_float
}
export function formatTime(value){
return value.toLocaleString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '');
}
边栏推荐
- [fxcg] inflation differences will still lead to the differentiation of monetary policies in various countries
- What are the Bluetooth headsets with good sound quality in 2022? Inventory of four high-quality Bluetooth headsets
- Know that Chuangyu cloud monitoring - scanv Max update: Ecology OA unauthorized server request forgery and other two vulnerabilities can be detected
- 使用BENCHMARKSQL工具对KingbaseES预热数据时执行:select sys_prewarm(‘NDX_OORDER_2 ‘)报错
- 2022 chemical automation control instrument examination summary and chemical automation control instrument certificate examination
- Some information about the developer environment in Chengdu
- vulnhub HA: Natraj
- How to retrieve the password for opening word files
- 有道云笔记
- Joint search set: the number of points in connected blocks (the number of points in a set)
猜你喜欢

Triangular rasterization

Employee attendance management system based on SSM

Number of 1 in binary (simple difficulty)

【XSS绕过-防护策略】理解防护策略,更好的绕过

Number of uniform strings of leetcode simple problem

How to choose cross-border e-commerce multi merchant system

Use the benchmarksql tool to perform a data prompt on kingbases. The jdbc driver cannot be found

2022 registration examination for safety production management personnel of hazardous chemical production units and examination skills for safety production management personnel of hazardous chemical

Which Bluetooth headset is good about 400? Four Bluetooth headsets with strong noise reduction are recommended

Leetcode simple question: the key with the longest key duration
随机推荐
JS multidimensional array to one-dimensional array
How to use kotlin to improve productivity: kotlin tips
2.14 summary
Basic use of continuous integration server Jenkins
Square root of X
Php+mysql registration landing page development complete code
When using the benchmarksql tool to test the concurrency of kingbasees, there are sub threads that are not closed in time after the main process is killed successfully
Golang -- realize file transfer
Dismantle a 100000 yuan BYD "Yuan". Come and see what components are in it.
[Thesis Writing] how to write the overall design of JSP tourism network
arthas watch 抓取入参的某个字段/属性
逆袭大学生的职业规划
跨境电商多商户系统怎么选
Introduction of pointer variables in function parameters
JVM原理简介
2022 t elevator repair simulation examination question bank and t elevator repair simulation examination question bank
[set theory] binary relationship (binary relationship notation | binary relationship from a to B | number of binary relationships | example of binary relationship)
智能合约安全审计公司选型分析和审计报告资源下载---国内篇
多板块轮动策略编写技巧----策略编写学习教材
Which Bluetooth headset is good about 400? Four Bluetooth headsets with strong noise reduction are recommended