FABL - File Abstraction Layer
npm
Install via$ npm install --save fabl
Usage
Require it:
var File =
File
Static methods on Creating a file:
// Synchronousvar file = File// Sync, with modevar file = File// Async, with mode and callback (mode is optional)var file = File
Checking existance of a file:
FileFile
Stat a file:
FileFile
Renaming a file:
// Rename and move are synonymFileFile
Truncating/Allocating a file:
// Truncate and allocate are aliases,// Size is optional, defaults to zeroFileFile
Deleting a file:
// Delete and unlink are aliasesFileFile
File
Methods on an instance of Creating a file:
// Create an instance with a given pathvar file = 'README.md' // Sync createfile // ORfile
Opening a file:
// Sync open, with defaults// Flags default to 'r+', or previously used flags// Mode defaults to whatever node defaults to (0666)file // ORfile // ORfile // ORfile
Closing a file:
filefile
Deleting a file:
file // ORfile
Renaming/Moving a file:
// Rename and Move are aliasesfilefilefile
Truncating/Allocating a file:
// Truncate and Allocate are aliases as well// Size is optional, defaults to zerofilefile
Stat'ing a file:
var stat = filefile
Reading from a file:
// Read a chunk synchronouslyvar data = file// Offset can be omitted, and defaults to zerofile// Create a readable streamvar stream = file// With boundariesvar bound = file// And / or with optionsvar optstream = file
Writing to a file:
// Write data synchronouslyvar bytesWritten = file// Add an offset (the length is determined by// the bytelength of data (it's converted to a Buffer))file// Or create a writable stream, which has// the same options as the readStream() abovevar stream = file