fs-recurse

2019-07-14 admin

fs-recurse是什么

什么是fs-recurse,Walk through directories asynchronously with callback on each file/folder

fs-recurse使用教程帮助文档

fs-recurse

Walk through directories asynchronously, with callback on each file/folder and ignore option

Usage

npm install fs-recurse

Signature

recurse(String path, Function callback, Function done, Array ignore);

Arguments

  1. path String

    Path in which you want to recurse

  2. callback Function

    Receives four arguments :

    • path String current path
    • filename String current file name
    • type String file extension or ‘folder’
    • cursor Function call this function after executing any async operation on current file
  3. done Function

    Invoked when recursion is done

  4. ignore Array

    Anymatch compatible filters…

Example

var recurse = require('./fs-recurse');

recurse('test', function(path, filename, type, cursor){
	fs.stat(path + '/' + file, function(err, stats){
		cursor();
		// Do async operation on files ...
	});
}, function(){
	console.log('Done!');
}, [/\.txt$/, 'index.html']);
// *.txt and index.html will be ignored

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-69691.html

文章标题:fs-recurse

回到顶部