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

zonghe-lmraaa

v1.0.0

Published

//1.封装函数 const copyFn = (add, del) => { //2.判断起始文件是否存在 如果不存在则不能复制 if (!fs.existsSync(add)) { throw new Error("源文件不存在" + add); return; } //3.判断目标文件是否存在 如果存在则不能复制 if (fs.existsSync(del)) { throw new Error

Downloads

7

Readme

#这是一个复制和删除的综合案例!!!

//1.封装函数 const copyFn = (add, del) => { //2.判断起始文件是否存在 如果不存在则不能复制 if (!fs.existsSync(add)) { throw new Error("源文件不存在" + add); return; } //3.判断目标文件是否存在 如果存在则不能复制 if (fs.existsSync(del)) { throw new Error("目标文件已存在" + del); return; } //4.创建目标文件 fs.mkdirSync(del); //5.遍历起始文件下的所有子目录 fs.readdirSync(add).forEach(item => { //6.拼接地址 如果不加父目录的话默认在当前目录查找 所以就查找不到 let addMidd = add + "/" + item; let delMidd = del + "/" + item; //7.判断起始文件是否是文件 if (fs.statSync(addMidd).isFile()) { //8.如果是则删除 fs.copyFileSync(addMidd, delMidd); } else { //9.如果不是继续调用函数复制子目录下的子文件 copyFn(addMidd, delMidd) } }) } copyFn("swiper", "aaa");

const del = (pathDir) => { //2.查看当前目录的所有子目录

//3.遍历所有子目录
fs.readdirSync(pathDir).forEach(item => {
        //4.拼接地址   如果不加父目录的话默认在当前目录查找 所以就查找不到
        let src = pathDir + "/" + item;
        //5.读取文件夹信息
        //6.判断是否是文件
        if (fs.statSync(src).isFile()) {
            //7.删除文件
            fs.unlinkSync(src);
        } else {
            //8.调用递归继续删除子目录下的文件
            del(src);
        }
    })
    //9.删除目录
fs.rmdirSync(pathDir);

}

del("ttt");