1.0.0 • Published 4 years ago

fs-multi v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Node.js: fs-multi

fs-multi extends fs-extra v9.0.0 for working multiple files.

Installation

npm install fs-multi

Usage

fs-multi is a drop in replacement for fs-extra v9.0.0. All methods in fs and fs-extra are attached to fs-multi.

You don't ever need to include the native fs or fs-extra modules. You can now include only fs-multi module.

const fs = require('fs-multi')

multi(method, files)

copy or move multiple files or directories.

  • method <string> Methods may be copy or move.
  • files <Object> Destinations, options and callback functions or <string> as only destinations for each file. Each key of <Object> is referred to src (see: copy or move).
    • dest <string> Destination
    • opts <Object> Options
      • overwrite <boolean>: default is true for copy or default is false for move
      • errorOnExist <boolean>: for copy only
      • dereference <boolean>: for copy only
      • preserveTimestamps <boolean>: for copy only
      • filter <Function>: for copy only

Example:

Working with multiple files:

const fs = require('fs-multi')

let files = {

  // dest is in <Object>
  '/tmp/myfile': {
    dest: '/tmp/mynewfile',
    callback: err => {
      if (err) console.error(err)
      else console.log('myfile success!')
    }
  },

  // dest is <string> itself
  '/tmp/mysecondfile': '/tmp/mysecondnewfile'
}

fs.multi('copy', files).then(
  () => console.log('multiple processes completed'))
    .catch(err => console.error(err)
)

Working with native fs and fs-extra methods:

fs.copy('/tmp/mydir', '/tmp/mynewdir') //fs-extra 'copy' method

fs.copyFile('/tmp/myfile', '/tmp/mynewfile') //fs 'copyFile' method

License

Licensed under MIT

1.0.0

4 years ago

0.3.0

4 years ago

0.2.0

5 years ago

0.1.0

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago