3.0.0 • Published 3 years ago

p-try v3.0.0

Weekly downloads
32,967,335
License
MIT
Repository
github
Last release
3 years ago

p-try

Start a promise chain

How is it useful?

Install

npm install p-try

Usage

import pTry from 'p-try';

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


web-desktop-helperfree-minarchetype-librarycomponennentteasy-select-rnchinjowwchinjowvuedragdropuploadimagespopsmart-common-authreact-native-bluetooth2killi8n-react-native-fast-imagepipihomern-send-smsspecify-importsbabel-specify-imports@icanpm/api-master@arisageha/react-lazyload@arisageha/react-lazyload-fixfoshata-markdown@cashremit/cr-streamline-icons@almeidaa/msreact-native-template-rfbaseairscanairscan-examplebb-chatreact-native-esc-pos-sahaab@borisovart/atol-kkt-module@frxf/frxfkubii-apideneme323112@texttree/demo-bsa-reference-rcl@fundefund/funde_ck@ntt_app/react-native-custom-notificationreact-native-custom-text-hwjamesreact-native-covid-sdkgql_din_modbitgetalex-frontend-sdk-stagingafryxiconsreact-native-thanh-toast-librarymutasi-bcasalut_gongjang_first_module@jttechnic/interpreter@thanhnguyen14797/react-native-thanh-toast-library@l1nyanm1ng/react-picture-viewer@saeon/quick-formcthpb-plugin-social@olivervorasai/slidermysql-formatreact-native-printer-brothersrn-pdf-reader-offlinecbmis-ai-toolboxreact-native-shekhar-bridge-testcogoportutilsukor-remasteruncoded-connecteasy-threeeasy-three-templevibestliblevibestlib2levilibtest19levilibtest24levilibtest25levilibtest26levilibtest27levilibtest28levilibtest29temp-mail-fuckwilscanner@khalitovadel/abstract-repository@oiti/documentoscopy-react-nativejs4cytoscape@respondea/cordova-plugin-v-inappbrowser@mink-opn/build-tokensquoc-testreact-native-slider-kfnodejs-fileshareunblock-block-save-variables@prodam/prodam-typescclibyarntest@saaspe/componentshyperpass-sdkplginexpand-react-bridgeopea-bootstraapluminos-ui-coresklif-ui-kitsklif-api@everything-registry/sub-chunk-2396jawwy-sdkjawwy_gamification_release@314oner_npm/universal-components-libraryreact-native-sphereuisphereuijawwy_libraryreact-native-credit-card-pkgp149-table@rabailriaz/hisaab-web-portalsklif-uireact-native-jawwy_sample
3.0.0

3 years ago

2.2.0

5 years ago

2.1.0

5 years ago

2.0.0

6 years ago

1.0.0

8 years ago