Skip to content

Commit

Permalink
Rename Citation class
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaasonen committed Mar 11, 2019
1 parent 47cfa57 commit fdda111
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/Reference.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

const _ = require('lodash')

class Citation {
static mergeAll (citations) {
return _(citations)
class Reference {
static mergeAll (references) {
return _(references)
.tail()
.reduce(
(merged, citation) => merged.merge(citation),
_.head(citations)
_.head(references)
)
}

Expand All @@ -16,16 +16,16 @@ class Citation {
this.pages = pages
}

merge (citation) {
if (this.document === citation.document) {
return new Citation(
merge (reference) {
if (this.document === reference.document) {
return new Reference(
this.document,
_(this.pages).union(citation.pages).sortBy().value()
_(this.pages).union(reference.pages).sortBy().value()
)
} else {
throw new Error(`Incompatible documents: "${this.document}" and "${citation.document}".`)
throw new Error(`Incompatible documents: "${this.document}" and "${reference.document}".`)
}
}
}

module.exports = Citation
module.exports = Reference

0 comments on commit fdda111

Please sign in to comment.