awaitwhile

Native: ``` while (conditional != key) { } ```

Usage no npm install needed!

<script type="module">
  import awaitwhile from 'https://cdn.skypack.dev/awaitwhile';
</script>

README

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
}