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

Function until and whilst Issues in Documents #1688

Closed
jaeseok-park opened this issue Sep 25, 2019 · 0 comments
Closed

Function until and whilst Issues in Documents #1688

jaeseok-park opened this issue Sep 25, 2019 · 0 comments

Comments

@jaeseok-park
Copy link

jaeseok-park commented Sep 25, 2019

What version of async are you using?
v3.1.0 and also master branch

  1. until
    The example source codes are as below:
const results = []
async.until(function test(page, cb) {
    cb(null, page.next == null)
}, function iter(next) {
    fetchPage(url, (err, body) => {
        if (err) return next(err)
        results = results.concat(body.objects)
        next(err, body)
    })
}, function done (err) {
    // all pages have been fetched
})

But, test function can have only callback function argument. It cannot receive page argument.
When I print out arguments in the above test function, it has only a function as arguments.
Please check this.

  1. whilst
    The example source codes are as below:
var count = 0;
async.whilst(
    function test(cb) { cb(null, count < 5;) },
    function iter(callback) {
        count++;
        setTimeout(function() {
            callback(null, count);
        }, 1000);
    },
    function (err, n) {
        // 5 seconds have passed, n = 5
    }
);

In test function, semicolon seems to be located at the wrong position.
Maybe, the below code is intended.

    function test(cb) { cb(null, count < 5); },

And, in parameter description of test,

asynchronous truth test to perform before each execution of iteratee. Invoked with ().

I think its last sentence seems to be modified as Invoked with (callback) according to the parameter description of until.

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

No branches or pull requests

2 participants