# object-with-keys

> Turn an array of string values into an object with the string values as keys

Latest version **1.0.0** (published 2016-10-30) · ISC license · 0 weekly downloads

## Install

```sh
npm install object-with-keys
pnpm add object-with-keys
yarn add object-with-keys
bun add object-with-keys
```

## 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-10-30 |
| First published | 2016-10-30 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | "Kan Adachi |
| Maintainers | obber |
| Keywords | object, from, array, of, keys |

## Links

- npm: https://www.npmjs.com/package/object-with-keys
- Repository: https://github.com/obber/object-with-keys
- Homepage: https://github.com/obber/object-with-keys#readme
- Issues: https://github.com/obber/object-with-keys/issues
- npm.io page: https://npm.io/package/object-with-keys

## Recent versions

- 1.0.0 (latest) — 2016-10-30

## README

# objectWithKeys

Simple utility function to turn an array of strings/numbers into an object with the strings/numbers from the array as keys.

This function takes in an optional default value as the second argument.

## Install:

```bash
npm install object-with-keys
```

or

```bash
yarn add object-with-keys
```

## Usage:

```javascript
var objectWithKeys = require('object-with-keys');

var initialState = objectWithKeys([
  0, 1, 2, 3, 4, 5, 6, 7, 8
], 0);

console.log(initialState); /* =>
  {
    0: 0,
    1: 0,
    2: 0,
    3: 0,
    4: 0,
    5: 0,
    6: 0,
    7: 0,
    8: 0
  }
*/
```

This function is useful for creating empty, initial state objects in state trees like ngrx/store or redux.

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