Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
22 lines (14 sloc) 656 Bytes

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);
});