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

foxutil

v1.1.2

Published

npm package demo

Downloads

31

Readme

GIT

API

import {foxRegexp,foxUtil} from 'foxutil'

分成两个部分

foxRegexp

正则表达式,直接调用即可

chinese

返回一个匹配中文汉字的表达式

phone

返回一个匹配手机号的表达式

tel

返回一个匹配座机号的表达式

email

返回一个匹配邮箱的表达式

password

返回一个以字母开头,长度在6~18之间,只能包含字母、数字和下划线表达式

strongPassword

返回一个强密码的表达式

yi_identity

返回一个匹配一代身份证的表达式

er_identity

返回一个匹配二代身份证的表达式

phoneIdentity

返回一个匹配手机机身ID的表达式

annotation

返回一个匹配html标签的表达式

username

返回一个匹配字母开头,允许5-16字节,允许字母数字下划线的表达式

getImg

返回一个匹配img标签的表达式

getURL

返回一个匹配网页URL参数的表达式

getQQ

返回一个匹配QQ号的正则表达式

getTrain

返回一个匹配火车车次的正则表达式

getImg

匹配图片后缀的表达式

foxUtil

一些比较实用工具函数

colorConVersion

将255进制的颜色转换为16进制颜色并使用变量接收参数为3个数字类型

const color = foxUtil.colorConVersion(255,255,255)    // #ffffff
dayOfYear

查看当前日期是今年的那一年并使用变量接收参数是new Date()

const color = foxUtil.dayOfYear(new Date())   // 73
dayCountDiffer

计算日期的时间差,第一个和第二个时间的距离是多远

const day = foxUtil.dayCountDiffer(new Date("2020-10-10"),new Date("2021-10-10"))     //365
randomColor

随机生成一个十六进制的颜色 const color = randomColor() // #45652f

const color = foxUtil.randomColor()   // #45652f
arrUniq

讲一个数组去除重复项,对象、NaN、函数都可去重 参数为一个拥有重复项的数组

const uniq = foxUtil.arrUniq(arr)
upsetArray

将一个排好序的数组打乱顺序 参数为一个排好序的数组

gotoTop

点击的时候调用 返回到当前页面的顶部 没有参数

isEmpty

判断一个数组是否为空,如果为空则返回false不为空则返回true 参数为数组

isNullObject

判断一个对象是否为空,如果为空则返回false不为空则返回true 参数为对象

getUrl

获取当前页面URL路径传递过来的参数 ,没有参数

deepCopy

深度拷贝一个对象并返回一个新的对象

deepClone

深度拷贝一个对象但不会拷贝set和map结构

average

求数字的平均值 const aver = average(1,2,3,4) // 2.5

debounce

防抖函数,第一个参数为函数,第二个是延迟执行秒数,第三个参数是布尔值true立即执行,false延迟执行

throttle

节流函数,第一个参数为函数,第二个是延迟执行秒数,第三个参数是一个number类型 1是使用时间戳,2是使用时间函数

intersection

查找两个数组重复的元素,并返回一个新的数组

difference

查找两个数组不重复的元素,并返回一个新的数组

lazy 懒加载

接收四个参数,两个必选参数,两个可选参数

  • 第一个参数是列表元素的父元素,或者是列表数组元素
  • 第二个参数是一个回调函数,接收一个参数,参数是一个数组对象,对象属性:
    • target 被观察的dom元素
    • time 可见性发生变化的时间,是一个高精度时间戳
    • iview 是否可见
    • visible 目标元素的可见比例,完全可见为1,完全不可见为0
    • targetDOM 目标元素矩形区域信息
    • iviewTarget 目标元素与跟元素的交叉区域的信息
  • 第三个参数是bool值,是否关闭监听
  • 第四个参数是一个对象可选参数,提供三个属性
    • root 指定的跟元素
    • rootMargin 根元素的外边距
    • threshold 根元素和列表元素的交集,可以是数组也可以是一个number
lazy(document.querySelector('ul'),(list)=>{
    //list [{target,time,iview,visible,targetDOM,iviewTarget}]
})
lazy(document.querySelectorAll('li'),(list)=>{
  //list [{target,time,iview,visible,targetDOM,iviewTarget}]
},false,{
    root:null,
    rootMargin:'0px',
    threshold:0
})
getItem

两个参数

  • 第一个数组对象,
  • 第二个是回调函数 返回当前的查找到的对象
  const arr = [{a:1,b:[{a:3}]},{a:2}]
  getItem(arr, item => item.a === 3) // {a:3}
time

一个参数

  • 一个日期字符串
  • 返回过滤好的日期格式
  time('2022-03-16T11:03:28.000+0800')   // 2022-03-16 11:03:28
mergeSort 归并排序
console.log(mergeSort([1,3,4,6,23,45,5,7,2,234,444,565,333]))
//[1, 2, 3, 4, 5, 6 ,7, 23, 45, 234, 333, 444,565]