jmar777/suspend — pull request #19 by notcome (2014-05-19 07:13:35+00:00)
Title: Support calling fork()(err, val) manually

Sometime it is required to call fork()(err, val) immediately. For example, if I need asynchronously load a directory and all sub-directories:
```Javascript
function loadDirectory (path, cb) {
suspend.run(function *() {
let list = {};
let files = yield fs.readdir(path, resume());
let paths = map(files, function (name) { return path + '/' + name; });
let stats = yield async.map(paths, fs.stat, resume());

for (let i = 0; i < files.length; i ++)
if (stats[i].isDirectory())
loadDirectory(paths[i], suspend.fork());
else
suspend.fork()(null, files[i]);

let result = yield suspend.join();
for (let i = 0; i < files.length; i ++)
list[files[i]] = result[i];
return list;
}, function (err, list) { cb(err, list); });
}
```
Though we could put the file/directory detecting code in loadDirectory (it is definitely better, making the programming stronger to invalid input), it would be a little confusing that ``suspend`` weirdly consumes fork values.

A more crazy example:
```Javascript
suspend.run(function*() {
for (var i = 0; i < 5; i ++)
fork()(null, i);
});
```

In the original implementation, only the last item will be in the array.