Changed semantics a bit to incorporate ES6 Promises instead of callbacks. Added some basic nodeunit test cases.