From a61273b5f9536761bb20ac921d4fc831aa555621 Mon Sep 17 00:00:00 2001 From: Richard Doe <richard.doe@rwdit.net> Date: Fri, 13 Dec 2019 13:40:34 +0000 Subject: [PATCH] Document and lint annotationListUris --- src/lib/ManifestoCanvas.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/lib/ManifestoCanvas.js b/src/lib/ManifestoCanvas.js index ea5e5da1c..70f8786e6 100644 --- a/src/lib/ManifestoCanvas.js +++ b/src/lib/ManifestoCanvas.js @@ -34,17 +34,19 @@ export default class ManifestoCanvas { return this.canvas.getWidth() / this.canvas.getHeight(); } - /** */ + /** + * Fetches AnnotationList URIs from canvas's otherContent property + * + * Supported otherContent types: + * - Objects having @type property of "sc:AnnotationList" and URI in @id + * - Strings being the URIs + */ get annotationListUris() { return flatten( new Array(this.canvas.__jsonld.otherContent), // eslint-disable-line no-underscore-dangle ) - .filter((otherContent) => { - return otherContent && (typeof otherContent === 'string' || otherContent['@type'] === 'sc:AnnotationList'); - }) - .map((otherContent) => { - return typeof otherContent === 'string' ? otherContent : otherContent['@id']; - }); + .filter(otherContent => otherContent && (typeof otherContent === 'string' || otherContent['@type'] === 'sc:AnnotationList')) + .map(otherContent => (typeof otherContent === 'string' ? otherContent : otherContent['@id'])); } /** */ -- GitLab