npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

hxy-bank-utils

v1.0.1

Published

银行项目专用工具函数库,支持移动端和PC端,兼容低版本浏览器

Readme

hxy-bank-utils

银行项目专用工具函数库,支持移动端和PC端,兼容低版本浏览器。

特性

  • 🏦 银行专用 - 针对银行项目需求设计的工具函数
  • 📱 移动端友好 - 支持移动端和PC端
  • 🌐 浏览器兼容 - 兼容低版本浏览器(IE11+)
  • 📦 按需引入 - 支持按需引入和全局引入
  • 🔒 类型安全 - 完整的TypeScript类型定义
  • 🧪 测试覆盖 - 完整的单元测试覆盖
  • 📚 详细文档 - 每个函数都有详细的注释和示例

安装

npm install hxy-bank-utils

使用方式

按需引入

import { formatAmount, isValidBankCard, maskPhone } from 'hxy-bank-utils';

// 格式化金额
const amount = formatAmount(1234567.89); // "1,234,567.89"

// 验证银行卡号
const isValid = isValidBankCard('6222021234567890123'); // true

// 脱敏手机号
const maskedPhone = maskPhone('13800138000'); // "138****8000"

全局引入

import BankUtils from 'hxy-bank-utils';

// 使用工具函数
const amount = BankUtils.formatAmount(1234567.89);
const isValid = BankUtils.isValidBankCard('6222021234567890123');
const maskedPhone = BankUtils.maskPhone('13800138000');

功能模块

金额相关 (amount)

  • formatAmount() - 格式化金额为千分位格式
  • formatAmountToChinese() - 格式化金额为中文大写格式
  • formatAmountSimple() - 格式化金额为简化格式
  • add() - 精确加法运算
  • subtract() - 精确减法运算
  • multiply() - 精确乘法运算
  • divide() - 精确除法运算
  • isValidAmount() - 验证金额格式
  • isAmountInRange() - 验证金额范围

银行卡相关 (bankCard)

  • isValidBankCard() - 验证银行卡号格式
  • getBankInfo() - 获取银行卡对应银行信息
  • formatBankCard() - 格式化银行卡号
  • maskBankCard() - 银行卡号脱敏
  • maskBankCardFull() - 银行卡号完整脱敏

身份证相关 (idCard)

  • isValidIdCard() - 验证身份证号格式
  • parseIdCardBirthDate() - 解析身份证出生日期
  • parseIdCardGender() - 解析身份证性别
  • parseIdCardAge() - 解析身份证年龄
  • maskIdCard() - 身份证号脱敏

手机号相关 (phone)

  • isValidPhone() - 验证手机号格式
  • getPhoneCarrier() - 获取手机号运营商信息
  • formatPhone() - 格式化手机号
  • maskPhone() - 手机号脱敏

密码相关 (password)

  • validatePasswordStrength() - 验证密码强度
  • generatePassword() - 生成随机密码
  • generatePIN() - 生成PIN码
  • calculatePasswordScore() - 计算密码强度分数

时间相关 (time)

  • formatTime() - 格式化时间
  • formatRelativeTime() - 格式化相对时间
  • calculateDaysDiff() - 计算天数差
  • calculateAge() - 计算年龄
  • isWorkday() - 验证是否为工作日

字符串相关 (string)

  • capitalize() - 首字母大写
  • toCamelCase() - 驼峰命名转换
  • truncate() - 截断字符串
  • maskString() - 字符串脱敏
  • isEmpty() - 验证字符串是否为空

数字相关 (number)

  • formatNumber() - 格式化数字
  • formatPercent() - 格式化百分比
  • formatCurrency() - 格式化货币
  • isPositive() - 验证是否为正数
  • isInteger() - 验证是否为整数

验证相关 (validate)

  • validateEmail() - 验证邮箱格式
  • validatePhone() - 验证手机号格式
  • validateIdCard() - 验证身份证号格式
  • validateBankCard() - 验证银行卡号格式
  • validateName() - 验证姓名格式

加密相关 (crypto)

  • md5() - MD5哈希
  • sha1() - SHA1哈希
  • sha256() - SHA256哈希
  • base64Encode() - Base64编码
  • base64Decode() - Base64解码
  • randomString() - 生成随机字符串
  • randomUUID() - 生成随机UUID

格式化相关 (format)

  • formatCNY() - 格式化人民币
  • formatUSD() - 格式化美元
  • formatEUR() - 格式化欧元
  • formatChineseDate() - 格式化中文日期

设备检测相关 (device)

  • isMobile() - 检测是否为移动设备
  • isTablet() - 检测是否为平板设备
  • isDesktop() - 检测是否为桌面设备
  • isIOS() - 检测是否为iOS设备
  • isAndroid() - 检测是否为Android设备
  • isChrome() - 检测是否为Chrome浏览器
  • isFirefox() - 检测是否为Firefox浏览器

开发

安装依赖

npm install

构建

npm run build

测试

npm test

代码检查

npm run lint

代码格式化

npm run format

浏览器支持

  • Chrome >= 60
  • Firefox >= 60
  • Safari >= 12
  • Edge >= 79
  • IE >= 11

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!

更新日志

1.0.0

  • 初始版本发布
  • 包含银行项目常用工具函数
  • 支持按需引入和全局引入
  • 完整的TypeScript类型定义
  • 完整的单元测试覆盖