Skip to content
Promise aware wrapper for Node's fs module
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
test
.gitignore
.jshintignore
.jshintrc
.travis.yml
LICENSE.txt
README.md
package.json

README.md

fs Then

Build Status

Thin wrapper arround Node's fs module that makes the async functions promise aware. The wrapped methods return a promise the represents the value of the async operation. Traditional callbacks still work, allowing for a transparent drop-in for fs. Sync methods, classes and other helpers are not modified.

Example

Traditional Callback

var fs = require('fs');
fs.readFile('path to file', function (err, buffer) {
   ...
});

With Promises

var fs = require('fs-then');
fs.readFile('path to file').then(
   function (buffer) { ... },
   function (err) { ... }
);

Wrapped methods

  • appendFile
  • chmod
  • chown
  • close
  • exists
  • fchmod
  • fchown
  • fdatasync
  • fstat
  • fsync
  • ftruncate
  • futimes
  • lchmod
  • lchown
  • link
  • lstat
  • mkdir
  • open
  • read
  • readFile
  • readdir
  • readlink
  • realpath
  • rename
  • rmdir
  • stat
  • symlink
  • truncate
  • unlink
  • utimes
  • write
  • writeFile
Something went wrong with that request. Please try again.