quazardous / readify

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

With bower:

npm i bower --save

How to use?

Readify could be used in node.js based applications or in browsers with help of filer.

node.js example:

const readify = require('readify');

// basic
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--',
        }]
    }
});

// raw output
readify('/', '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
        }]
    }
});

// sort output
// available sort option: name, size, owner, date
// available order option: asc, desc
readify('/', {sort: 'size', order: 'desc'}, (error, data) => {
    console.log(data);
});

// all together
readify('/', {sort: 'size', order: 'desc', type: 'raw'}, (error, data) => {
    console.log(data);
});

browser example:

var fs = new Filer.FileSystem();

readify('/', function(error, data) {
    console.log(error || data);
});

Environments

In old node.js environments that supports es5 only, readify could be used with:

var readify = require('readify/legacy');

License

MIT

About

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

License:MIT License


Languages

Language:JavaScript 100.0%