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

@zh-or/lib

v1.0.6

Published

libs

Downloads

127

Readme

github

  1. 地址

request

封装的xhr

notify

异步信号

工具类包含方法

  1. getTextWidth(text, fs) 获取text文字的实际宽度, fs表示字体大小
  2. getId(prefix) 获取不重复的自增id默认前缀为id_[num]
  3. isIE() 当前是否ie浏览器
  4. sortArray(type, arr, column) 数字或者中文数组排序
    • type=asc|desc类型
    • arr数组
    • column 排序使用的字段支持多层级, 如user.age
  5. cookie(key, value, options)读取或写入cookie
    • key 读取或写入的key
    • value 写入的值, 如果不传此参数表示读取
    • options => {time: [time], domain: [path]}写入cookie的配置
  6. randomNum(minNum, maxNum) 获取随机数
  7. toTimeStr(time) 时间戳转换为xx 时 xx 分 xx 秒的格式
  8. parseDate(date) 解析dateDate对象, 支持yyyy-MM-dd hh:mm:ss和时间戳或者Date.parse()支持的标准格式
  9. formatDate(date, formatStr)
    • date 同上面parseDate参数
    • formatStr格式字符串, 默认为:yyyy-MM-dd hh:mm:ss
  10. getDiffDay(type)获取时间间隔返回数组[start, end]
    • type=today今天
    • type=yesterday昨天
    • type=week本周
    • type=lastWeek上周
    • type=month本月
    • type=near30最近30天
    • type=[数字]返回今天到[今天-数字]的范围
  11. saveFile(url, saveName)保存url到文件
  12. selectFile(cb)弹出文件选择框
  13. selectDir(cb)弹出目录选择框
  14. reSizeImg(file, size) 压缩图片到指定尺寸size={width, height}
  15. getObjectURL(file)文件转base64
  16. setLocal(key, val) = localStorage.setItem
  17. getLocal(key, def) = localStorage.getItem
  18. removeLocal(key) = localStorage.removeItem
  19. deepClone(obj) 深度克隆一个obj
  20. clear(data) 清空data的值
  21. clone(from, to, lvl)根据to对象包含的字段来复制from的值
  22. ObjHas(obj, key)检查对象是否存在指定字段, 支持多级key=user.info.name
  23. ObjGet(obj, key)从对象获取指定字段的值, 支持多级key=user.info.name
  24. attr(arr, obj)arr数组的成员添加obj的字段和值
  25. arrToString(arr, field)提取数组成员对象的指定字段并join(',')连接起来
  26. getQueryString(name)获取location.hrefquery参数的值
  27. trim(str)正则删除字符串首尾空
  28. HTMLdecode(str)HTML标签解码
  29. HTMLencode(str)HTML标签编码
  30. formatFileSize(len)把长度转换为byte,KB,MB
  31. copyString(str)复制字符串到剪切板
  32. tween(type, from, to, time, callback)缓动函数
    • type类型, 支持[linear,easeIn,strongEaseIn,strongEaseOut,sineaseIn,sineaseOut]
    • from number|Array
    • to number|Array
    • time 动画时长
    • callback 回调函数
  33. showToast(msg, timeout) 弹出toast 弹窗
  34. showWait(msg) 弹出加载框
  35. hideWait() 隐藏加载框