p-try

WebJar for p-try

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

p-try
Последняя версия

Последняя версия

2.2.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

p-try
WebJar for p-try
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/sindresorhus/p-try

Скачать p-try

Имя Файла Размер
p-try-2.2.0.pom
p-try-2.2.0.jar 4 KB
p-try-2.2.0-sources.jar 22 bytes
p-try-2.2.0-javadoc.jar 22 bytes
Обзор

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/p-try/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>p-try</artifactId>
    <version>2.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/p-try/
implementation 'org.webjars.npm:p-try:2.2.0'
// https://jarcasting.com/artifacts/org.webjars.npm/p-try/
implementation ("org.webjars.npm:p-try:2.2.0")
'org.webjars.npm:p-try:jar:2.2.0'
<dependency org="org.webjars.npm" name="p-try" rev="2.2.0">
  <artifact name="p-try" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='p-try', version='2.2.0')
)
libraryDependencies += "org.webjars.npm" % "p-try" % "2.2.0"
[org.webjars.npm/p-try "2.2.0"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

p-try Build Status

Start a promise chain

How is it useful?

Install

$ npm install p-try

Usage

const pTry = require('p-try');

(async () => {
	try {
		const value = await pTry(() => {
			return synchronousFunctionThatMightThrow();
		});
		console.log(value);
	} catch (error) {
		console.error(error);
	}
})();

API

pTry(fn, ...arguments)

Returns a Promise resolved with the value of calling fn(...arguments). If the function throws an error, the returned Promise will be rejected with that error.

Support for passing arguments on to the fn is provided in order to be able to avoid creating unnecessary closures. You probably don't need this optimization unless you're pushing a lot of functions.

fn

The function to run to start the promise chain.

arguments

Arguments to pass to fn.

Related

  • p-finally - Promise#finally() ponyfill - Invoked when the promise is settled regardless of outcome
  • More…

Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Версии библиотеки

Версия
2.2.0
2.1.0
2.0.0
1.0.0