# plainify

> Wraps a value in a plain object, if it isn’t one already.

Latest version **1.0.0** (published 2018-04-14) · MIT license · 0 weekly downloads

## Install

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

## 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.0 |
| Published | 2018-04-14 |
| First published | 2018-04-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 1 |
| Unpacked size | 2.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | John Lamansky |
| Maintainers | lamansky |
| Keywords | plain, object, options |

## Links

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

## Dependencies (1)

- [is-plain-object](https://npm.io/package/is-plain-object.md) ^2.0.4

## Recent versions

- 1.0.0 (latest) — 2018-04-14

## README

# plainify

Wraps a value in a plain object, if it isn’t one already.

Lets you specify a default single key for an options object, for example.

## Installation

Requires [Node.js](https://nodejs.org/) 4.0.0 or above.

```bash
npm i plainify
```

## API

The module exports a single function.

### Parameters

1. `key` (string or symbol): The key under which to file `x` if it’s not already a plain object.
2. `x` (any)

### Return Value

Returns `x` as-is if it’s a plain object. Otherwise, returns a new plain object with one entry, having `key` as the key and `x` as the value.

## Example

Let’s say you have an options object with keys `a`, `b`, and `c`. You can use `plainify` to specify `b` as the default key.

```javascript
const plainify = require('plainify')

function example (options) {
  const {a, b, c} = plainify('b', options)
  // ...
}

example({a: 1}) // a=1; b and c are undefined
example(2) // b=2; a and c are undefined
example() // a, b, and c are undefined
```

## Related

Inspired by [arrify](https://github.com/sindresorhus/arrify).

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