Skip to content

delucis/filesize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@delucis/filesize

Build Status Coverage Status

A minimal, asynchronous library that returns human-friendly file sizes. Wraps filesize and uses Node’s fs.stat to retrieve sizes from the file system.

Installation

npm install @delucis/filesize

Usage

const FS = require('@delucis/filesize')

// Use with a callback to handle the returned string.
FS('my-file.txt', function (error, size) {
  if (error) {
    console.error('Couldn’t get file size...')
    return
  }
  console.log('Size of my-file.txt: ' + size);
  return
})

API

@delucis/filesize(path, [options,] callback)

path

Type: string, Buffer, URL

The path to the file you want to get the size for, which is passed to fs.stat.

options

Type: object
Default: {}

If included, this will be passed as filesize’s options object.

callback

Type: function

A function to handle the returned value.

Passed arguments
  1. An error object, which will be null if all goes well.
  2. The output of filesize. By default this is a string, but can also be of other types depending on the options you pass in.

Tests

npm test

About

📏 Utility that returns human-friendly file sizes from a file path.

Resources

Stars

Watchers

Forks

Packages

No packages published