# promisify

> Convert callback-based APIs to promises

Latest version **0.0.3** (published 2012-11-28) · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2012-11-28 |
| First published | 2012-10-29 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 28 |
| Author | David Wragg |
| Maintainers | dwragg |

## Links

- npm: https://www.npmjs.com/package/promisify
- Repository: https://github.com/dpw/promisify
- npm.io page: https://npm.io/package/promisify

## Dependencies (1)

- [when](https://npm.io/package/when.md)

## Recent versions

- 0.0.3 (latest) — 2012-11-28
- 0.0.2 — 2012-11-28
- 0.0.1 — 2012-10-29

## README

# Promisify: Convert callback-based APIs to promises

Promises are a popular solution to some of the drawbacks of the
callback-style async APIs dominant in node.js libraries.  But it's
awkward to write an node.js application using promises when all the
libraries you want to use are callback-based.

Hence Promisify.  It converts callback-style APIs to use promises
instead.  To use it, you provide a concise description of the
structure of the API to tell Promisify what to convert.  For example,
here is a sample which converts a substantial portion of the MongoDB
driver API to Promises:

    var promisify = require('promisify');

    var promisify_collection = promisify.object({
        insert: promisify.cb_func(),
        remove: promisify.cb_func(),
        findOne: promisify.cb_func(),
        find: promisify.func(promisify.object({
            stream: promisify.func(promisify.read_stream())
        }))
    });

    var promisify_connection = promisify.object({
        collection: promisify.cb_func(promisify_collection),
        createCollection: promisify.cb_func(promisify_collection),
        dropCollection: promisify.cb_func()
    });

    var promisify_mongodb = promisify.object({
        connect: promisify.cb_func(promisify_connection)
    });

    var mongodb = promisify_mongodb(require('mongodb'));

Promisify is built upon the [when.js](https://github.com/cujojs/when)
implementation of promises.

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