JSPM

  • Created
  • Published
  • Downloads 797
  • Score
    100M100P100Q92966F
  • License MIT

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

Package Exports

  • readify
  • readify/lib/readify.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (readify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Readify License NPM version Build Status Coverage Status

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

Install

With npm:

npm i readify

API

readify(dir [, options, ])

  • 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")

Examples

const readify = require('readify');
const tryToCatch = require('try-to-catch');

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

readify('/', {
    type: 'raw',
}).then(console.log);

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

readify('/', {
    type: 'raw',
    sort: 'size',
    order: 'desc',
}).then(console.log);

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

License

MIT