0.1.0 • Published 10 years ago

proph v0.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
10 years ago

proph Build Status NPM Version License

A tiny, simple and fast futures implementation.

Usage

var Future = require('proph');
var fs = require('fs');

var readFile = Future.wrap(fs.readFile);

var files = Future.concat(readFile('README.md'), readFile('package.json'));

files.fork(function(err) {
  console.error('Error reading files: ' + err);
}, function(files) {
  console.log('README.md is ' + files[0].length + ' bytes');
  console.log('package.json is ' + files[1].length + ' bytes');
});

Or write your own wrappers!

var Future = require('proph');
var fs = require('fs');

var exists = function(path) {
  return new Future(function(reject, resolve) {
    fs.exists(path, function(itExists) {
      if (itExists) {
        reject();
      } else {
        resolve();
      }
    });
  });
};

exists('package.json').fold(function() {
  console.log('nooo!');
}, function() {
  console.log('yay!');
}).exec();

function nop() {}

Install

You can get proph on npm.

$ npm install --save proph

And even bower!

$ bower install --save proph