@delucis/filesize

1.0.2 • Public • Published

@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

Readme

Keywords

Package Sidebar

Install

npm i @delucis/filesize

Weekly Downloads

1

Version

1.0.2

License

GPL-3.0

Unpacked Size

3.93 kB

Total Files

3

Last publish

Collaborators

  • delucis