# promisify-selected-methods

> Given an object with methods and a list of method names, return a new object with promisified bound versions of those methods.

Latest version **0.1.0** (published 2019-03-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install promisify-selected-methods
pnpm add promisify-selected-methods
yarn add promisify-selected-methods
bun add promisify-selected-methods
```

## 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.1.0 |
| Published | 2019-03-15 |
| First published | 2019-03-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 5.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | M.K. |
| Maintainers | mk-pmb |
| Keywords | methods, promisify |

## Links

- npm: https://www.npmjs.com/package/promisify-selected-methods
- Repository: https://github.com/mk-pmb/promisify-selected-methods-js
- Homepage: https://github.com/mk-pmb/promisify-selected-methods-js/#readme
- Issues: https://github.com/mk-pmb/promisify-selected-methods-js/issues
- npm.io page: https://npm.io/package/promisify-selected-methods

## Dependencies (2)

- [pify](https://npm.io/package/pify.md) ^4.0.1
- [is-fn](https://npm.io/package/is-fn.md) ^2.0.0

## Recent versions

- 0.1.0 (latest) — 2019-03-15

## README

<!--#echo json="package.json" key="name" underline="=" -->
promisify-selected-methods
==========================
<!--/#echo -->

<!--#echo json="package.json" key="description" -->
Given an object with methods and a list of method names, return a new object
with promisified bound versions of those methods.
<!--/#echo -->



API
---

This module exports one function with two modes:

### prFunc = promisifySelectedMethods(obj, oneMethodName)

`obj` can be anything. If it's false-y, `prFunc` will be `false`.

`oneMethodName` can be:
* false-y, then `prFunc` will be `false`.
* a string or number, then a method of that name is looked up in `obj`,
  bound to `obj`, promisified and returned as `prFunc`.


### prFuncs = promisifySelectedMethods(obj, methodNames)

`obj` can be anything. If it's false-y, `prFuncs` will be `false`.

`prFuncs` will be a dictionary object if you provide proper `methodNames`,
i.e. either

* an array, then keys in `prFuncs` will refer to the same-named method
  in `obj`, no magic.
* a dictionary object, mapping desired method names (keys in `prFuncs`)
  to the callback methods' name (key in `obj`). Special values:
  * `true`: Use same method name.
  * `null`, `false`: Ignore this entry.

`methodNames` that point to something that doesn't look like a function,
will be ignored.



Usage
-----

from [test/usage.js](test/usage.js):

<!--#include file="test/usage.mjs" transform="mjsUsageDemo1802" -->
<!--#verbatim lncnt="17" -->
```javascript
import nodeFs from 'fs';
import pifyMtds from 'promisify-selected-methods';

const readLinkPr = pifyMtds(nodeFs, 'readlink');
const promising = {
  ...pifyMtds(nodeFs, ['chmod', 'stat']),
  ...pifyMtds(nodeFs, {
    readFile: true,       // keep original name
    readDir: 'readdir',   // rename to camelCase
    ignored: null,
    alsoIgnored: false,
  }),
};
const expectedMethodNames = ['chmod',
  'readDir', 'readFile', 'stat'];
```
<!--/include-->



<!--#toc stop="scan" -->



Known issues
------------

* Needs more/better tests and docs.




&nbsp;


License
-------
<!--#echo json="package.json" key=".license" -->
ISC
<!--/#echo -->

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