JSPM

readdir-life

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q32289F
  • License MIT

Check what are the oldest/latest files/folders within a directory

Package Exports

  • readdir-life

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 (readdir-life) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

readdir-life

GitHub release Build Status Coverage Status XO code style npm

Check the oldest/latest files/folders within a directory

Install

$ yarn add readdir-life

Usage

const {join} = require('path');
const readdirLife = require('readdir-life');

const pathResolved = join(__dirname, 'your-path');

readdirLife.latest(pathResolved)
    .then(res => console.log(res))
    .catch(err => console.error(err));

/* =>

{
    file: 'latest-file-or-folder-modified',
    stat: {
        dev: 16777220,
        mode: 33188,
        nlink: 1,
        uid: 501,
        gid: 20,
        rdev: 0,
        blksize: 4096,
        ino: 14889287,
        size: 0,
        blocks: 0,
        atime: 2017-03-05T01:29:07.000Z,
        mtime: 2017-03-05T01:29:16.000Z,
        ctime: 2017-03-05T01:29:16.000Z,
        birthtime: 2017-03-05T01:29:06.000Z
    }
}
*/

readdirLife.sortLatest(pathResolved)
    .then(res => console.log(res))
    .catch(err => console.error(err));

/* =>

[{
    file: 'latest-file-or-folder-modified',
    stat: {
        dev: 16777220,
        mode: 33188,
        nlink: 1,
        uid: 501,
        gid: 20,
        rdev: 0,
        blksize: 4096,
        ino: 14889287,
        size: 0,
        blocks: 0,
        atime: 2017-03-05T01:29:07.000Z,
        mtime: 2017-03-05T01:29:16.000Z,
        ctime: 2017-03-05T01:29:16.000Z,
        birthtime: 2017-03-05T01:29:06.000Z
    }
}, {...}]
*/

API

.latest(input, [options])

input

Type: string

Directory to read.

options

typeTime

Type: string
Default: mtime // Modified time

Type of the time to check: ctime|mtime|atime|birthtime More info: fs.Stats

.oldest(input, [options])

return

Type: object

input

Type: string

Directory to read.

options

typeTime

Type: string
Default: mtime // Modified time

Type of the time to check: ctime|mtime|atime|birthtime More info: fs.Stats

.sortLatest(input, [options])

From the latest to the oldest

return

Type: array

input

Type: string

Directory to read.

options

typeTime

Type: string
Default: mtime // Modified time

Type of the time to check: ctime|mtime|atime|birthtime More info: fs.Stats

.sortOldest(input, [options])

From the oldest to the latest

return

Type: array

input

Type: string

Directory to read.

options

typeTime

Type: string
Default: mtime // Modified time

Type of the time to check: ctime|mtime|atime|birthtime More info: fs.Stats

License

MIT © LasaleFamine