@iebh/reflib 2.7.2 → 2.8.1

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/fields.js CHANGED
@@ -1,158 +1,158 @@
1
- /**
2
- * Field definitions for Reflib citations
3
- * @type {Object} An object lookup where each key represents a field within a citation
4
- * @property {string} type A TypeScript compatible type for that field
5
- * @property {array<string>} [value] Possible values if the type is restricted
6
- */
7
- export let fields = {
8
- recNumber: {
9
- type: 'string',
10
- },
11
- type: {
12
- type: 'string',
13
- values: [
14
- 'aggregatedDatabase',
15
- 'ancientText',
16
- 'artwork',
17
- 'audioVisualMaterial',
18
- 'bill',
19
- 'blog',
20
- 'book',
21
- 'bookSection',
22
- 'case',
23
- 'catalog',
24
- 'chartOrTable',
25
- 'classicalWork',
26
- 'computerProgram',
27
- 'conferencePaper',
28
- 'conferenceProceedings',
29
- 'dataset',
30
- 'dictionary',
31
- 'editedBook',
32
- 'electronicArticle',
33
- 'electronicBook',
34
- 'electronicBookSection',
35
- 'encyclopedia',
36
- 'equation',
37
- 'figure',
38
- 'filmOrBroadcast',
39
- 'generic',
40
- 'governmentDocument',
41
- 'grant',
42
- 'hearing',
43
- 'journalArticle',
44
- 'legalRuleOrRegulation',
45
- 'agazineArticle',
46
- 'manuscript',
47
- 'map',
48
- 'music',
49
- 'newspaperArticle',
50
- 'onlineDatabase',
51
- 'onlineMultimedia',
52
- 'pamphlet',
53
- 'patent',
54
- 'personalCommunication',
55
- 'report',
56
- 'serial',
57
- 'standard',
58
- 'statute',
59
- 'thesis',
60
- 'unknown',
61
- 'unpublished',
62
- 'web',
63
- ],
64
- },
65
- title: {
66
- type: 'string',
67
- },
68
- journal: {
69
- type: 'string',
70
- },
71
- authors: {
72
- type: 'array<string>',
73
- },
74
- date: {
75
- type: 'string',
76
- },
77
- urls: {
78
- type: 'array<string>',
79
- },
80
- pages: {
81
- type: 'string',
82
- },
83
- volume: {
84
- type: 'string',
85
- },
86
- number: {
87
- type: 'string',
88
- },
89
- isbn: {
90
- type: 'string',
91
- },
92
- abstract: {
93
- type: 'string',
94
- },
95
- label: {
96
- type: 'string',
97
- },
98
- caption: {
99
- type: 'string',
100
- },
101
- notes: {
102
- type: 'string',
103
- },
104
- address: {
105
- type: 'string',
106
- },
107
- researchNotes: {
108
- type: 'string',
109
- },
110
- keywords: {
111
- type: 'array<string>',
112
- },
113
- accessDate: {
114
- type: 'string',
115
- },
116
- accession: {
117
- type: 'string',
118
- },
119
- doi: {
120
- type: 'string',
121
- },
122
- section: {
123
- type: 'string',
124
- },
125
- language: {
126
- type: 'string',
127
- },
128
- databaseProvider: {
129
- type: 'string',
130
- },
131
- database: {
132
- type: 'string',
133
- },
134
- workType: {
135
- type: 'string',
136
- },
137
- custom1: {
138
- type: 'string',
139
- },
140
- custom2: {
141
- type: 'string',
142
- },
143
- custom3: {
144
- type: 'string',
145
- },
146
- custom4: {
147
- type: 'string',
148
- },
149
- custom5: {
150
- type: 'string',
151
- },
152
- custom6: {
153
- type: 'string',
154
- },
155
- custom7: {
156
- type: 'string',
157
- },
158
- };
1
+ /**
2
+ * Field definitions for Reflib citations
3
+ * @type {Object} An object lookup where each key represents a field within a citation
4
+ * @property {string} type A TypeScript compatible type for that field
5
+ * @property {array<string>} [value] Possible values if the type is restricted
6
+ */
7
+ export let fields = {
8
+ recNumber: {
9
+ type: 'string',
10
+ },
11
+ type: {
12
+ type: 'string',
13
+ values: [
14
+ 'aggregatedDatabase',
15
+ 'ancientText',
16
+ 'artwork',
17
+ 'audioVisualMaterial',
18
+ 'bill',
19
+ 'blog',
20
+ 'book',
21
+ 'bookSection',
22
+ 'case',
23
+ 'catalog',
24
+ 'chartOrTable',
25
+ 'classicalWork',
26
+ 'computerProgram',
27
+ 'conferencePaper',
28
+ 'conferenceProceedings',
29
+ 'dataset',
30
+ 'dictionary',
31
+ 'editedBook',
32
+ 'electronicArticle',
33
+ 'electronicBook',
34
+ 'electronicBookSection',
35
+ 'encyclopedia',
36
+ 'equation',
37
+ 'figure',
38
+ 'filmOrBroadcast',
39
+ 'generic',
40
+ 'governmentDocument',
41
+ 'grant',
42
+ 'hearing',
43
+ 'journalArticle',
44
+ 'legalRuleOrRegulation',
45
+ 'agazineArticle',
46
+ 'manuscript',
47
+ 'map',
48
+ 'music',
49
+ 'newspaperArticle',
50
+ 'onlineDatabase',
51
+ 'onlineMultimedia',
52
+ 'pamphlet',
53
+ 'patent',
54
+ 'personalCommunication',
55
+ 'report',
56
+ 'serial',
57
+ 'standard',
58
+ 'statute',
59
+ 'thesis',
60
+ 'unknown',
61
+ 'unpublished',
62
+ 'web',
63
+ ],
64
+ },
65
+ title: {
66
+ type: 'string',
67
+ },
68
+ journal: {
69
+ type: 'string',
70
+ },
71
+ authors: {
72
+ type: 'array<string>',
73
+ },
74
+ date: {
75
+ type: 'string',
76
+ },
77
+ urls: {
78
+ type: 'array<string>',
79
+ },
80
+ pages: {
81
+ type: 'string',
82
+ },
83
+ volume: {
84
+ type: 'string',
85
+ },
86
+ number: {
87
+ type: 'string',
88
+ },
89
+ isbn: {
90
+ type: 'string',
91
+ },
92
+ abstract: {
93
+ type: 'string',
94
+ },
95
+ label: {
96
+ type: 'string',
97
+ },
98
+ caption: {
99
+ type: 'string',
100
+ },
101
+ notes: {
102
+ type: 'string',
103
+ },
104
+ address: {
105
+ type: 'string',
106
+ },
107
+ researchNotes: {
108
+ type: 'string',
109
+ },
110
+ keywords: {
111
+ type: 'array<string>',
112
+ },
113
+ accessDate: {
114
+ type: 'string',
115
+ },
116
+ accession: {
117
+ type: 'string',
118
+ },
119
+ doi: {
120
+ type: 'string',
121
+ },
122
+ section: {
123
+ type: 'string',
124
+ },
125
+ language: {
126
+ type: 'string',
127
+ },
128
+ databaseProvider: {
129
+ type: 'string',
130
+ },
131
+ database: {
132
+ type: 'string',
133
+ },
134
+ workType: {
135
+ type: 'string',
136
+ },
137
+ custom1: {
138
+ type: 'string',
139
+ },
140
+ custom2: {
141
+ type: 'string',
142
+ },
143
+ custom3: {
144
+ type: 'string',
145
+ },
146
+ custom4: {
147
+ type: 'string',
148
+ },
149
+ custom5: {
150
+ type: 'string',
151
+ },
152
+ custom6: {
153
+ type: 'string',
154
+ },
155
+ custom7: {
156
+ type: 'string',
157
+ },
158
+ };
package/lib/formats.js CHANGED
@@ -1,85 +1,85 @@
1
- /**
2
- * Lookup table of various citation file formats
3
- * @type {array<Object>} A collection of Reflib supported file formats
4
- * @property {string} title The long form title of the format
5
- * @property {string} titleShort Shorter title of the format
6
- * @property {string} input Input format required by parser
7
- * @property {string} output Output format required by formatter
8
- * @property {Array<String>} ext File extensions of this format, the first entry is generally used as the output default
9
- * @property {boolean} canRead Whether the format is supported when reading a citation library
10
- * @property {boolean} canWrite Whether the format is supported when writing a citation library
11
- */
12
- export let formats = {
13
- bibtex: {
14
- id: 'bibtex',
15
- title: 'BibTeX',
16
- titleShort: 'BibTeX',
17
- ext: ['.bib'],
18
- canRead: true,
19
- canWrite: true,
20
- },
21
- csv: {
22
- id: 'csv',
23
- title: 'Comma Seperated Values',
24
- titleShort: 'CSV',
25
- ext: ['.csv'],
26
- canRead: false,
27
- canWrite: false,
28
- },
29
- endnoteEnl: {
30
- id: 'endnoteEnl',
31
- title: 'EndNote ENL',
32
- titleShort: 'EndNote',
33
- ext: ['.enl'],
34
- canRead: true,
35
- canWrite: true,
36
- },
37
- endnoteEnlX: {
38
- id: 'endnoteEnlX',
39
- title: 'EndNote ENLX',
40
- titleShort: 'EndNote ENLX',
41
- ext: ['.enlx'],
42
- canRead: true,
43
- canWrite: false,
44
- },
45
- endnoteXml: {
46
- id: 'endnoteXml',
47
- title: 'EndNoteXML',
48
- titleShort: 'EndNoteXML',
49
- ext: ['.xml'],
50
- canRead: true,
51
- canWrite: true,
52
- },
53
- json: {
54
- id: 'json',
55
- title: 'JSON',
56
- titleShort: 'JSON',
57
- ext: ['.json'],
58
- canRead: true,
59
- canWrite: true,
60
- },
61
- medline: {
62
- id: 'medline',
63
- title: 'MEDLINE / PubMed',
64
- titleShort: 'MEDLINE',
65
- ext: ['.nbib'],
66
- canRead: true,
67
- canWrite: true,
68
- },
69
- ris: {
70
- id: 'ris',
71
- title: 'RIS',
72
- titleShort: 'RIS',
73
- ext: ['.ris','.txt','.cgi'],
74
- canRead: true,
75
- canWrite: true,
76
- },
77
- tsv: {
78
- id: 'tsv',
79
- title: 'Tab Seperated Values',
80
- titleShort: 'TSV',
81
- ext: ['.tsv'],
82
- canRead: false,
83
- canWrite: false,
84
- },
85
- }
1
+ /**
2
+ * Lookup table of various citation file formats
3
+ * @type {array<Object>} A collection of Reflib supported file formats
4
+ * @property {string} title The long form title of the format
5
+ * @property {string} titleShort Shorter title of the format
6
+ * @property {string} input Input format required by parser
7
+ * @property {string} output Output format required by formatter
8
+ * @property {Array<String>} ext File extensions of this format, the first entry is generally used as the output default
9
+ * @property {boolean} canRead Whether the format is supported when reading a citation library
10
+ * @property {boolean} canWrite Whether the format is supported when writing a citation library
11
+ */
12
+ export let formats = {
13
+ bibtex: {
14
+ id: 'bibtex',
15
+ title: 'BibTeX',
16
+ titleShort: 'BibTeX',
17
+ ext: ['.bib'],
18
+ canRead: true,
19
+ canWrite: true,
20
+ },
21
+ csv: {
22
+ id: 'csv',
23
+ title: 'Comma Seperated Values',
24
+ titleShort: 'CSV',
25
+ ext: ['.csv'],
26
+ canRead: false,
27
+ canWrite: false,
28
+ },
29
+ endnoteEnl: {
30
+ id: 'endnoteEnl',
31
+ title: 'EndNote ENL',
32
+ titleShort: 'EndNote',
33
+ ext: ['.enl'],
34
+ canRead: true,
35
+ canWrite: true,
36
+ },
37
+ endnoteEnlX: {
38
+ id: 'endnoteEnlX',
39
+ title: 'EndNote ENLX',
40
+ titleShort: 'EndNote ENLX',
41
+ ext: ['.enlx'],
42
+ canRead: true,
43
+ canWrite: false,
44
+ },
45
+ endnoteXml: {
46
+ id: 'endnoteXml',
47
+ title: 'EndNoteXML',
48
+ titleShort: 'EndNoteXML',
49
+ ext: ['.xml'],
50
+ canRead: true,
51
+ canWrite: true,
52
+ },
53
+ json: {
54
+ id: 'json',
55
+ title: 'JSON',
56
+ titleShort: 'JSON',
57
+ ext: ['.json'],
58
+ canRead: true,
59
+ canWrite: true,
60
+ },
61
+ medline: {
62
+ id: 'medline',
63
+ title: 'MEDLINE / PubMed',
64
+ titleShort: 'MEDLINE',
65
+ ext: ['.nbib'],
66
+ canRead: true,
67
+ canWrite: true,
68
+ },
69
+ ris: {
70
+ id: 'ris',
71
+ title: 'RIS',
72
+ titleShort: 'RIS',
73
+ ext: ['.ris','.txt','.cgi'],
74
+ canRead: true,
75
+ canWrite: true,
76
+ },
77
+ tsv: {
78
+ id: 'tsv',
79
+ title: 'Tab Seperated Values',
80
+ titleShort: 'TSV',
81
+ ext: ['.tsv'],
82
+ canRead: false,
83
+ canWrite: false,
84
+ },
85
+ }
package/lib/getModule.js CHANGED
@@ -1,39 +1,39 @@
1
- import * as modules from '../modules/default.js';
2
-
3
- let hasSetup = new Set(); // Modules we have already setup
4
-
5
- /**
6
- * Simple wrapper which loads the named module as a keyed lirary of functions
7
- *
8
- * @param {string} module The module ID as per `lib/formats.js`
9
- * @param {Object} [options] Additional options to use when fetching the module
10
- * @param {boolean} [options.setup=true] Call the `setup()` function on any module requested before use
11
- *
12
- * @returns {Object} The loaded module as an object of standardised functionality
13
- */
14
- export function getModule(module, options) {
15
- // Sanity checking
16
- if (!module) throw new Error('No module provided');
17
-
18
- // Argument mangling
19
- let settings = {
20
- setup: true,
21
- ...options,
22
- };
23
-
24
- // Try to find the module
25
- let mod = modules[module];
26
- if (!mod) throw new Error(`Unknown module "${module}"`);
27
-
28
- // Should setup and module exposes a setup function?
29
- if (
30
- mod.setup // We should set up...
31
- && settings.setup // AND the module has a function to do so...
32
- && !hasSetup.has(module) // AND we've not setup before
33
- ) {
34
- hasSetup.add(module);
35
- mod.setup();
36
- }
37
-
38
- return mod;
39
- }
1
+ import * as modules from '../modules/default.js';
2
+
3
+ let hasSetup = new Set(); // Modules we have already setup
4
+
5
+ /**
6
+ * Simple wrapper which loads the named module as a keyed lirary of functions
7
+ *
8
+ * @param {string} module The module ID as per `lib/formats.js`
9
+ * @param {Object} [options] Additional options to use when fetching the module
10
+ * @param {boolean} [options.setup=true] Call the `setup()` function on any module requested before use
11
+ *
12
+ * @returns {Object} The loaded module as an object of standardised functionality
13
+ */
14
+ export function getModule(module, options) {
15
+ // Sanity checking
16
+ if (!module) throw new Error('No module provided');
17
+
18
+ // Argument mangling
19
+ let settings = {
20
+ setup: true,
21
+ ...options,
22
+ };
23
+
24
+ // Try to find the module
25
+ let mod = modules[module];
26
+ if (!mod) throw new Error(`Unknown module "${module}"`);
27
+
28
+ // Should setup and module exposes a setup function?
29
+ if (
30
+ mod.setup // We should set up...
31
+ && settings.setup // AND the module has a function to do so...
32
+ && !hasSetup.has(module) // AND we've not setup before
33
+ ) {
34
+ hasSetup.add(module);
35
+ mod.setup();
36
+ }
37
+
38
+ return mod;
39
+ }
package/lib/getRefDoi.js CHANGED
@@ -1,16 +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
- }
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
+ }
@@ -1,13 +1,13 @@
1
- import {formats} from '../lib/formats.js';
2
-
3
- /**
4
- * Identify and return the Reflib format (from ./formats) to use for the given file name / path
5
- * @param {string} path The input path to identify
6
- * @returns {Object} A matching entry from ./formats or null if no matching format was found
7
- */
8
- export function identifyFormat(path) {
9
- let ext = /^.*(?<ext>\..+?)$/.exec(path)?.groups.ext.toLowerCase();
10
- if (!ext) return null;
11
-
12
- return Object.values(formats).find(format => format.ext.includes(ext));
13
- }
1
+ import {formats} from '../lib/formats.js';
2
+
3
+ /**
4
+ * Identify and return the Reflib format (from ./formats) to use for the given file name / path
5
+ * @param {string} path The input path to identify
6
+ * @returns {Object} A matching entry from ./formats or null if no matching format was found
7
+ */
8
+ export function identifyFormat(path) {
9
+ let ext = /^.*(?<ext>\..+?)$/.exec(path)?.groups.ext.toLowerCase();
10
+ if (!ext) return null;
11
+
12
+ return Object.values(formats).find(format => format.ext.includes(ext));
13
+ }