Giter Club home page Giter Club logo

readdir-life's Introduction

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

Related

License

MIT © LasaleFamine

readdir-life's People

Contributors

lasalefamine avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

lawrencenull

readdir-life's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.