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

yann-fs

v2.0.3

Published

Enhanced fs-extra with better error handling

Readme

yann-fs

一个增强版的 fs-extra 工具库,提供更优雅的错误处理方式和完整的 TypeScript 类型支持。

特性

  • 完整封装 fs-extra 的异步方法
  • 统一的错误处理返回格式 [error, data]
  • 支持全局错误处理配置
  • 完整的 TypeScript 类型支持
  • 同时支持 ESM 和 CommonJS
  • 支持 Promise 和 async/await

安装

npm i yann-fs -S

快速上手

mjs 模式

import fs, { remove } from 'yann-fs';

const [err, data] = await fs.remove(path);
// or
const [err, data] = await remove(path);

cjs 模式

const fs = require('yann-fs);

const [err, data] = await fs.remove(path);

API 文档

错误处理

  • fsConfig: 全局错误处理配置对象
    • errHandler: 设置全局错误处理函数
  • fsTo<T>: 统一的错误处理包装函数,将 [error, data] 转换为单一返回值

文件操作

  • copy(src: string, dest: string, options?: CopyOptions): 复制文件或目录
  • move(src: string, dest: string, options?: MoveOptions): 移动文件或目录
  • remove(path: string): 删除文��或目录
  • emptyDir(path: string): 清空目录但保留目录本身
  • ensureFile(path: string): 确保文件存在,如果不存在则创建
  • createFile(file: string): 创建新文件
  • readFile(path: string, options?: ReadOptions): 读取文件内容
  • writeFile(file: string, data: any, options?: WriteFileOptions): 写入文件内容
  • appendFile(path: string, data: any, options?: WriteFileOptions): 追加内容到文件
  • truncate(path: PathLike, len?: number): 截断文件到指定长度
  • unlink(path: PathLike): 删除文件链接

JSON 操作

  • readJson<T>(path: string, options?: ReadOptions): 读取 JSON 文件
  • writeJson(file: string, data: any, options?: WriteOptions): 写入 JSON 文件
  • outputJson(file: string, data: any, options?: WriteOptions): 写入 JSON 文件,自动创建目录

目录操作

  • ensureDir(path: string, options?: EnsureOptions): 确保目录存在,如果不存在则创建
  • mkdir(dir: string, options?: EnsureOptions): 创建目录
  • mkdirs(dir: string, options?: EnsureOptions): 递归创建目录
  • mkdtemp(prefix: string, options?: ObjectEncodingOptions): 创建临时目录
  • readdir(path: string, options?): 读取目录内容
  • rmdir(path: string): 删除目录

链接操作

  • ensureLink(src: string, dest: string): 确保硬链接存��,如果不存在则创建
  • ensureSymlink(src: string, dest: string): 确保符号链接存在,如果不存在则创建
  • createLink(src: string, dest: string): 创建硬链接
  • createSymlink(src: string, dest: string): 创建符号链接

文件信息

  • stat(path: PathLike): 获取文件状态信息
  • lstat(path: PathLike): 获取文件状态信息(不解析符号链接)
  • pathExists(path: string): 检查路径是否存在
  • isDir(path: PathLike, errHandler?): 检查路径是否为目录
  • exists(path: string): 检查文件是否存在(不推荐使用)

权限操作

  • chmod(path: PathLike, mode: Mode): 修改文件权限
  • chown(path: PathLike, uid: number, gid: number): 修改文件所有者
  • access(path: PathLike, mode?: number): 检查文件访问权限

时间戳操作

  • utimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date): 修改文件访问和修改时间

文件监听

  • watch: 监听文件或目录变化