How to use p-any - 3 common examples

To help you get started, we’ve selected a few p-any 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 atomiclabs / hyperdex / app / renderer / marketmaker-socket.js View on Github external
swapEmitter.emit('progress', message);
			if (message.method) {
				swapEmitter.emit(message.method, message);
			}
			if (message.method === 'tradestatus' && message.status === 'finished') {
				swapEmitter.emit('completed', message);
			}
		});

		// We should wait for 10 minutes before removing the listener
		// to handle edge cases where swaps can breifly have an incorrect
		// status due to communication issues:
		// https://github.com/jl777/SuperNET/issues/756
		const TEN_MINUTES = 1000 * 60 * 10;
		pAny([
			swapEmitter.once('failed'),
			swapEmitter.once('completed'),
		]).then(async () => {
			await delay(TEN_MINUTES);
			removeListener();
		});

		return swapEmitter;
	}
}
github tinajs / mina-webpack / packages / mina-entry-webpack-plugin / src / loaders / virtual-mina-loader.ts View on Github external
pProps(options.extensions, (extnames: Array) => {
    let findFileWithExtname = (extname: string) => {
      let filePath = replaceExt(this.resourcePath, `.${extname}`)
      // @ts-ignore
      return fs.exists(filePath).then(isExist => ({ isExist, filePath }))
    }
    return pAny(extnames.map(findFileWithExtname), {
      filter: ({ isExist }) => isExist,
    }).then(
      ({ filePath }) => {
        this.addDependency(filePath)
        return fs.readFile(filePath, 'utf8')
      },
      () => {}
    )
  })
    .then((parts: Record) => done(null, template(parts)))
github koajs / jwt / lib / index.js View on Github external
.catch(function (err) {
                    if (err instanceof pAny.AggregateError) {
                        for (const e of err) {
                            throw e;
                        }
                    } else {
                        throw err;
                    }
                });

p-any

Wait for any promise to be fulfilled

MIT
Latest version published 3 years ago

Package Health Score

56 / 100
Full package analysis

Popular p-any functions