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 🙏

© 2024 – Pkg Stats / Ryan Hefner

DirWatcher

v1.0.0

Published

A simple tool for you to watch a directory

Downloads

1

Readme

##DirWatcher 监视你的目录

监控指定目录中文件的增加,删除,修改,子目录的增加,删除等

安装 npm install DirWatcher

USAGE 使用

var dw = require( './DirWatcher' );
dw.watchDir( 'path', function( ifDir, path, cur, pre ){
	
	// ifDir 是否为目录
	// path 文件或者目录的路径
	// type 变更类型 'modify' 'remove' 'add'
	// cur 当文件变更时,包含当前文件的信息
	// pre 当文件变更时,包含变更前文件信息	
});

###API

####watchDir( path, next )

  • path: 目录的路径
  • next: 回调,包含五个个参数ifDir, path, type, cur, pre

####readDir( path, next )

对制定目录进行递归便利,对每一个有效路径执行一次回调

  • path: 目录的路径
  • next: 回调,为目录下的每一个文件或者子目录执行一次回调。回调包含
    • err
    • path: 路径
    • ifDir: 是否为目录

###Exception 配置例外

可以通过在需要添加例外的目录下添加名为.nowatch文件,来添加例外. 例外添加的规则:

  • 每一行为一条例外
  • 一行中若出现空格,空格后的内容将被忽略
  • 使用#进行注释
  • /结尾的例外将被视为目录,否则为具体的文件名

###存在的问题

  • 当watch的文件和目录过多,将报错EMFILE的错误
  • 当一个路径被删除,然后再新建同名路径时将无法重新watch该路径(对于目录应该问题不大,但是对于文件,暂时无法解决) hah