Code Monkey home page Code Monkey logo

xfs's Introduction

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

xfs's People

Contributors

fishbar avatar

Watchers

James Cloos avatar Li Yang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.