3.0.0 • Published 5 years ago

promise-synchronizer v3.0.0

Weekly downloads
481
License
MIT
Repository
github
Last release
5 years ago

promise-synchronizer

styled with prettier npm npm npm

Build Status Code Coverage MIT License PRs Welcome

synchronize promise

Install

yarn add promise-synchronizer

Usage

Wrap async functions

import sync from 'promise-synchronizer'

const asyncFunction = async () => 'Fulfilled'

asyncFunction()

// -> Promise { 'Fulfilled' }

const syncFunction = sync(asyncFunction)

syncFunction()
// -> 'Fulfilled'

Wait for promises

import sync from 'promise-synchronizer'

const promiseWillFulfill = Promise.resolve('Fulfilled')
sync(promiseWillFulfill)
// -> Fulfilled

const promiseWillReject = Promise.reject(new Error('Rejected'))
sync(promiseWillReject)
// -> Uncaught Error: Reject

Use try-catch

import sync from 'promise-synchronizer'

try {
  console.log(sync(promise)) // Fulfilled
} catch (error) {
  console.error(error) // Rejected
}
3.0.0

5 years ago

2.0.0

5 years ago

1.2.0

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago