# polygoat

> Make JavaScript functions that support both promise and callback styles.

Latest version **1.1.4** (published 2016-04-17) · ISC license · 0 weekly downloads

## Install

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

## 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.1.4 |
| Published | 2016-04-17 |
| First published | 2016-04-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 152 |
| Author | Sonny Piers |
| Maintainers | sonny |
| Keywords | async, promise, callback, hybrid, hybridify, promisify, thenify |

## Links

- npm: https://www.npmjs.com/package/polygoat
- Repository: https://github.com/sonnyp/polygoat
- Issues: https://github.com/sonnyp/polygoat/issues
- npm.io page: https://npm.io/package/polygoat

## 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.1.4 (latest) — 2016-04-17
- 1.1.3 — 2016-04-14
- 1.1.2 — 2016-04-13
- 1.1.1 — 2016-04-13
- 1.1.0 — 2016-04-13
- 1.0.0 — 2016-04-12

## README

polygoat
========

[![Build Status](https://img.shields.io/travis/sonnyp/polygoat/master.svg?style=flat-square)](https://travis-ci.org/sonnyp/polygoat/branches)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](http://standardjs.com/)

![logo](./logo.png)

polygoat is a tool to make functions support both callback and promise style.

* very small, < 30 lines of code
* no promise support/polyfill required
* simple, hack-free
* Node.js and browsers
* fast, see [benchmark](#benchmark)

# Getting started


`npm install polygoat`

----

```javascript
var pg = require('polygoat');
```

or

```xml
<script src="node_modules/polygoat/index.js"></script>
```
```javascript
var pg = window.polygoat
```

# Usage

```js
// wrap an asynchronous function with polygoat
function hybridFunction (path, callback) {
  return pg(function (done) {
    fs.readdir(path, done)
  }, callback)
}

// hybridFunction can be used with promise style
hybridFunction('/').then(console.log)

// or callback style
hybridFunction('/', console.log)

// you can also pass the Promise implementation of your choice
var bluebird = require('bluebird')

function hybridFunction (path, callback) {
  return pg(function (done) {
    fs.readdir(path, done)
  }, callback, bluebird)
}

hybridFunction() instanceof bluebird // true
```

# Example

See [example.js](https://github.com/sonnyp/polygoat/blob/master/example.js)

# Benchmark

See [benchmark](https://github.com/sonnyp/polygoat/tree/master/benchmark)

# Test

```
npm install standard
npm test
```

[Goat icon](https://thenounproject.com/term/goat/301185/) by [Agne Alesiute](https://thenounproject.com/grrrauf) from [the Noun Project](https://thenounproject.com)

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