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 🙏

© 2025 – Pkg Stats / Ryan Hefner

patrick-utils

v1.0.0

Published

#### 初始化项目

Readme

发布一个 npm 工具包

初始化项目

winpty vue.cmd create patrick-utils 选择 default 配置

新建一个 utils 目录,下面 index.js

//index.js
function sum(a, b) {
  return a + b;
}
export { sum };

修改 packge.json 配置

{
"name": "patrick-utils",
  "private": false,
  "version": "1.0.0",
  "license": "MIT",
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint",
    "package": "vue-cli-service build --target lib --name baseComFuncs     ./src/utils/index.js"
  },
  "main": "/dist/baseComFuncs.umd.min.jss"
}

配置说明

  1. name npm 的包名,发布成功后可以在 npm 官网 上搜索

  2. private->false 设置为公开

  3. version 版本号 每次发布版本号必须更新

  4. 添加 license MIT

  5. scripts 中添加编译项 "package": "vue-cli-service build --target lib --name baseComFuncs ./src/utils/index.js"

    --targer lib 代表打包成库文件

    --name index 打包生成文件的名称

    ./src/utils/index.js 代码的入口文件地址

  6. 添加 main: "/dist/baseComFuncs.umd.min.js" 入口文件

npm 包发布流程

  1. 查看当前的 npm 源 npm config get registry npmjs.com
  2. npm login 然后输入账号密码 登录
  3. npm publish 发布,成功后命令行会有提示信息
  4. npm unpublish 撤回 npm 包

使用方法

使用说明

  1. npm install patrick-utils
  2. import * as utils from 'patrick-utils'
  3. 开始使用 utils 中各种方法
  4. 更新方法 npm update patrick-utils

本地开发调试说明

  1. npm 包项目目录下执行 npm link
  2. 需要使用 npm 包的项目下执行 npm link patrick-utils
  3. 以下同使用说明步骤 2 及以下

目前的提供的方法

  • testPhone 校验是否为合法手机号
  • testIdCard 校验是否为合法身份证号
  • testEmail 校验是否为合法邮箱
  • testCnName 校验是否为中文
  • testEnName 校验是否为英文
  • testSocialCode 校验是否为合法统一社会信用代码
  • translateTime 转换时间为 YYYY-MM-DD HH:mm:ss 格式

其他

修改 readme.md ,描述包的安装方法以及使用方法