# nodeify

> Convert promised code to use node style callbacks

Latest version **1.0.1** (published 2017-02-26) · MIT license · 0 weekly downloads

## Install

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

## 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 | 1.0.1 |
| Published | 2017-02-26 |
| First published | 2013-02-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 41 |
| Author | ForbesLindesay |
| Maintainers | forbeslindesay |
| Keywords | promise, then, nodeify, callback |

## Links

- npm: https://www.npmjs.com/package/nodeify
- Repository: https://github.com/then/nodeify
- Homepage: https://github.com/then/nodeify#readme
- Issues: https://github.com/then/nodeify/issues
- npm.io page: https://npm.io/package/nodeify

## Dependencies (2)

- [promise](https://npm.io/package/promise.md) ~1.3.0
- [is-promise](https://npm.io/package/is-promise.md) ~1.0.0

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2017-02-26
- 1.0.0 — 2013-02-28

## README

[![Build Status](https://img.shields.io/travis/then/nodeify/master.svg)](https://travis-ci.org/then/nodeify)
# Nodeify

  Convert promised code to use node style callbacks.  If no callback is provided it will just return the original promise.

## Installation

  Server:

    $ npm install nodeify

## Usage

### Functional

  Call `nodeify` directly passing the `promise` and an optional `callback` as arguments.  If a `callback` is provided it will be called as `callback(error, result)`.  If `callback` is not a function, `promise` is returned.

```javascript
var nodeify = require('nodeify');

function myAsyncMethod(arg, callback) {
  return nodeify(myPromiseMethod(arg), callback);
}
```

### Constructor / Method

  The `nodeify.Promise` constructor returns a promise with a `.nodeify` method which behaves just like the functional version above except that the first argument is implicitly `this`.

```javascript
var Promise = require('nodeify').Promise;

function myAsyncMethod(arg, callback) {
  return new Promise(function (resolver) {
    //do async work
  })
  .nodeify(callback);
}
```

### Extend

#### Extend(promise)

  Takes a promise and extends it to support the `.nodeify` method.  It will still support the nodeify method after calls to `.then`.

```javascript
var Promise = require('promise');
var nodeify = require('nodeify');

function myAsyncMethod(arg, callback) {
  return nodeify.extend(myPromiseMethod(arg))
    .nodeify(callback);
}
```

#### Extend(PromiseConstructor)

  Takes a PromiseConstructor and extends it to support the `.nodeify` method.

```javascript
var PromiseConstructor = require('promise-constructor-used-by-my-promise-method');

require('nodeify').extend(PromiseConstructor);

function myAsyncMethod(arg, callback) {
  return myPromiseMethod(arg).nodeify(callback);
}
```

#### Extend()

  Extends the default promise constructor (returned by calling `require('promise')`) and extends it to support `.nodeify`.

```javascript
require('nodeify').extend();

function myAsyncMethod(arg, callback) {
  //assuming myPromiseMethod uses `promise` as its promise library
  return myPromiseMethod(arg).nodeify(callback);
}
```

## Licence

  MIT

![viewcount](https://viewcount.jepso.com/count/then/nodeify.png)

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