当前位置:网站首页>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/, '');
}
边栏推荐
- 普通本科大学生活避坑指南
- Which Bluetooth headset is cost-effective? Four Bluetooth headsets with high cost performance are recommended
- Two points -leetcode-540 A single element in an ordered array
- 金仓KFS数据双向同步场景部署
- 金仓数据库KingbaseES 插件kdb_date_function
- 一名外包仔的2022年中总结
- Employee attendance management system based on SSM
- 使用BENCHMARKSQL工具对kingbaseES执行灌数据提示无法找到JDBC driver
- Wine travel Jianghu War: Ctrip is strong, meituan is strong, and Tiktok is fighting
- How to retrieve the password for opening word files
猜你喜欢

Learning practice: comprehensive application of cycle and branch structure (I)

FuncS sh file not found when using the benchmarksql tool to test kingbases

Leetcode simple question: the key with the longest key duration

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

Integration of Android high-frequency interview questions (including reference answers)

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

Know that Chuangyu cloud monitoring - scanv Max update: Ecology OA unauthorized server request forgery and other two vulnerabilities can be detected

Golang -- realize file transfer

有道云笔记

解决bp中文乱码
随机推荐
Function introduction of member points mall system
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
【SQL注入点】注入点出现位置、判断
C primre plus Chapter 10 question 6 inverted array
AWS VPC
Joint search set: the number of points in connected blocks (the number of points in a set)
使用BENCHMARKSQL工具对kingbasees并发测试时kill掉主进程成功后存在子线程未及时关闭
[fairseq] error: typeerror:_ broadcast_ coalesced(): incompatible function arguments
[pat (basic level) practice] - [simple simulation] 1063 calculate the spectral radius
Leetcode simple question: the key with the longest key duration
有道云笔记
[set theory] binary relationship (special relationship type | empty relationship | identity relationship | global relationship | divisive relationship | size relationship)
2022-02-14 (394. String decoding)
Hj35 serpentine matrix
Smart contract security audit company selection analysis and audit report resources download - domestic article
[software testing-6] & Test Management
Pyqt control part (II)
MC Layer Target
RSRS指标择时及大小盘轮动
vulnhub HA: Natraj