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 🙏

© 2024 – Pkg Stats / Ryan Hefner

claus-core

v1.0.8

Published

js公共方法的集合

Downloads

3

Readme

claus-core

介绍

js公共方法的集合

使用示例

安装

yarn add claus-core

使用

import { getToday } from 'claus-core'
console.log(getToday()) // 2021年06月24号 星期四

各方法的参数及返回值

1.formatTime(timestamp[, format])

将时间戳转为时间字符串,format可不传默认'yyyy-MM-dd HH:mm:ss'

console.log(formatTime(new Date(),'yyyy-MM-dd')) // 2021-11-18
console.log(formatTime(new Date(),'yyyy-MM-dd HH:mm:ss')) // 2021-11-18 17:25:14
console.log(formatTime(new Date())) // 2021-11-18 17:25:14
console.log(formatTime(new Date(),'yyyy/MM/dd HH:mm')) // 2021/11/18 17:25

2.getToday()

获取今天的年月日星期 如 2021年06月24号 星期四

console.log(getToday()) // 2021年06月24号 星期四

3.formatMoney(money)

传入金额数字转为千分形式

console.log(formatMoney(1234)) // 1,234.00

4.formatPhoneNumber(phone)

手机号脱敏

console.log(formatPhoneNumber('17612348888')) // 176****8888

5.obj2Param(obj)

接收一个对象,转为key1=value1&key2=value2的参数字符串拼接

console.log(obj2Param({name:'zhangsan',age:18})) // name=zhangsan&age=18

6.validateIdCard(idCard)

校验身份证号是否正确

validateIdCard('141122199901011234') // false

7.validatePassport(pass)

校验护照(港澳通行证)是否正确

validatePassport('141122199901011234') // false

8.formatBankCard(bankCard)

银行卡号四位分割

console.log(formatBankCard('6214830194484993')) // 6214 8301 9448 4993 

参与贡献

  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request