# synchronized-promise

> Turn ES6 Promise into synchronize function call, a simple wrapper of deasync package

Latest version **0.3.1** (published 2020-04-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install synchronized-promise
pnpm add synchronized-promise
yarn add synchronized-promise
bun add synchronized-promise
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2020-04-02 |
| First published | 2018-02-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=4.2.0 |
| Dependencies | 1 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Yukai Huang |
| Maintainers | yukaii |
| Keywords | promise, deasync, synchronize |

## Links

- npm: https://www.npmjs.com/package/synchronized-promise
- Repository: https://github.com/Yukaii/synchronized-promise
- Homepage: https://github.com/Yukaii/synchronized-promise#readme
- Issues: https://github.com/Yukaii/synchronized-promise/issues
- npm.io page: https://npm.io/package/synchronized-promise

## Dependencies (1)

- [deasync](https://npm.io/package/deasync.md) ^0.1.15

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 0.3.1 (latest) — 2020-04-02
- 0.3.0 — 2020-04-02
- 0.2.0 — 2019-09-30
- 0.1.0 — 2019-06-07
- 0.0.4 — 2018-02-13
- 0.0.3 — 2018-02-13
- 0.0.2 — 2018-02-12
- 0.0.1 — 2018-02-12

## README

# synchronized-promise
[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors)

[![npm version](https://badge.fury.io/js/synchronized-promise.svg)](https://badge.fury.io/js/synchronized-promise)
[![Build Status](https://travis-ci.org/Yukaii/synchronized-promise.svg?branch=master)](https://travis-ci.org/Yukaii/synchronized-promise)

Turn ES6 Promise into synchronize function call, a simple wrapper of deasync package

## Installation

```js
npm install synchronized-promise --save
```

## Usage

First, you need to require the `synchronized-promise` packgage, for JavaScript:

```js
const sp = require('synchronized-promise')
```

For TypeScript or ES6 later JavaScript:

```ts
import sp from 'synchronized-promise'
```

Then call it as the following example:

```js
// An promise base async function
let asyncFunction = (value) => {
  return new Promise((resolve, reject) => {
    setTimeout(function () {
      resolve(value)
    }, 2000)
  })
}

// regular usage
asyncFunction(5).then(value => value === 5)

// make it synchronized
let syncFunc = sp(asyncFunction)
const value = syncFunc(5) // value === 5
```

See [`test.js`](https://github.com/Yukaii/synchronized-promise/blob/master/test.js) for usage in details.

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
  <tr>
    <td align="center"><a href="https://github.com/masquevil"><img src="https://avatars1.githubusercontent.com/u/3344691?v=4" width="100px;" alt=""/><br /><sub><b>侠小然</b></sub></a><br /><a href="https://github.com/Yukaii/synchronized-promise/commits?author=masquevil" title="Code">💻</a></td>
    <td align="center"><a href="https://github.com/clar-cmp"><img src="https://avatars3.githubusercontent.com/u/54909317?v=4" width="100px;" alt=""/><br /><sub><b>Clar Charron</b></sub></a><br /><a href="https://github.com/Yukaii/synchronized-promise/commits?author=clar-cmp" title="Code">💻</a></td>
  </tr>
</table>

<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

---
_Source: https://npm.io/package/synchronized-promise · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
