@cloudcmd/sortify

Sort directory content by name, size, date

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
10Nov 14, 2018Jan 30, 2018Minified + gzip package size for @cloudcmd/sortify in KB

Readme

Sortify License NPM version Dependency Status Build Status Coverage Status

Sort directory content received by readify by name, size, date.

Install

npm i @cloudcmd/sortify

API

sortify(options, files)

  • options - object can contain:
    • sort - sort by: name, size, date
    • order - "asc" or "desc" for ascending and descending order (default: "asc")
  • files - files list

Examples

const files = [{
    name: 'readify.js',
    size: 3735,
    date: 2016-11-21T13:37:55.275Z,
    owner: 1000,
    mode: 33204,
    type: 'file',
}, {
    name: 'sortify.js',
    size: 4735,
    date: 2016-11-21T13:37:55.275Z,
    owner: 1000,
    mode: 33204,
    type: 'file',
}];

const sort = 'size';
const order ='desc';

sortify({sort, order}, files);
// output
[{
    name: 'sortify.js',
    size: 4735,
    date: 2016-11-21T13:37:55.275Z,
    owner: 1000,
    mode: 33204,
    type: 'file'
}, {
    name: 'readify.js',
    size: 3735,
    date: 2016-11-21T13:37:55.275Z,
    owner: 1000,
    mode: 33204,
    type: 'file'
}]

License

MIT

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.