# async-method

> Makes async methods work with callbacks and promises

Latest version **1.0.0** (published 2018-08-06) · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install async-method
pnpm add async-method
yarn add async-method
bun add async-method
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-08-06 |
| First published | 2015-01-20 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=v8 |
| Dependencies | 2 |
| Unpacked size | 4.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Michael van der Weg |
| Maintainers | ee |
| Keywords | async, methods |

## Links

- npm: https://www.npmjs.com/package/async-method
- Repository: https://github.com/eventEmitter/async-method
- Issues: https://github.com/eventEmitter/async-method/issues
- npm.io page: https://npm.io/package/async-method

## Dependencies (2)

- [ee-log](https://npm.io/package/ee-log.md) 3.0.6
- [ee-types](https://npm.io/package/ee-types.md) 2.1.4

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

- 1.0.0 (latest) — 2018-08-06
- 0.1.1 — 2015-01-20

## README

# async-method

Makes async methods work with callbacks and promises. You have a function on your class that expects a callback as last parameter? Wrap it using the asyncMethod and it returns a promise if the callback is omitted.

## installation

    npm i async-method

## build status

[![Build Status](https://travis-ci.org/eventEmitter/async-method.png?branch=master)](https://travis-ci.org/eventEmitter/async-method)


## usage
    
    // create a class 
    var MyClass = new Class({
        multiply: asyncMethod(function(a, b, callback) {
            process.nextTick(function() {
                callback(null, a*b);
            });
        })
    });



    var myClassInstance = new MyClass();


    // classic callback 
    myClassInstance.multiply(3, 5, function(err, result) {

    });


    // es6 promise
    myClassInstance.multiply(3, 5).then(function(result) {

    }).catch(function(err) {

    });

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