Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

fabiospampinato/ripstat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ripstat

Fetch the stats for a file as if a saber-tooth tiger is chasing you!

Features

  • Fast: This is designed to be as fast as possible, and it's probably at least ~2x faster than whatever you are doing currently. If you know how to speed it up further ping me.
  • Reliable: Stats objects are read reliably, which is something especially important when you are reading thousands of them, chances are the current way you are reading files doesn't account for EMFILE errors at all for example.
  • Non-blocking: Almost all the work is performed asynchronously, so you'll experience no freezes in the main thread.
  • Non-native: By using native modules perhaps some more overhead could be trimmed, but native modules are a pain to work with, this uses none of them.

Install

npm install --save ripstat

Usage

The following interface is provided for stats objects:

class Stats {
  dev: number;
  mode: number;
  nlink: number;
  uid: number;
  gid: number;
  rdev: number;
  blksize: number;
  ino: number | bigint;
  size: number;
  blocks: number;
  atimeMs: number;
  mtimeMs: number;
  ctimeMs: number;
  birthtimeMs: number;
  isDirectory (): boolean;
  isFile (): boolean;
  isBlockDevice (): boolean;
  isCharacterDevice (): boolean;
  isSymbolicLink (): boolean;
  isFIFO (): boolean;
  isSocket (): boolean;
}

This is how you use it:

import ripstat from 'ripstat';

const stats = await ripstat ( '/Users/fabio/Desktop/foo.txt' );

console.log ( stats ); // => Stats

License

MIT © Fabio Spampinato

About

Fetch the stats for a file as if a saber-tooth tiger is chasing you!

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published