# @cat5th/key-serializer

> serilize keys and query keys deep in an object

Latest version **0.2.5** (published 2019-03-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @cat5th/key-serializer
pnpm add @cat5th/key-serializer
yarn add @cat5th/key-serializer
bun add @cat5th/key-serializer
```

## Health

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

Positive: has types; high quality score.

Warnings: low downloads; no esm support; has vulnerabilities; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.5 |
| Published | 2019-03-23 |
| First published | 2018-11-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 342.1 KB |
| Known vulnerabilities | 1 |
| Install scripts | no |
| Author | Harvey.Woo |
| Maintainers | alphmega |
| Keywords | key, serializer |

## Links

- npm: https://www.npmjs.com/package/@cat5th/key-serializer
- Repository: https://github.com/harvey-woo/key-serializer
- Homepage: https://github.com/harvey-woo/key-serializer#readme
- Issues: https://github.com/harvey-woo/key-serializer/issues
- npm.io page: https://npm.io/package/@cat5th/key-serializer

## Recent versions

- 0.2.5 (latest) — 2019-03-23
- 0.2.1 — 2019-03-23
- 0.2.4 — 2019-03-23
- 0.2.3 — 2019-03-23
- 0.2.0 — 2018-11-08
- 0.1.7 — 2018-11-02
- 0.1.6 — 2018-11-02
- 0.1.5 — 2018-11-02
- 0.1.4 — 2018-11-02
- 0.1.3 — 2018-11-02
- 0.1.0 — 2018-11-01

## README

# key-serializer
serilize keys and query keys deep in an object

[documentation](https://harvey-woo.github.io/key-serializer/index.html)

[![npm version](https://img.shields.io/npm/v/@cat5th/key-serializer.svg?style=flat-square)](https://www.npmjs.com/package/@cat5th/key-serializer)
[![coverage](https://img.shields.io/codecov/c/github/harvey-woo/key-serializer.svg?style=flat-square)](https://codecov.io/gh/harvey-woo/key-serializer)
[![npm downloads](https://img.shields.io/npm/dt/@cat5th/key-serializer.svg?style=flat-square)](https://www.npmjs.com/package/@cat5th/key-serializer)
[![Build Status](https://img.shields.io/travis/harvey-woo/key-serializer.svg?style=flat-square)](https://travis-ci.org/harvey-woo/key-serializer)

## how to use
It is very easy to get value of keys deep into your object, or stringify keys to a string from array

### import serializer
```javascript
import keySerializer from '@cat5th/key-serializer'
```

### stringify keys

```javascript
keySerializer.stringify(['a', 1, 'b', 0])
// result: "a[1].b[0]"
```
### parse keys

```javascript
keySerializer.parse('a[1].b[0]')
// result: ['a', 1, 'b', 0]
```
### query object

```javascript
const obj = { a: [{ b: [1, 2], c: [3, 4] }, { b: [5, 6], c: [7, 8] }] }
keySerializer.query(obj, 'a[1].b[0]')
// result: { value: 5, key: 0, target: [5, 6]}
```
### get value
```javascript
keySerializer.get(obj, 'a[1].b[0]')
// result: 5
```

### set value
```javascript
keySerializer.set(obj, 'a[1].b[0]', 1)
console.log(obj.a[1].b[0])
// result: 1
```
> **notice**: get/set/query function will throw TypeError when target is null or undefined, keep in mind, and always use get/query in try block

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