access fn-result in test of whilst/until #18

MaZderMind opened this Issue Mar 30, 2011 · 2 comments

3 participants


whilst & until would be much more useful if the test-callback could access the result of the last fn-call (it would get it as argument).



This could be useful, but would come at the cost of complicating the syntax. Not only would the predicate need to take an argument, the function's callback would also need to take a second argument. As of right now, the function passed to whilst has no concept of a result.

Instead, just store the last result in the function and check it in the predicate:

var lastResult = null;

  function () { return lastResult !== 4; },
  function (callback) {
    doStuff(function(err, result){
      lastResult = result;

yeah, I see the point, but it's not much trouble to rely on the surrounding scope. closing for now

@caolan caolan closed this Mar 2, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment