# unarray

> Retrieves a single value wrapped in an array.

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

## Install

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

## 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-18 |
| First published | 2018-04-18 |
| 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 | array |

## Links

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

## Dependencies (1)

- [is-new](https://npm.io/package/is-new.md) ^1.0.0

## Recent versions

- 1.0.0 (latest) — 2018-04-18

## README

# unarray

Retrieves a single value wrapped in an array.

## Installation

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

```bash
npm i unarray
```

## API

The module exports a single function.

### Parameters

1. `a` (array)
2. Optional: Object argument:
    * Optional: `fallback` (any): A value to return if the function fails to retrieve a single value.
    * Optional: `recursive` (bool): If `true`, will retrieve a single value wrapped in nested arrays. Defaults to `false`.

### Return Value

A single value if found. On failure, returns `fallback` if provided; otherwise returns the last-searched array.

## Examples

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

unarray([123]) // 123
unarray([123], {fallback: 'abc'}) // 123
unarray([1, 2]) // [1, 2]
unarray([1, 2], {fallback: 3}) // 3
unarray([[123]]) // [123]
unarray([[123]], {recursive: true}) // 123
```

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