当前位置:网站首页>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/, '');
}
边栏推荐
- [set theory] set identities (idempotent law | exchange law | combination law | distribution rate | De Morgan law | absorption rate | zero law | identity | exclusion law | contradiction law | complemen
- Factor stock selection scoring model
- Php+mysql registration landing page development complete code
- Integration of Android high-frequency interview questions (including reference answers)
- JS multidimensional array to one-dimensional array
- Introduction to message queuing (MQ)
- X-ray normal based contour rendering
- 使用BENCHMARKSQL工具对kingbasees并发测试时kill掉主进程成功后存在子线程未及时关闭
- Priv app permission exception
- Writing skills of multi plate rotation strategy -- strategy writing learning materials
猜你喜欢
【XSS绕过-防护策略】理解防护策略,更好的绕过
2022 t elevator repair simulation examination question bank and t elevator repair simulation examination question bank
使用BENCHMARKSQL工具对KingbaseES预热数据时执行:select sys_prewarm(‘NDX_OORDER_2 ‘)报错
2022 registration of G2 utility boiler stoker examination and G2 utility boiler stoker reexamination examination
[dynamic programming] subsequence problem
Integration of Android high-frequency interview questions (including reference answers)
一名外包仔的2022年中总结
I've been in software testing for 8 years and worked as a test leader for 3 years. I can also be a programmer if I'm not a professional
Games101 Lesson 9 shading 3 Notes
Some information about the developer environment in Chengdu
随机推荐
Dive into deep learning - 2.1 data operation & Exercise
C Primer Plus Chapter 10, question 14 3 × 5 array
商城系统搭建完成后需要设置哪些功能
GFS distributed file system (it's nice to meet it alone)
[Thesis Writing] how to write the overall design of JSP tourism network
MC Layer Target
[software testing-6] & Test Management
X-ray normal based contour rendering
How to retrieve the password for opening word files
跨境电商多商户系统怎么选
【工具跑SQL盲注】
Some information about the developer environment in Chengdu
GFS分布式文件系统(光是遇见已经很美好了)
Use the benchmarksql tool to perform a data prompt on kingbases. The jdbc driver cannot be found
[PCL self study: filtering] introduction and use of various filters in PCL (continuously updated)
重绘和回流
[Chongqing Guangdong education] reference materials for design and a better life of Zhongyuan Institute of science and technology
Contents of welder (primary) examination and welder (primary) examination in 2022
2022 P cylinder filling test content and P cylinder filling simulation test questions
[fxcg] market analysis today