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

fs.io

v1.0.1

Published

fs.io for nodejs

Downloads

14

Readme

fs.io

fs.io 提供基于Promise(Q Promise)的文件、目录操作类库

api参考.net Framework System.IO命名空间下的

http://msdn.microsoft.com/en-us/library/System.IO(v=vs.110).aspx

File FileInfoDirectory

使用方法

	var file = require('fs.io').file;
	var dict = require('fs.io').directory;
	file.copy(from,to)
		.done(function(){})
		.fail(function(){});
	...

file

file.copy(src, dest, isOverride)

src 源路径

dest 目标路径

isOverride 是否覆盖目标文件

** 该api,使用ncp库进行复制 **

file.delete(path)

path 文件路径

file.isExists(path)

path 文件路径

promise在done函数从参数返回是否存在

	file.isExists("d:/saa.txt").done(function(exists){
		if(exists){

		}
	})

file.move(src, dest)

src 源路径 dest 目标路径

file.getLastAccessTime(path)

获取最后访问时间

file.getLastModifyTime(path)

获取文件最后修改时间

file.getCreateTime(path)

获取文件创建时间

file.read(path)

注意 该函数返回值Stream.Readable对象

file.readAllText(path)

读取文件的所有内容

file.write(path)

注意 该函数返回Stream.Wriable对象

file.writeAllText(path, text)

path 文件路径 text 写入文件内容

file.appendText(path, text)

往文件结尾写入文本,如果文件不存在,则创建文件

directory

directory.createDirectory(path)

根据提供路径创建目录结构,路径中如果有任何目录不存在,则创建相应的目录

path 可为相对路径或绝对路径

相对路径则基于当前工作目录创建子目录

directory.delete(path, recursive)

删除文件目录,删非空目录时,recursive为true

directory.isExists(path)

目录是否存在,在resolve函数中,返回目录是否存在

directory.move(srcDir, destDir, override)

移动源目录到指定路径, overrid 可选,为true时覆盖目标路径内容

该函数封装fs-extra类库的move函数

directory.isDirectory(path)

指定路径是否为目录

directory.getDirectories(path, pattern)

pattern 目录搜索模式,支持 glob搜索方式,可选项,默认返回根目录下的第一级子目录,即 pattern = "*"

	directory.getDirectories("tmp/","**/*");//返回所有子目录
	directory.getDirectories("tmp/","**/abc*");//返回abc开头的所有子目录

directory.getFiles(path, pattern)

获取文件夹下所有文件路径,返回所有符合条件的文件地址

pattern 文件搜索模式,默认为 **/*.*,即返回所有文件

	directory.getFiles("path");//返回所有文件
	directory.getFiles("path","*.js");//返回根目录的js文件
	directory.getFiles("path","**/*.js");//返会目录下的所有js文件

FileInfo

FileInfo 包含以下属性

  • fullName 文件路径
  • name 文件名
  • extension 文件扩展名
  • directoryName 目录名
  • isStatReady stats通过异步获取,此属性标示stats是否请求完毕
  • createTime 文件创建时间
  • lastAccessTime 文件最后访问时间
  • lastModifyTime 文件修改时间
  • length 文件大小

类函数

  • isExists() 文件是否存在
  • copyTo(destPath) 文件拷贝
  • moveTo(destPath) 文件转移
  • openRead() 以Readable流形式打开
  • openText() 读取文件内容
  • openWrite() 以Writeable流形式打开
  • writeAllText(text) 写入文本
  • appendText(text) 附加文本
  • delete() 文件删除