Skip to content

Commit 4d1aaf7

Browse files
committed
introduce function getBib
for retrieving formatted reference for each item if requested via `options.include=bib`.
1 parent dbf3d06 commit 4d1aaf7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/response.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ class ApiResponse {
5555
return null;
5656
}
5757

58+
/**
59+
* Bib available in the response if requested via `options.include=bib`. Specialised classes provide extracted meta data depending on context.
60+
* @return {object}
61+
*/
62+
getBib() {
63+
if('bib' in this.raw) {
64+
return this.raw.bib;
65+
}
66+
return null;
67+
}
68+
5869
/**
5970
* Value of the "Last-Modified-Version" header in response if present. Specialised classes provide
6071
version depending on context
@@ -144,6 +155,14 @@ module:zotero-api-client~MultiReadResponse#getData}
144155
return this.raw.map(r => 'meta' in r && r.meta || null);
145156
}
146157

158+
/**
159+
* @return {Array} a list of formatted references (if requested via `options.include=bib`), indexes of the array match indexes of entities in {@link
160+
module:zotero-api-client~MultiReadResponse#getData}
161+
*/
162+
getBib() {
163+
return this.raw.map(r => 'bib' in r && r.bib || null);
164+
}
165+
147166
/**
148167
* @return {?number} Total number of results
149168
*/

0 commit comments

Comments
 (0)