# json-chain

> fluent chaining for json with dot-prop access

Latest version **0.0.3** (published 2017-04-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install json-chain
pnpm add json-chain
yarn add json-chain
bun add json-chain
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2017-04-06 |
| First published | 2017-04-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 30 |
| Author | James |
| Maintainers | aretecode |
| Keywords | json, fluent, chain, fliphub |

## Links

- npm: https://www.npmjs.com/package/json-chain
- Repository: https://github.com/fliphub/fliphub
- Homepage: https://github.com/fliphub/fliphub#readme
- Issues: https://github.com/fliphub/fliphub/issues
- npm.io page: https://npm.io/package/json-chain

## Dependencies (1)

- [dot-prop](https://npm.io/package/dot-prop.md) 4.1.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.0.3 (latest) — 2017-04-06
- 0.0.2 — 2017-04-03
- 0.0.1 — 2017-04-03

## README

# 🎀⛓ json-chain

> fluent chaining for json with dot-prop access

[![NPM version][json-chain-npm-image]][json-chain-npm-url]
[![MIT License][license-image]][license-url]
[![fliphub][gitter-badge]][gitter-url]
[![flipfam][flipfam-image]][flipfam-url]

[json-chain-npm-image]: https://img.shields.io/npm/v/json-chain.svg
[json-chain-npm-url]: https://npmjs.org/package/json-chain
[license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
[license-url]: https://spdx.org/licenses/MIT
[gitter-badge]: https://img.shields.io/gitter/room/fliphub/pink.svg
[gitter-url]: https://gitter.im/fliphub/Lobby
[flipfam-image]: https://img.shields.io/badge/%F0%9F%8F%97%20%F0%9F%92%A0-flipfam-9659F7.svg
[flipfam-url]: https://www.npmjs.com/package/flipfam

## 📦 usage
```bash
yarn add json-chain
npm i json-chain --save
```

```js
const JSONChain = require('json-chain')
```

## 📘 examples

```js
const data = {
  eh: ['og'],
  canada: true,
}

const chain = JSONChain.init(data).update('eh', ['some values'])
```

## 👓 reading json file

```js
const {readFileSync} = require('fs')

const pkg = readFileSync('./package.json', 'utf8')
const chain = new JSONChain(pkg)
  .parse() // will be done automatically, is optional
  .set('eh', ['some values']) // also as .update
  .del('eh') // also as .delete, .remove

// also as .val
const test = chain.get('scripts.test')
const has = chain.has('version')
```

## ✍ writing to file
- has `.toString` and `.toJSON` methods for auto-stringifying when cast to `string` or `JSON.stringify`

## 👾 keep it simple
```js
const chain = new JSONChain(pkg)
  .updateIfNotEmpty('scripts.test', 'ava --verbose')
  .updateIfNotEmpty('scripts.devDependencies', {'ava': '*'})
  .write()
```

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