1.0.1 • Published 4 years ago

awaitwhile v1.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

A solution for asynchronous while loops

npm version

Usage

Native:

while (conditional != key) { 
    test()
    jump() 
}

AwaitWhile:

await awaitWhile.while(test, jump, conditional, key)

Parameters

main method:

The method which you are looping

jump method:

The method which you will do in between every loop of method1 (ie. i+=1)

conditional:

The conditional statement (in this case the value that you are trying to get to become the key)

key:

The value which resolves the method when the conditional equals it

Example Methods

main:

async function test(conditional, key, callback) {
    setTimeout(async () => {
        conditional++;
        return callback(conditional, key)
    })
}

jump:

async function jump(i) {
    return i + 1
}
1.0.1

4 years ago

1.0.0

4 years ago