0.9.39 • Published 1 year ago

@halleyassist/q-lite v0.9.39

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

q-lite

Lightweight implementation of Q.js for performance

Methods

Q.safetyAwait

Solves stack preservation when calling async functions without an await over async boundries

function testFn(){
    const deferred = Q.defer()
    async function a(){
        await Q.delay(1)
        throw new Error('test')
    }
    const promise = a()
    
    // will fail if this becomes awaited
    // this is because the stack is not preserved
    await Q.delay(10)

    const p = Q.cancelledRace([deferred.promise,promise])
    deferred.resolve()
    return await p
}

Stack would be lost (testFn) in this test over the Q.delay call. However with Q.safetyAwait method state can be preserved.

function testFn(){
    const deferred = Q.defer()
    async function a(){
        await Q.delay(1)
        throw new Error('test')
    }
    const promise = a()
    
    // will fail if this becomes awaited
    // this is because the stack is not preserved
    await Q.safetyAwait([Q.delay(10)], [promise])

    const p = Q.cancelledRace([deferred.promise,promise])
    deferred.resolve()
    return await p
}
0.9.39

1 year ago

0.9.38

1 year ago

0.9.37

1 year ago

0.9.36

1 year ago

0.9.35

1 year ago

0.9.34

2 years ago

0.9.32

2 years ago

0.9.33

2 years ago

0.9.30

2 years ago

0.9.31

2 years ago

0.9.24

2 years ago

0.9.25

2 years ago

0.9.26

2 years ago

0.9.27

2 years ago

0.9.28

2 years ago

0.9.29

2 years ago

0.9.8

3 years ago

0.9.13

3 years ago

0.9.7

3 years ago

0.9.14

3 years ago

0.9.9

3 years ago

0.9.20

3 years ago

0.9.21

3 years ago

0.9.10

3 years ago

0.9.11

3 years ago

0.9.16

3 years ago

0.9.17

3 years ago

0.9.18

3 years ago

0.9.19

3 years ago

0.9.6

3 years ago

0.9.2

3 years ago