xfs
extends fs module, easy way to manipulate file system, support both sync functions and async functions
Last updated 6 years ago by fish .
Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install xfs 
SYNC missed versions from official npm registry.

xfs

xfs is a module extends build-in fs module, let file manipulate easily

Build Status

xfs extends the following functions :

async functions

  • mkdir(path,cb) make directories and their contents recursively
  • rmdir(path,cb) remove directories and their contents recursively
  • rename(src,dest,cb) rename file across two different devices
  • walk(dir, expr, each, done); walk through dir, each file will pass to each() , when walk done, done() called
// walk traverse through files in the dir one by one
// get only js files in dir
fs.walk(dir, /\.js$/, function (err, file, done) {
  // your code here

  // in the end , must call done()
  done();
}, function (err) {
  // your code
});

// function walk() can also accept an `function type` expr
fs.walk(dir, function (fpath) {
  // return bool, true means accept, false means ignore
  return true
}, function (err, file, done) {

}, function (err) {

});

// or you can save the done function

fs.walk(dir, /\.js$/, function (err, file){
  // your code here
});

sync functions

  • rm(path)
  • mkdir(path)
  • save(path, data[, options|encoding])
var sync = xfs.sync();
// shell > rm -r path
sync.rm(path);
// shell > mkdir -p path
sync.mkdir(path);
// save file auto create dir if not exist
// node >= v0.10.0
sync.save(path, data, option); // when node >= v0.10.0, the last param is option
sync.save(path, data, encoding); // when node < v0.10.0, the last param is encoding

... to be contine

symlink file, rm will failed

License

MIT

Current Tags

  • 0.2.6                                ...           latest (6 years ago)

17 Versions

  • 0.2.6                                ...           6 years ago
  • 0.2.5                                ...           6 years ago
  • 0.2.4                                ...           7 years ago
  • 0.2.3                                ...           7 years ago
  • 0.2.2                                ...           7 years ago
  • 0.2.1                                ...           9 years ago
  • 0.2.0                                ...           9 years ago
  • 0.1.10                                ...           10 years ago
  • 0.1.9                                ...           11 years ago
  • 0.1.8                                ...           11 years ago
  • 0.1.7                                ...           11 years ago
  • 0.1.6                                ...           11 years ago
  • 0.1.4                                ...           11 years ago
  • 0.1.3                                ...           12 years ago
  • 0.1.2                                ...           12 years ago
  • 0.1.1                                ...           13 years ago
  • 0.1.0                                ...           13 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (3)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |