0.1.2 • Published 1 year ago

webanno-compare-target-lists-pmb v0.1.2

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

webanno-compare-target-lists-pmb

Compare target lists of web annotations.

API

This module exports one function:

compareTargetLists(oldAnno, newAnno)

Takes two web annotations oldAnno and newAnno, which should be objects that hold a target key with arbitrary value. Ideally, the target values conform to the Web Annotation Data Model.

Returns a report, which is an object with these keys:

  • removed: Array of of targets that occurr only in oldAnno.
  • added: Array of targets that occurr only in newAnno.
  • commonInOld: Array of targets that occurr in both annotations, in the order they were found in oldAnno.
  • commonInNew: Array of targets that occurr in both annotations, in the order they were found in oldAnno.
  • commonSameOrder: Boolean, whether the lists of common targets are in same ordering. If there are no common targets, they are considered in same order.
  • reordered: Boolean, whether the lists of common targets differ in ordering. Opposite of commonSameOrder. They come as a pair to help you make your script fail more safely in case of future API changes.

Usage

see test/usage.mjs. from test/usage.mjs: :TODO:

var webanno-compare-target-lists-pmb = require('webanno-compare-target-lists-pmb');
D.result  = webanno-compare-target-lists-pmb(null);
D.expect('===',           null);
$ webanno-compare-target-lists-pmb foo
bar

Known issues

  • Needs more/better tests and docs.

 

License

ISC

0.1.2

1 year ago

0.1.0

1 year ago