Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/allain/json-patch-stream
JSON-patch utilities for transforming a stream of JSON documents into a stream of JSON patches and vice versa
https://github.com/allain/json-patch-stream
Last synced: 3 months ago
JSON representation
JSON-patch utilities for transforming a stream of JSON documents into a stream of JSON patches and vice versa
- Host: GitHub
- URL: https://github.com/allain/json-patch-stream
- Owner: allain
- License: isc
- Created: 2015-01-01T15:12:47.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-01-01T15:28:05.000Z (about 10 years ago)
- Last Synced: 2024-10-10T17:50:41.839Z (3 months ago)
- Language: JavaScript
- Size: 113 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# json-patch-stream
JSON-patch utilities for transforming a stream of JSON documents into a stream of JSON patches and vice versa
[![build status](https://secure.travis-ci.org/allain/json-patch-stream.png)](http://travis-ci.org/allain/json-patch-stream)
## Installation
This module is installed via npm:
``` bash
$ npm install json-patch-stream
```## Example Usage
``` js
var streamify = require('stream-array'),
var stdout = require('stdout');var jsonPatchStream = require('json-patch-stream');
streamify([{"a": 10}, {"a": 20}])
.pipe(jsonPatchStream.toPatches())
.pipe(stdout());// Ouputs these two json patches
// [ { op: 'add', path: '/a', value: 10 } ]
// [ { op: 'test', path: '/a', value: 10 }, {} op: 'replace', path: '/a', value: 20 } ]streamify([
[ { op: 'add', path: '/a', value: 10 } ],
[ { op: 'test', path: '/a', value: 10 }, {} op: 'replace', path: '/a', value: 20 } ]
])
.pipe(jsonPatchStream.toDocs())
.pipe(stdout());// Outputs these two docs
// {"a": 10}
// {"a": 20}
```