Pewarta Proxy

📋 Server Request & Proxy Logs

Loading active proxy settings...
Developed by Khairul Adha (adhexa.id)
Mengambil log server...

⚙️ Pengaturan Proxy Target

Skip to content
sindresorhusPublic

About

Break out of a promise chain

Resources

Code of conduct

Contributing

Stars

24 stars

Watchers

4 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

p-break

Break out of a promise chain

See "How do I break out of a promise chain?" for a better way.

Install

$ npm install p-break

Usage

Here the onlyRunConditional promises are skipped if conditional is falsy:

import pBreak from 'p-break';

alwaysRun1()
	.then(() => alwaysRun2())
	.then(conditional => conditional || pBreak('🦄'))
	.then(() => onlyRunConditional1())
	.then(() => onlyRunConditional2())
	.then(() => onlyRunConditional3())
	.then(() => onlyRunConditional4())
	.catch(pBreak.end)
	.then(console.log);
	//=> '🦄'

API

pBreak([value])

Starts the break. Any .then()'s between here and pBreak.end() are skipped.

value

Value to pass down the chain after pBreak.end().

pBreak.end

Ends the break. Make sure not to have any other .catch() handlers between pBreak() and here.

Related

About

Break out of a promise chain

Resources

Code of conduct

Contributing

Stars

24 stars

Watchers

4 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages