CodeForPhilly / CodeForPhilly/jawn
Story: Diff two feeds
- Dominant language
- JavaScript
- Stars
- 46
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
**This is a Work in Progress**
If I run `jawn.diff(feedOneId, feedTwoId)` I should get a stream of json objects representing actions (add/update/delete).
If I apply all of the actions in that stream to the database/repository represented by `feedOne`, its contents should then match `feedTwo`.
## Running a diff
Checkout a feed, run a diff and print the results of the diff.
``` javascript
var jawn = require('jawn');
var through = require('through2').obj;
var checkout = jawn.checkout(feedOneId);
checkout.on('end', function () {
jawn.diff(feedOneId, feedTwoId).pipe(process.stdout)
});
```
The output should look roughly like this: (see 2015 dat beta for real examples)
```
{ action: "add", key: 9812349878, values: {...} }
{ action: "delete", key: 23421341234 }
```
## Applying a diff using (hypothetical) jawn.applyActionStream function
``` javascript
var jawn = require('jawn');
var through = require('through2').obj;
var checkout = jawn.checkout(feedOneId);
var applyActions = jawn.applyActionStream
checkout.on('end', function () {
jawn.diff(feedOneId, feedTwoId).pipe(applyActions)
})
applyActions.on('end', function () {
// the current contents of the repo should match the contents of feedTwo
t.same('', jawn.diff(jawn.current, feedTwoId))
})
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.