3.0.0 • Published 4 years ago

promise-synchronizer v3.0.0

Weekly downloads
481
License
MIT
Repository
github
Last release
4 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

4 years ago

2.0.0

4 years ago

1.2.0

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago