Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Story: Diff two feeds #29

Open
flyingzumwalt opened this issue Mar 15, 2016 · 0 comments
Open

Story: Diff two feeds #29

flyingzumwalt opened this issue Mar 15, 2016 · 0 comments

Comments

@flyingzumwalt
Copy link
Collaborator

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.

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

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))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant