# refine-if-defined

> If a value is defined (!== undefined), call a function to potentially refine it.

Latest version **0.1.0** (published 2020-07-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install refine-if-defined
pnpm add refine-if-defined
yarn add refine-if-defined
bun add refine-if-defined
```

## 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 | 2020-07-25 |
| First published | 2020-07-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | M.K. |
| Maintainers | mk-pmb |

## Links

- npm: https://www.npmjs.com/package/refine-if-defined
- Repository: https://github.com/mk-pmb/refine-if-defined-js
- Homepage: https://github.com/mk-pmb/refine-if-defined-js/#readme
- Issues: https://github.com/mk-pmb/refine-if-defined-js/issues
- npm.io page: https://npm.io/package/refine-if-defined

## Recent versions

- 0.1.0 (latest) — 2020-07-25

## README

<!--#echo json="package.json" key="name" underline="=" -->
refine-if-defined
=================
<!--/#echo -->

<!--#echo json="package.json" key="description" -->
If a value is defined (!== undefined), call a function to potentially refine
it.
<!--/#echo -->



API
---

This module exports one function:

### refineIfDefined([how])(val)

If `how` is false-y, or `val` is undefined, return `val`.
Otherwise, call `how(val)` to obtain a possible replacement `better`.
If `better` is defined (i.e. not undefined), return it;
else return the original `val`.



Promise support
---------------

There's also a submodule `refine-if-defined/pr.js` that exports one function:

### promisedRefineIfDefined([how])(val)

It works as above but with async/Promise support in all parts.
Will always return a Promise.





<!--#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/refine-if-defined · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
