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

easy-tool

v0.0.2

Published

js工具库

Readme

easy-tool

WalkForest

用于遍历树结构的对象
// 直接树结构对象
interface MockTree {
  children?: MockTree[]
  value: string
  label?: string
}
// 联合类型的树结构对象
interface BaseTree {
  value: string
  label?: string
}

interface HasChildTree extends BaseTree {
  children: UnionTree[]
}

interface HasChildOtherTree extends BaseTree {
  other: UnionTree[]
}

interface NotChildTree extends BaseTree {}

type UnionTree = NotChildTree | HasChildTree | HasChildOtherTree
用法
import { WalkForest } from 'easy-tool'

interface MockTree {
  children?: MockTree[]
  value: string
  label?: string
}
const forest: MockTree[] = []

// 第一个参数:要遍历的树集合
// 第二个参数:下一级的key
// 第三个参数:值的key
// 第四个参数:遍历的顺序(选填,默认:DLR)
const walkForest = new WalkForest(forest, 'children', 'value')

walkForest.each((node, path) => {
  // todo
})
设置遍历顺序
walkForest.setOrder('DLR')
// DLR: 根->左->右
// DRL: 根->右->左
// LRD: 左->右->根
// RLD: 右->左->根
API
walkForest
  .setOrder // 设置遍历顺序
  .each // 遍历所有的节点,若返回true则终止便利
  .filterWithPath // 过滤返回true的节点和节点对应的路径列表
  .filter // 过滤返回true的节点列表
  .findWithPath // 返回第一个返回true的节点和其对应的路径,找到后终止遍历
  .find // 返回第一个返回true的节点,找到后终止遍历
  .some // 有一个为true,则结果为true(遇到true终止遍历)
  .every // 有一个为false,则结果为false(遇到false终止遍历)
  .count // 返回节点个数
  .values // 返回所有value
  .paths // 返回所有的path
  .flatWithPath // 将树转为列表,每项是节点和其对应的路径
  .flat // 将树转为列表,每项是节点

acute

一套响应式API
用法
import { useCell, brain } from 'easy-tool'

const state = useCell(10) // 定义一个响应式数据

// 在watch中使用响应式数据
// 定义时会调用一次传入watch的函数
// 若state的数据发生变化,则会自动重新执行传入watch的函数
brain.watch(() => {
  console.log(state.v) // 10
})

// 在compute中使用相应式数据
// 定义时会调用一次传入compute的函数,并且会返回函数的返回值
// 当state的数据发生变化时,会自动重新执行闯入compute的函数,并且自动更新返回值数据
// 返回值数据也是一个响应式数据(只读)
const computeState = brain.compute(() => {
  return state.v * 10
}) // computeState.v === 100