# random-from-array

> Given an array, return a random value from it

Latest version **1.0.1** (published 2019-01-26) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install random-from-array
pnpm add random-from-array
yarn add random-from-array
bun add random-from-array
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-01-26 |
| First published | 2019-01-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Cezar Augusto |
| Maintainers | cezaraugusto |
| Keywords | random, array, typescript |

## Links

- npm: https://www.npmjs.com/package/random-from-array
- Repository: https://github.com/cezaraugusto/random-from-array
- Homepage: https://github.com/cezaraugusto/random-from-array.git#readme
- Issues: https://github.com/cezaraugusto/random-from-array.git/issues
- npm.io page: https://npm.io/package/random-from-array

## 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) — 2019-01-26
- 1.0.0 — 2019-01-26

## README

[![Written in TypeScript](https://img.shields.io/badge/TypeScript-100%25-blue.svg)](https://github.com/cezaraugusto/random-from-array) [![npm](https://img.shields.io/npm/v/random-from-array.svg)]() [![Build Status](https://travis-ci.org/cezaraugusto/random-from-array.svg?branch=master)](https://travis-ci.org/cezaraugusto/random-from-array)

> TypeScript module with type definition support by default. Also works with other JavaScript projects.

# random-from-array

Given an array, return a random value from it.

## Useful when

An array of elements must output a random value.

## Installation

```sh
$ npm i random-from-array
```

## Usage

[Try it on CodeSandbox](https://codesandbox.io/s/5234j3wn6p)

```js
import randomFromArray from 'random-from-array'

randomFromArray(['bossa nova', 'jazz', 'rock']) // one of: 'bossa nova' or 'jazz' or 'rock'

// also works with an array of objects
const arrayOfObj = [
  { value: 'bossa nova' },
  { value: 'jazz' },
  { value: 'rock' }
]

randomFromArray(arrayOfObj) // one of: { value: 'bossa nova' } or { value: 'jazz' } or { value: 'rock' }
```

## License

random-from-array © [Cezar Augusto](https://twitter.com/cezaraugusto). Released under the MIT License.

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