fsis

A set of utility methods for determining if a path is a specific type of resource without having to call fs.stat and then one of the is* methods on the returned Stat object. See Node.js fs.Stat methods.

npm install fsis
12 downloads in the last month

fsis

This is a set of utility methods for determining if a path is a specific type of resource without having to call fs.stat and then one of the is* methods on the returned Stat object. See Node.js fs.Stat methods.

Exported Methods

  • file(path, callback)
  • fileSync(path)
  • directory(path, callback)
  • directorySync(path)
  • blockDevice(path, callback)
  • blockDeviceSync(path)
  • characterDevice(path, callback)
  • characterDeviceSync(path)
  • fifo(path, callback)
  • fifoSync(path)
  • socket(path, callback)
  • socketSync(path)

Asynchronous callbacks are passed a single boolean value. True if the path exists and is the correct type of resource. False if the path doesn not exist or is not the correct type of resource.

Synchronous methods return true or false. True if the path exists and is the correct type of resource. False if the path doesn not exist or is not the correct type of resource.

Example

var is = require('fsis');

is.file('foo', function(yes)
{
    console.log('foo ' + (yes ? 'is' : 'is not') + ' a file.');
});

console.log('bar ' + (is.fileSync('bar') ? 'is' + 'is not') + 'a file.');
npm loves you