From 4d1aaf7b4522aabf120693d7e1d50781711ca72f Mon Sep 17 00:00:00 2001 From: Peter Stadler Date: Wed, 26 Nov 2025 16:12:44 +0100 Subject: [PATCH] introduce function `getBib` for retrieving formatted reference for each item if requested via `options.include=bib`. --- src/response.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/response.js b/src/response.js index 0bf71f7..ee47181 100644 --- a/src/response.js +++ b/src/response.js @@ -55,6 +55,17 @@ class ApiResponse { return null; } + /** + * Bib available in the response if requested via `options.include=bib`. Specialised classes provide extracted meta data depending on context. + * @return {object} + */ + getBib() { + if('bib' in this.raw) { + return this.raw.bib; + } + return null; + } + /** * Value of the "Last-Modified-Version" header in response if present. Specialised classes provide version depending on context @@ -144,6 +155,14 @@ module:zotero-api-client~MultiReadResponse#getData} return this.raw.map(r => 'meta' in r && r.meta || null); } + /** + * @return {Array} a list of formatted references (if requested via `options.include=bib`), indexes of the array match indexes of entities in {@link +module:zotero-api-client~MultiReadResponse#getData} + */ + getBib() { + return this.raw.map(r => 'bib' in r && r.bib || null); + } + /** * @return {?number} Total number of results */