0.0.1 • Published 6 years ago

filepaths-group v0.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

filepaths-group

build status AppVeyor Build Status


Collapse an array of file objects into a grouped array (entire dirs/single files). Best to use in conjunction with drag-drop.


Get it!

npm install --save filepaths-group

Usage

Note that every object in the file array needs to have a .path property. If you want to get accumulated dir/file sizes back the input objects also need to have a numeric .size property.

var group = require('filepaths-group')

var files = [ { path: 'C:/COPYING'}, { path: 'C:/fraud.pem' } ]

group(files, function (err, grouped) {
  if (err) return console.error(err)
  console.log(grouped)
})

Grouped file objects have a .type property which either indicates a single file or an entire directory.


API

group(files[, opts], callback)

Collapse the input file object array into a labelled array of entire directories and single files. Calls back with callback(err, data). Options default to:

{
  size: false // indicate total sizes of files and directories
}

License

MIT