@iebh/reflib 2.4.4 → 2.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/default.js CHANGED
@@ -5,6 +5,7 @@ import {readStream} from './readStream.js';
5
5
  import {readFile} from './readFile.js';
6
6
  import {writeStream} from './writeStream.js';
7
7
  import {writeFile} from './writeFile.js';
8
+ import { getRefDoi } from './getRefDoi.js';
8
9
 
9
10
  export {
10
11
  formats,
@@ -14,6 +15,7 @@ export {
14
15
  readStream,
15
16
  writeFile,
16
17
  writeStream,
18
+ getRefDoi
17
19
  };
18
20
 
19
21
  export default {
@@ -24,4 +26,5 @@ export default {
24
26
  readStream,
25
27
  writeFile,
26
28
  writeStream,
29
+ getRefDoi
27
30
  };
package/lib/formats.js CHANGED
@@ -46,7 +46,7 @@ export let formats = {
46
46
  id: 'ris',
47
47
  title: 'RIS',
48
48
  titleShort: 'RIS',
49
- ext: ['.ris','.txt', '.cgi'],
49
+ ext: ['.ris','.txt','.cgi'],
50
50
  canRead: true,
51
51
  canWrite: true,
52
52
  },
@@ -0,0 +1,16 @@
1
+ // @returns {Object} The modified ref object with the updated DOI
2
+ /**
3
+ * Identify DOI in the format(eg: 'https://dx.doi.org/10.1186/s40504-020-00106-2'), extract DOI number only(eg:'10.1186/s40504-020-00106-2')and return the ref object
4
+ * @param {Object} ref The input object to identify and change DOI format
5
+ *@returns {string|null} The modified DOI or null if no DOI is available
6
+ */
7
+ export function getRefDoi(ref) {
8
+ if (ref.doi) {
9
+ const doiPrefix = 'https://dx.doi.org/';
10
+ if (ref.doi.startsWith(doiPrefix)) {
11
+ ref.doi = ref.doi.slice(doiPrefix.length);
12
+ }
13
+ return ref.doi;
14
+ }
15
+ return null;
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iebh/reflib",
3
- "version": "2.4.4",
3
+ "version": "2.4.6",
4
4
  "description": "Reference / Citation reference library utilities",
5
5
  "scripts": {
6
6
  "lint": "eslint .",