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

@netjoy/common-utils

v1.0.1

Published

基础 utils 集合,快捷校验数字、手机、邮箱等,还包含获取页面参数、域名、节流、防抖、首字母大写、手机号加星等函数方法

Readme

一、使用

  • 安装

    $ npm i @netjoy/common-utils
  • 引入

    // 方式一
    import * as Utils from "@netjoy/common-utils";
    
    // 方式二
    import { xxx, xxx, xxx } from "@netjoy/common-utils";
  • 函数支持

    // ============================================================================================
    // 关于 校验
    // ============================================================================================
    
    /**
    * @description: 字符串是否首字母大写
    * @param {*} value 字符串
    * @return {*} true/false
    */
    export function IsTitleCase(value: string): boolean;
    
    /**
    * @description: 手机号码校验
    * @param {*} value 手机号码
    * @return {*} true/false
    */
    export function IsPhoneNumber(value: string): boolean;
    
    /**
    * @description: 邮箱校验
    * @param {*} value 邮箱
    * @return {*} true/false
    */
    export function IsEmail(value: string): boolean;
    
    /**
    * @description: 身份证号码校验
    * @param {*} value 身份证号码
    * @return {*} true/false
    */
    export function IsIdentityCode(value: string): boolean;
    
    /**
    * @description: 银行卡号校验
    * @param {*} value 银行卡号
    * @return {*} true/false
    */
    export function IsBankAccount(value: string): boolean;
    
    /**
    * @description: 正数校验(支持 1-2 位小数)
    * @param {*} value 数字
    * @return {*} true/false
    */
    export function IsPositiveFloat(value: string): boolean;
    
    /**
    * @description: 正数校验
    * @param {*} value 数字
    * @return {*} true/false
    */
    export function IsPositiveNumber(value: string): boolean;
    
    /**
    * @description: 正整数校验
    * @param {*} value 数字
    * @return {*} true/false
    */
    export function IsPositiveInteger(value: string): boolean;
    
    /**
    * @description: 非零正整数校验
    * @param {*} value 数字
    * @return {*} true/false
    */
    export function IsPositiveIntegerPro(value: string): boolean;
    
    /**
    * @description: 非零负数校验
    * @param {*} value 数字
    * @return {*} true/false
    */
    export function IsNegativeNumber(value: string): boolean;
    
    /**
    * @description: 非零负数校验(支持 1-2 位小数)
    * @param {*} value 数字
    * @return {*} true/false
    */
    export function IsNegativeNumberPro(value: string): boolean;
    
    /**
    * @description: 负整数校验
    * @param {*} value 数字
    * @return {*} true/false
    */
    export function IsNegativeInteger(value: string): boolean;
    
    /**
    * @description: 非零负整数校验
    * @param {*} value 数字
    * @return {*} true/false
    */
    export function IsNegativeIntegerPro(value: string): boolean;
    
    // ============================================================================================
    // 关于 数字
    // ============================================================================================
    
    /**
    * @description: 取两个数之间的随机数
    * @param {*} min 最小范围
    * @param {*} max 最大范围
    * @return {*} 随机数
    */
    export function RandomInt(min: number, max: number): number;
    
    // ============================================================================================
    // 关于 字符串
    // ============================================================================================
    
    /**
    * @description: 字符串首字母大写
    * @param {*} value 字符串
    * @return {*} 首字母大写的字符串
    */
    export function TitleCase(value: string): string;
    
    /**
    * @description: 手机号中间部分变星号
    * @param {*} value 手机号
    * @return {*} 处理后的手机号
    */
    export function PhoneEncryption(value: string): string;
    
    // ============================================================================================
    // 关于 Window
    // ============================================================================================
    
    /**
    * @description: 获取当前域名地址
    * @param {*} path 额外在域名地址后面追加的路径
    * @return {*} 完整的当前域名地址
    */
    export function DomainName(path?: string): string;
    
    /**
    * @description: 获取页面链接参数,解析链接附带的参数,默认为当前页面链接
    * @param {*} url 指定解析链接,默认为当前页面链接
    * @return {*} 参数对象
    */
    export function GetQueryAll(url?: string): {};
    
    /**
    * @description: 获取页面链接指定参数,解析链接附带的参数,默认为当前页面链接
    * @param {*} key 指定参数key
    * @param {*} url 指定解析链接,默认为当前页面链接
    * @return {*} 参数对象
    */
    export function GetQuery(key: string, url?: string): any;
    
    /**
    * @description: 获取 input 光标位置
    * @param {*} element 输入框标签
    * @return {*} 光标位置
    */
    export function InputPosition(element: any): number;
    
    /**
    * @description: 触发 window.resize 事件
    */
    export function TriggerWindowResizeEvent(): void;
    
    /**
    * @description: 节流函数
    * @param {*} fn 回调
    * @param {*} delay 延迟时长 s,默认 500
    */
    export function Throttle(fn: Function, delay: number): void;
    
    /**
    * @description: 防抖函数
    * @param {*} fn 回调
    * @param {*} delay 延迟时长 s,默认 500
    */
    export function Debounce(fn: Function, delay: number): void;
    
    // ============================================================================================
    // 关于 JSON
    // ============================================================================================
    
    /** 文档:https://blog.csdn.net/zz00008888/article/details/123236599
    * @description: 通过 key 规则快捷获取 JSON 数据中的值
    * @param {*} json 对象
    * @param {*} key Key规则
    * @return {*}
    */
    export function Value(json: { [key: any]: any }, key: any): any;
    
    // ============================================================================================
    // 关于 文件
    // ============================================================================================
    
    /**
    * @description: 获取文件后缀
    * @param {*} path 文件路径
    * @return {*} 文件后缀
    */
    export function FileExtension(path: string): string;