Skip to content

q-lite 0.9.37

Install from the command line:
Learn more about npm packages
$ npm install @halleyassist/q-lite@0.9.37
Install via package.json:
"@halleyassist/q-lite": "0.9.37"

About this version

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
}

Details


Assets

  • q-lite-0.9.37.tgz

Download activity

  • Total downloads 24
  • Last 30 days 0
  • Last week 0
  • Today 0