Read directory content with file attributes: size, date, owner, mode
JavaScript
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.eslintrc
.eslintrc.test
.gitignore
.npmignore
.travis.yml
ChangeLog
LICENSE
README.md
package.json

README.md

Readify License NPM version Dependency Status Build Status Coverage Status

Read directory content with file attributes: size, date, owner, mode.

Install

With npm:

npm i readify --save

API

readify(dir [, options, ], callback)

  • dir - path of a directory
  • options - object can contain:
    • type - type of result, could be "raw"
    • sort - sort by: name, size, date
    • order - "asc" or "desc" for ascending and descending order (default: "asc")
  • callback - function

Examples

const readify = require('readify');

readify('/', (error, data) => {
    console.log(data);
    // output
    {
        path: '/',
        files:  [{
            name: 'readify.js',
            size: '4.22kb',
            date: '20.02.2016',
            owner: 'coderaiser',
            mode: 'rw- rw- r--'
        }]
    }
});

readify('/', {type: 'raw'}, (error, data) => {
    console.log(data);
    // output
    {
        path: '/',
        files:  [{
            name: 'readify.js',
            size: 4735,
            date: 2016-11-21T13:37:55.275Z,
            owner: 1000,
            mode: 33204
        }]
    }
});

readify('/', {type: 'raw', sort: 'size', order: 'desc'}, (error, data) => {
    console.log(data);
    // output
    {
        path: '/',
        files:  [{
            name: 'readify.js',
            size: 4735,
            date: 2016-11-21T13:37:55.275Z,
            owner: 1000,
            mode: 33204
        }]
    }
});

License

MIT