How to use synchronous-promise - 8 common examples

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 tus / tus-js-client / test / spec / upload.js View on Github external
beforeEach(function () {
      jasmine.Ajax.install();
      SynchronousPromise.installGlobally();

      // Clear localStorage before every test to prevent stored URLs to
      // interfere with our setup.
      if (isBrowser) {
        localStorage.clear();
      }
    });
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 {}
    }
github brodybits / prettierx / tests_integration / runPrettier.js View on Github external
    .mockImplementation(() => SynchronousPromise.resolve(options.input || ""));
  jest
github tus / tus-js-client / test / spec / upload.js View on Github external
afterEach(function () {
      jasmine.Ajax.uninstall();
      SynchronousPromise.uninstallGlobally();
    });
github jquense / yup / src / util / createValidation.js View on Github external
function runTest(testFn, ctx, value, sync) {
  let result = testFn.call(ctx, value);
  if (!sync) return Promise.resolve(result);

  if (thenable(result)) {
    throw new Error(
      `Validation test of type: "${
        ctx.type
      }" returned a Promise during a synchronous validate. ` +
        `This test will finish after the validate call has returned`,
    );
  }
  return SynchronousPromise.resolve(result);
}
github exokitxr / zeo / core / engines / webvr / client.js View on Github external
const _stopOpening = () => {
              this.isOpening = false;

              return SynchronousPromise.resolve();
            };
            const _handleError = err => {
github Levertion / mcfunction-langserver / src / data / noncached.ts View on Github external
const schemaRequestService: SchemaRequestService = url =>
        schemas.hasOwnProperty(url)
            ? SynchronousPromise.resolve(schemas[url])
            : SynchronousPromise.reject(
                  `Schema at url ${url} not supported`
              );
github Levertion / mcfunction-langserver / src / data / noncached.ts View on Github external
const schemaRequestService: SchemaRequestService = url =>
        schemas.hasOwnProperty(url)
            ? SynchronousPromise.resolve(schemas[url])
            : SynchronousPromise.reject(
                  `Schema at url ${url} not supported`
              );

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