How to use the synchronous-promise.SynchronousPromise function in synchronous-promise

To help you get started, we’ve selected a few synchronous-promise examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pinyin / tween-here / src / tweenExit.ts View on Github external
const releaseLock = () => {
        if (lock.get(element) === releaseLock) {
            lock.delete(element)
            cleanup()
        }
    }
    lock.set(element, releaseLock)

    if (!isInViewport(from)) {
        return
    }
    const isParentChanged = container !== element.parentElement
    const snapshot = snapshotNode(element, isParentChanged)
    snapshot.style.position = `absolute` // TODO more optimization such as contain

    await new SynchronousPromise(
        (resolve: () => void, reject: () => void) => {
            listeners.set(element, () => {
                listeners.delete(element)
                resolve()
            })
            cleanup = () => {
                listeners.delete(element)
                reject()
            }
        },
    )
    await writePhase(OptimizeFor.LATENCY)
    container.appendChild(snapshot)
    cleanup = () => {
        try { container.removeChild(snapshot) } catch {}
    }

synchronous-promise

Synchronous Promise-like prototype to use in testing where you would have used an ES6 Promise

BSD-3-Clause
Latest version published 2 years ago

Package Health Score

73 / 100
Full package analysis

Similar packages