Skip to content

Function until and whilst Issues in Documents #1688

@jaeseok-park

Description

@jaeseok-park

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions