git ssb

0+

cel / pull-kvdiff



Tree: 6b8f19fb3b608e0c8d3ebdb9053a18257e6fe9d3

Files: 6b8f19fb3b608e0c8d3ebdb9053a18257e6fe9d3 / README.md

996 bytesRaw

pull-kvdiff

diff key-value streams

var pull = require('pull-stream')
var kvdiff = require('pull-kvdiff')

pull(
  kvdiff([
    pull.values([
      {key: 'a', value: 1},
      {key: 'b', value: 2},
      {key: 'c', value: 3},
    ]),
    pull.values([
      {key: 'a', value: 1},
      {key: 'b', value: 3},
      {key: 'd', value: 3},
    ])
  ], 'key'),
  pull.log()
)

output:

{ key: 'b',
  values: [ { key: 'b', value: 2 }, { key: 'b', value: 3 } ],
  diff: { value: [ 2, 3 ] } }
{ key: 'c',
  values: [ { key: 'c', value: 3 },  ],
  diff: { key: [ 'c' ], value: [ 3 ] } }
{ key: 'd',
  values: [ , { key: 'd', value: 3 } ],
  diff: { key: [ , 'd' ], value: [ , 3 ] } }

kvdiff(sources, keyProp) → source

License

Copyright (c) 2016 Charles Lehner

Usage of the works is permitted provided that this instrument is retained with the works, so that any entity that uses the works is notified of this instrument.

DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.

Built with git-ssb-web