node-fibers : yielding data out of a Fiber

Multi tool use
node-fibers : yielding data out of a Fiber
I just started working with node-fibers to actually try out something I had in mind to make it easier to make mongoose queries a little more easy to deal with.
Unfortunately , I don't seem to understand what I'm doing wrong to get the users
returned using the yield()
to the main function that called Fiber.
users
yield()
var Fiber = require("fibers");
var mongoose = require("mongoose");
var User = require('./user');
mongoose.connect('mongodb://localhost/fibers');
function wrapper() {
let f = Fiber(function(){
var results;
var fiber = Fiber.current;
User.find({},function(err,users){
var results = Fiber(function(){
fiber.run(users);
}).run();
})
results = Fiber.yield();
Fiber.yield(results);
});
return f.run.bind(f);
}
var result = wrapper()();
console.log(result);
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
use sync instead of fibers . npmjs.com/package/sync
– Ratan Uday Kumar
Jul 2 at 4:04