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 🙏

© 2025 – Pkg Stats / Ryan Hefner

auto-watch

v0.0.2

Published

Utilities for auto watching file trees in node.js.

Readme

auto-watch

##目的(Purpose) Utilities for auto watching file trees.

自动监视目录树中文件和目录的创建、删除、改变等等事件。当添加新目录时自动给新目录及其子目录和文件添加监视任务。

##安装(Install)

###创建方式:

###事件(Events):

  • create - 创建文件或目录时触发事件。两个参数:path,stat。path:创建文件或目录的路径;stat:fs.Stats
  • createfile - 创建文件时触发的事件。两个参数:path,stat。path:创建文件的路径;stat:fs.Stats
  • createdirectory - 创建目录时触发的事件。两个参数:path,stat。path:创建目录的路径;stat:fs.Stats
  • delete - 删除文件或目录时触发事件。两个参数:path,stat。path:删除文件或目录的路径;stat:fs.Stats
  • deletefile - 删除文件时触发的事件。两个参数:path,stat。path:删除文件的路径;stat:fs.Stats
  • deletedirectory - 删除目录时触发的事件。两个参数:path,stat。path:删除目录的路径;stat:fs.Stats
  • change - 修改文件或目录时触发事件。两个参数:path,stat。path:修改文件或目录的路径;stat:fs.Stats
  • changefile - 修改文件时触发的事件。两个参数:path,stat。path:修改文件的路径;stat:fs.Stats
  • changedirectory - 修改目录时触发的事件。两个参数:path,stat。path:修改目录的路径;stat:fs.Stats

###添加不需要监视目录的规则:

###添加事件方法:

  • watch.listeners(object) - object必须,返回scanFS对象。
  • 通过调用方法添加事件: onCreate(fn)onCreateFile(fn)onCreateDirectory(fn)onDelete(fn)onDeleteFile(fn)onDeleteDirectory(fn)onChange(fn)onChangeFile(fn)onChangeDirectory(fn)

例子(Example):

var watch = require('./watch' ).create(function(watch){

	/*watch.exclude(['*index.js']);
	 watch.exclude(/.*index.js$/);
	 watch.exclude(new RegExp(/.*index.js$/));*/

	watch.listeners({
		'create': function(path, stat){
			console.log('create:' + path, stat);
		},
		'delete': function(path, stat){
			console.log('delete:' + path, stat);
		},
		'change': function(path, stat){
			console.log('change:' + path, stat);
		}
	}).watchTree(__dirname + '/test', function(err, fileCount, dirCount){
		console.log('test: ', arguments);
	});

});

//或者

var watch = require('./watch' ).create(function(watch){

	/*watch.exclude(['*index.js']);
	 watch.exclude(/.*index.js$/);
	 watch.exclude(new RegExp(/.*index.js$/));*/

	watch.listeners({
		'createfile': function(path, stat){
			console.log('createfile:' + path, stat);
			console.log(watch.files);
		},
		'deletefile': function(path, stat){
			console.log('deletefile:' + path, stat);
			console.log(watch.files);
		},
		'changefile': function(path, stat){
			console.log('changefile:' + path, stat);
			console.log(watch.files);
		},
		'createdirectory': function(path, stat){
			console.log('createdirectory:' + path, stat);
			console.log(watch.files);
		},
		'deletedirectory': function(path, stat){
			console.log('deletedirectory:' + path, stat);
			console.log(watch.files);
		},
		'changedirectory': function(path, stat){
			console.log('changedirectory:' + path, stat);
			console.log(watch.files);
		}
	} ).watchTree(__dirname + '/test', function(err, fileCount, dirCount){
		console.log('test: ', arguments);
	});

});