# @jfrazx/asarray

> Ensures returned value is always an Array

Latest version **1.0.1** (published 2021-04-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install @jfrazx/asarray
pnpm add @jfrazx/asarray
yarn add @jfrazx/asarray
bun add @jfrazx/asarray
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-04-02 |
| First published | 2017-10-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | jfrazx |
| Maintainers | jfrazx |
| Keywords | array, arguments, convert, object, typed array, keys, typescript |

## Links

- npm: https://www.npmjs.com/package/@jfrazx/asarray
- Repository: https://github.com/jfrazx/asArray
- Homepage: https://github.com/jfrazx/asArray#readme
- Issues: https://github.com/jfrazx/asArray/issues
- npm.io page: https://npm.io/package/@jfrazx/asarray

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2021-04-02
- 1.0.0 — 2017-10-10

## README

# asArray

Ensure that the information you are working with is always an Array.  
Optionally, you may pass a callback that will transform a single value,
or map key value pairs from an object

---

[![devDependencies Status](https://david-dm.org/jfrazx/asarray/dev-status.svg)](https://david-dm.org/jfrazx/asarray?type=dev)
[![Master Build Status](https://img.shields.io/travis/jfrazx/asArray/master.svg?style=plastic)](https://travis-ci.org/jfrazx/asArray)
[![codecov](https://codecov.io/gh/jfrazx/asArray/branch/master/graph/badge.svg?style=plastic)](https://codecov.io/gh/jfrazx/asArray)
[![License](https://img.shields.io/npm/l/asarray.svg?style=plastic)](https://www.npmjs.com/package/@jfrazx/asarray)

## Install

`npm install @jfrazx/asarray`

or

`yarn add @jfrazx/asarray`

## Usage

#### asArray<T, TResult>(data: T | T[], callback?: (value: T) => TResult): Array<T | TResult>

#### asArray<T extends Object, K extends keyof T>(data: T, extractObjectValues?: boolean, callback?: (key: K) => T[K]): Array<T | T[K]>

```typescript
import { asArray } from '@jfrazx/asarray';

const person: Person = { name: 'Bart Simpson', age: 10 };

asArray('this string will be in an array');
// => ['this string will be in an array']

asArray([8, 6, 7, 5, 3, 0, 9]);
// => [8, 6, 7, 5, 3, 0, 9]

asArray(person);
// => [{ name: 'Bart Simpson', age: 10 }];

asArray(person, (object: T) => object.name);
// => ['Bart Simpson'];

asArray(person, true);
// => ['Bart Simpson', 10];

asArray(person, true, (key: K, object: T, index: number, array: K[]) => [k, o[k]]);
// => [['name', 'Bart Simpson'], ['age', 10]];

function things() {
  asArray(arguments);
  // => ['koalas', 'marsupial']
}

things('koalas', 'marsupial');
```

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