# jsonvc

> A simple library for versioning JSON documents.

Latest version **0.0.0** (published 2015-07-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install jsonvc
pnpm add jsonvc
yarn add jsonvc
bun add jsonvc
```

## 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.0 |
| Published | 2015-07-05 |
| First published | 2015-07-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.10.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Naoto Yokoyama |
| Maintainers | builtinnya |
| Keywords | JSON |

## Links

- npm: https://www.npmjs.com/package/jsonvc
- Repository: https://github.com/builtinnya/jsonvc
- Issues: https://github.com/builtinnya/jsonvc/issues
- npm.io page: https://npm.io/package/jsonvc

## Dependencies (1)

- [node-uuid](https://npm.io/package/node-uuid.md) ^1.4.3

## 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.0 (latest) — 2015-07-05

## README

# jsonvc

[![Build Status](https://travis-ci.org/builtinnya/jsonvc.svg?branch=master)](https://travis-ci.org/builtinnya/jsonvc)
[![Coverage Status](https://coveralls.io/repos/builtinnya/jsonvc/badge.svg?branch=master)](https://coveralls.io/r/builtinnya/jsonvc?branch=master)
[![Code Climate](https://codeclimate.com/github/builtinnya/jsonvc/badges/gpa.svg)](https://codeclimate.com/github/builtinnya/jsonvc)
[![Dependency Status](https://david-dm.org/builtinnya/jsonvc.svg)](https://david-dm.org/builtinnya/jsonvc)
[![devDependency Status](https://david-dm.org/builtinnya/jsonvc/dev-status.svg)](https://david-dm.org/builtinnya/jsonvc#info=devDependencies)


jsonvc is a simple library for versioning JSON documents.

> jsonvc is still an experimental library and unstable.

jsonvc is intended to be used in developing web applications which need simple document versioning, where

- NoSQL backend is used
- Many small updates are made on large documents

## Examples

To create and initialize a versioned document:

```javascript
var jsonvc = require('jsonvc');

// Create a new versioned document from a normal document
var vdoc = jsonvc.init({ a: 1 });

// Or from an existing versioned document
var doc = vdoc.dumpDoc();
var repository = vdoc.dump();
var vdoc2 = jsonvc.load(doc, repository);
```

To update the document:

```javascript
// Create a new commit and update the document to { a: 1, b: 2 }
vdoc.update({ a: 1, b: 1 });
```

To restore the document by a commit ID:

```javascript
var vdoc = jsonvc.init({ a: 1 });

// Remember the first commit ID
var firstCommitId = vdoc.head;

vdoc.update({ a: 1, b: 1 });

// Now, vdoc has two commits and the current document is { a: 1, b: 1 }

// Create a new commit from the latest commit to restore the first document
vdoc.restore(firstCommitId);

// Now, vdoc has three commits and the current document is { a: 1 }
```

Use `.dump()` and `.dumpDoc()` to output the repository and the document, respectively:

```javascript
var vdoc = jsonvc.init({ a: 1 });

vdoc.dump();    // => internal object which represents the repository
vdoc.dumpDoc(); // => { a: 1 }
```

## Installation

### Node

Using [npm](https://www.npmjs.com/):

```shell
npm install --save jsonvc
```

### Browser

You can use [Browserify](http://browserify.org/) or [Webpack](http://webpack.github.io/) or whatever you want.

## Contributing to jsonvc

Any ideas, feature requests, pull requests are welcomed.
Please add the relevant tests and ensure that it passes all the tests by executing
`npm test` before submitting a pull request.

## License

Copyright © 2015 Naoto Yokoyama

Distributed under the MIT license. See the [LICENSE](./LICENSE) file for full details.

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