# filled-array

> Returns an array filled with the specified input

Latest version **2.2.0** (published 2022-02-02) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2022-02-02 |
| First published | 2015-11-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=12 |
| Dependencies | 0 |
| Unpacked size | 3.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | array, elements, filled, repeat, repeating, string, text, fill |

## Links

- npm: https://www.npmjs.com/package/filled-array
- Repository: https://github.com/sindresorhus/filled-array
- Homepage: https://github.com/sindresorhus/filled-array#readme
- Issues: https://github.com/sindresorhus/filled-array/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/filled-array

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 2.2.0 (latest) — 2022-02-02
- 2.1.0 — 2022-01-05
- 2.0.0 — 2021-04-15
- 1.1.0 — 2015-11-07
- 1.0.2 — 2015-11-04
- 1.0.1 — 2015-11-04
- 1.0.0 — 2015-11-04

## README

# filled-array

> Returns an array filled with the specified input

## Install

```sh
npm install filled-array
```

## Usage

```js
import filledArray from 'filled-array';

filledArray('x', 3);
//=> ['x', 'x', 'x']

filledArray(0, 3);
//=> [0, 0, 0]

filledArray(index => {
	return (++index % 3 ? '' : 'Fizz') + (index % 5 ? '' : 'Buzz') || index;
}, 15);
//=> [1, 2, 'Fizz', 4, 'Buzz', 'Fizz', 7, 8, 'Fizz', 'Buzz', 11, 'Fizz', 13, 14, 'FizzBuzz']
```

## API

### filledArray(fillValue, count)

#### fillValue

Type: `unknown`

The value to fill the array with.

You can pass a function to generate the array items dynamically. The function is expected to return the value for each iteration and will be called with the following arguments: index, the count you passed in, and the filled array thus far.

#### count

Type: `number` *(non-negative integer)*

The number of items to fill the array with.

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