# sb-promisify

> Node module for simple promisification

Latest version **2.0.2** (published 2017-05-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install sb-promisify
pnpm add sb-promisify
yarn add sb-promisify
bun add sb-promisify
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2017-05-01 |
| First published | 2016-02-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | steelbrain |
| Maintainers | steelbrain |
| Keywords | promisify, es6, promise |

## Links

- npm: https://www.npmjs.com/package/sb-promisify
- Repository: https://github.com/steelbrain/promisify
- Homepage: https://github.com/steelbrain/promisify#readme
- Issues: https://github.com/steelbrain/promisify/issues
- npm.io page: https://npm.io/package/sb-promisify

## 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

- 2.0.2 (latest) — 2017-05-01
- 2.0.1 — 2016-08-25
- 2.0.0 — 2016-08-22
- 1.3.0 — 2016-03-30
- 1.2.0 — 2016-03-26
- 1.1.1 — 2016-02-11
- 1.1.0 — 2016-02-08
- 1.0.0 — 2016-02-01

## README

# Promisify

A node module to help you convert callback-style functions to promises

## Installation

```js
npm install --save sb-promisify
```

## API

```js
function promisifyAll(object, throwError = true): Object
function promisify(callback, throwError = true): Function

export default promisify
export { promisify, promisifyAll }
```

## Example Usage

```js
import fs from 'fs'
import promisify from 'sb-promisify'

const readFile = promisify(fs.readFile)

readFile('/etc/passwd', 'utf8').then(function(contents) {
  console.log(contents)
}, function() {
  console.error('Unable to read file')
})
```
```js
import fs from 'fs'
import { promisifyAll } from 'sb-promisify'

const promisedFS = promisifyAll(fs)

promisedFS.readFileAsync('/etc/passwd', 'utf8').then(function(contents) {
  console.log(contents)
})
promisedFS.readFile('/etc/passwd', 'utf8', function(contents) {
  console.log(contents)
})
```

If you set throwError to false, here's how it would react

```js
'use babel'

import fs from 'fs'
import promisify from 'sb-promisify'

const access = promisify(fs.access, false)
const readFile = promisify(fs.readFile, false)

readFile('/etc/passwd').then(function(contents) {
  if (contents === false) {
    console.error('Unable to read file')
  } else {
    console.log(contents.toString('utf8'))
  }
})

access('/etc/passwd').then(function(access) {
  console.log('access', access) // true or false
})
```

## License
This module is licensed under the terms of MIT License. Check the LICENSE file for more info.

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