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

zhjs

v0.1.10

Published

使用方法

Readme

前端工具集

文件选择器

使用方法

  const selector = zhjs.useFileSelector({
    multiple: true,
    // 参考 https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/Input/file#accept
    accept: '.jpg,.png'
  })
  selector.openFileDialog()
    .then(files => {
      // TODO: use files here
    })

数组转树

使用方法

  const arr = [
    { id: 10, pid: 9 },
    { id: 9, pid: 5 },
    { id: 8, pid: 5 },
    { id: 7, pid: 2 },
    { id: 6, pid: 1 },
    { id: 5, pid: 1 },
    { id: 4, pid: 1 },
    { id: 3, pid: 0 },
    { id: 2, pid: 0 },
    { id: 1, pid: 0 },
    { id: 0, pid: null }
  ]
  // output: 树形结构
  const tree = zhjs.arrayToTree(arr, { parentProperty: 'pid' })
  // getRootNode
  console.log(tree.getRoot())
  // getLevelChildren
  console.log(tree.getLevel(1))
  // output 1 2 3
  console.log(tree.find(9))
  // output { id: 9, pid: 5 }
  console.log(tree.sort((a, b) => a.id - b.id))
  // sort by node.id, from low to height
  console.log(tree.getRoot().flat())
  // return flat tree nodes array

TODO:

  • Tree增加update方法 传入数组对整棵树进行动态更新
  • 移植ahook.useRequest部分功能

changelog

  • 0.1.4 修复文件选择器初始化时配置项不生效的问题
  • 0.1.5 调整arratToTree返回类型为Tree 增加Tree类型的公开方法getRootgetLevel
  • 0.1.6 修复 Tree.getLevel无法获取0层节点 的问题 增加Tree类型的公开方法find用于获取给定customID的节点
  • 0.1.7 增加Tree.sort公开方法,对每个children进行排序,参考Array.sort 增加Tree.getArray方法,获取树的源数组
  • 0.1.8 增加TreeNode.flat方法,返回打平后的TreeNode数组 修复Tree根节点如果在给定的源数组中存在时,不能正确往TreeNode.data中插入数据的问
  • 0.1.9 增加Tree模块的单元测试 增加Tasker类 增加FileSelector.dispose手动释放内存的方法 修复FileSelector类取消弹窗事件无法触发的问题
  • 0.1.10
    修复FileSelector.openFileDialog返回的文件对象延迟之后被释放的问题