0.0.4 • Published 4 years ago

fn_tools v0.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

实际工作中用到的一些工具函数,整理成一个工具包,便于后期直接使用和升级迭代,如有错误还请多多指教……

npm NPM APM

安装
yarn add fn_tools -s

or

npm install fn_tools -s
使用
improt { fn_tools_name1, fn_tools_name2, …… } from 'fn_tools';

数值格式化(金额 | 数值)

numberFormat

主要应用对数值进行格式化,包括保留有效数值位数,以及涉及金额增加千分符

参数类型默认值备注
numberNumber String
decimal_placeString2有效数位,若想要整数,直接传入0
thousand_markString,千分符号,若传入为数值,做空处理
math_typeStringroundMath类型,round, ceil, floor decimals_place > 0才生效
error_msgString--数值不存在时的错误信息

阿拉伯数字转换 (金额)

numberTransform

主要应用与金额模块,需要对金额进行大写的情况

参数类型默认值备注
numberNumber String
typeStringupper文本类型, lower (如:一 二 三), upper(壹, 贰, 叁)

日期格式化

dateFormat

主要应用对日期格式化,返回需要的类型

参数类型默认值备注
timestampNumber日期时间戳
typeStringYY-MM-DD返回格式,YY(年) YY-MM(年月) YY-MM-DD(年月日) YY-MM-DD-HMS(年月日时分秒) MM-DD(月日) HMS(时分秒) HM(时分) MS(分秒)
markString-连接符号

日期差

dateCompare

主要应用两个日期比较,计算两个日期的差额

参数类型默认值备注
startDateNumber开始日期,必时间戳
endDateNumber结束日期,必时间戳
deviceDateNumber设备日期(本地日期),必时间戳