# assure-array

> Wraps a value in an array if it isn't already one

Latest version **1.0.0** (published 2016-08-16) · WTFPL license · 0 weekly downloads

## Install

```sh
npm install assure-array
pnpm add assure-array
yarn add assure-array
bun add assure-array
```

## 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 | 2016-08-16 |
| First published | 2016-04-17 |
| Weekly downloads | 0 |
| License | WTFPL |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sven Slootweg |
| Maintainers | joepie91 |
| Keywords | array, wrap |

## Links

- npm: https://www.npmjs.com/package/assure-array
- Repository: http://git.cryto.net/joepie91/node-assure-array
- npm.io page: https://npm.io/package/assure-array

## Recent versions

- 1.0.0 (latest) — 2016-08-16
- 0.0.1 — 2016-04-17

## README

# assure-array

Wraps a value in an array if it isn't already one. Returns an empty array for `null` and `undefined`.

A typical usecase for this: when you have an option that accepts multiple values as an array, but you want to make the use of an array literal optional when there's only a single value to specify.

## License

[WTFPL](http://www.wtfpl.net/txt/copying/) or [CC0](https://creativecommons.org/publicdomain/zero/1.0/), whichever you prefer. A donation and/or attribution are appreciated, but not required.

## Donate

Maintaining open-source projects takes a lot of time, and the more donations I receive, the more time I can dedicate to open-source. If this module is useful to you, consider [making a donation](http://cryto.net/~joepie91/donate.html)!

You can donate using Bitcoin, PayPal, Flattr, cash-in-mail, SEPA transfers, and pretty much anything else. Thank you!

## Contributing

Pull requests welcome. Please make sure your modifications are in line with the overall code style, and ensure that you're editing the files in `src/`, not those in `lib/`.

Build tool of choice is `gulp`; simply run `gulp` while developing, and it will watch for changes.

Be aware that by making a pull request, you agree to release your modifications under the licenses stated above.

## Usage

Some examples:

```javascript
var assureArray = require("assure-array");

assureArray("hello world");      // ["hello world!"]
assureArray(["hello", "world"]); // ["hello", "world"]
assureArray(null);               // []
assureArray([true]);             // [true]
```

## API

### assureArray(value)

Ensures that the provided `value` is returned as an array.

* If `value` is an array already, this returns the array unchanged.
* If `value` is `null` or `undefined`, this returns an empty array.
* If `value` is any other kind of value, this returns a new array containing just that one value.

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