Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs.exists returns a function #6

Closed
yanickrochon opened this issue Mar 3, 2014 · 2 comments
Closed

fs.exists returns a function #6

yanickrochon opened this issue Mar 3, 2014 · 2 comments

Comments

@yanickrochon
Copy link

With this code

var cofsTest = function * () {

  console.log("Unknown file", yield fs.exists('random.file'));
  console.log("this file", yield * fs.exists(__filename));

  return true;
};
var generator = cofsTest();
var genResult;

while (!(genResult = generator.next(genResult && genResult.value)).done);
console.log("Test", genResult.value);

I get this result

Unknown file function (done){
    fs.stat(path, function(err, res){
      done(null, !err);
    });
  }
this file function (done){
    fs.stat(path, function(err, res){
      done(null, !err);
    });
  }
Test true

Where I would have expected something like

Unknown file false
this file true
Test true
@yanickrochon
Copy link
Author

The above example returns similar results for every co-fs functions.... were these supposed to be used inside co only?

@yanickrochon
Copy link
Author

Disregard this issue. I misunderstood the purpose of this module and thought I could get away without needing co. Silly me. Until node.js officially support generator functions across it's entire API, every generator functions will have to get invoked from co to enable this module's functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant