当前位置:网站首页>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/, '');
}
边栏推荐
- 【XSS绕过-防护策略】理解防护策略,更好的绕过
- Library management system based on SSM
- Preliminary cognition of C language pointer
- 使用BENCHMARKSQL工具对kingbaseES执行灌数据提示无法找到JDBC driver
- FFMpeg example
- What's wrong with SD card data damage? How to recover SD card data damage
- Basic use of continuous integration server Jenkins
- [PCL self study: filtering] introduction and use of various filters in PCL (continuously updated)
- Square root of X
- Contents of welder (primary) examination and welder (primary) examination in 2022
猜你喜欢

2022 P cylinder filling test content and P cylinder filling simulation test questions

UiPath实战(08) - 选取器(Selector)

FISCO bcos zero knowledge proof Fiat Shamir instance source code

After reviewing MySQL for a month, I was stunned when the interviewer of Alibaba asked me

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

Introduction of pointer variables in function parameters

Introduction to message queuing (MQ)

The programmer went to bed at 12 o'clock in the middle of the night, and the leader angrily scolded: go to bed so early, you are very good at keeping fit

Smart contract security audit company selection analysis and audit report resources download - domestic article

FuncS sh file not found when using the benchmarksql tool to test kingbases
随机推荐
[set theory] binary relation (example of binary relation on a | binary relation on a)
Matplotlib -- save graph
GFS分布式文件系统(光是遇见已经很美好了)
Design and implementation of JSP logistics center storage information management system
4 years of experience to interview test development, 10 minutes to end, ask too
What's wrong with SD card data damage? How to recover SD card data damage
Introduction to message queuing (MQ)
When using the benchmarksql tool to preheat data for kingbasees, execute: select sys_ Prewarm ('ndx_oorder_2 ') error
AWS VPC
Reptile exercise 02
vulnhub HA: Natraj
Some information about the developer environment in Chengdu
arthas watch 抓取入参的某个字段/属性
Ffmpeg mix
Introduction of pointer variables in function parameters
【SQL注入】联合查询(最简单的注入方法)
Youdao cloud notes
[fxcg] market analysis today
消息队列(MQ)介绍
Solve BP Chinese garbled code