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

@anyfu/dict-core

v0.0.1

Published

`@anyfu/dict-core`是一个用于字典数据请求合并、缓存、重试、降级、LRU 管理 的高性能工具,适用于后台配置字典、状态枚举、选项列表等场景。

Readme

@anyfu/dict-core

@anyfu/dict-core是一个用于字典数据请求合并、缓存、重试、降级、LRU 管理 的高性能工具,适用于后台配置字典、状态枚举、选项列表等场景。

同时, 也提供了一些相应的工具函数, 如:transformToOptionsgetDictItemsgetDictLabelgetOptionLabellistToTreetreeToArray

核心能力

| 能力 | 说明 | |---------------|----------------------------------------------------| | 🚀 请求合并 | mergeDelay 窗口内的多个字典请求自动合并为一次 HTTP | | 🧠 LRU 缓存 | 支持最大缓存条数 + 最近最少使用淘汰 | | ⏳ 过期控制 | cacheTime 控制缓存过期时间 | | 🔁 SWR 模式 | 过期数据先返回旧值,再后台刷新 | | 🧯 降级容错 | 请求失败可自动回退到缓存数据 | | 🔄 自动重试 | 支持失败重试与自定义重试条件 | | ✋ 可取消请求 | 支持取消未发出请求 + 进行中请求 | | 🔌 拦截器 | 支持请求和响应拦截 | | 🧩 可定制解析 | 可自定义响应结构和字典解析逻辑 |

工具函数

| 函数 | 作用 | |----------------|------------------------------------------------------| | transformToOptions | 将 枚举 / 普通对象 转换为 UI 组件可用的 options 结构 | | getDictItems | 获取字典数据列表,支持 禁用过滤、树形结构转换 | | getDictLabel | 根据字典值获取显示 label | | getOptionLabel | 根据 options 列表获取 label(UI 场景常用) | | listToTree | 扁平列表 → 树结构 | | treeToArray | 树结构 → 扁平数组,自动添加层级与父子关系 |