Provides a wrapper to return eventEmitters from async function calls.
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
vendor
readme.mkd

readme.mkd

Syn

Syn is a simple wrapper function, that returns an EventEmitter providing simple access to two events "started" and "finished". It's primary aid is in helping track when asynchronus functions have completed. It assumes that the callbacks you pass into the async functions are synchronus.

Examples

In this example, path will only be removed after stat is called.

var sys = require('sys')
var fs = require('fs')
var syn = require('syn')

var path = "/tmp";

var s = syn.track(fs.stat, [path], function (err, stat) {
  sys.log(stat);
});

s.addListener("finished", function () {
  fs.remove(path);
});