Comparing version 0.3.0 to 0.3.1
{ | ||
"name": "node-ncbi", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Access and parse the NCBI eUtils API in Node or the Browser", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -7,3 +7,3 @@ # node-ncbi | ||
**Note:** Browser use isn't ideal right now due to the very large XML parser. I'll come with a dedicated script | ||
**Note:** Browser use isn't ideal due to the very large XML parser. I'll come with a dedicated script | ||
that relies on the browser's native DOM parsing to get around this. | ||
@@ -10,0 +10,0 @@ |
@@ -15,2 +15,8 @@ 'use strict'; | ||
const pmids = queries.ids(data); | ||
if (!pmids.length) { | ||
return { | ||
count: 0, | ||
papers: [] | ||
}; | ||
} | ||
return new Promise((resolve, reject) => { | ||
@@ -45,2 +51,3 @@ this.summaries(pmids).then(summaries => { | ||
var pmids = queries.findLinks('pubmed_pubmed_citedin', data); | ||
if (!pmids.length) return []; | ||
return this.summaries(pmids); | ||
@@ -53,2 +60,3 @@ }); | ||
var pmids = queries.findLinks('pubmed_pubmed_refs', data); | ||
if (!pmids.length) return []; | ||
return this.summaries(pmids); | ||
@@ -61,2 +69,3 @@ }); | ||
var pmids = queries.findLinks('pubmed_pubmed', data); | ||
if (!pmids.length) return []; | ||
return this.summaries(pmids); | ||
@@ -63,0 +72,0 @@ }); |
@@ -71,3 +71,3 @@ const update = require('react-addons-update'); | ||
} catch(e) { | ||
return null; | ||
return 0; | ||
} | ||
@@ -80,3 +80,3 @@ }, | ||
} catch(e) { | ||
return null; | ||
return []; | ||
} | ||
@@ -90,3 +90,3 @@ }, | ||
} catch(e) { | ||
return null; | ||
return []; | ||
} | ||
@@ -119,3 +119,3 @@ Object.keys(results).forEach(key => { | ||
} catch(e) { | ||
return null; | ||
return []; | ||
} | ||
@@ -122,0 +122,0 @@ }, |
@@ -104,2 +104,3 @@ /* eslint-env mocha, node */ | ||
describe('Pubmed module', function() { | ||
this.timeout(10000); | ||
@@ -120,2 +121,37 @@ it('should perform a search', function(done) { | ||
it('should return papers that are similar to this one', function(done) { | ||
pubmed.similar(19188495).then(results => { | ||
assert(areSummaries(results)); | ||
done(); | ||
}); | ||
}); | ||
it('should return a count of 0 if the search returns no results', function(done) { | ||
pubmed.search('boioioioioioioioioioioing').then(results => { | ||
assert.equal(results.count, 0); | ||
done(); | ||
}) | ||
}); | ||
it('should return null if an invalid pmid is passed', function(done) { | ||
pubmed.summary(0).then(results => { | ||
assert.equal(results, null); | ||
done(); | ||
}); | ||
}); | ||
it('should return an empty array if an invalid pmid is passed to a linking method', function(done) { | ||
pubmed.citedBy(0).then(results => { | ||
assert.equal(results.length, 0); | ||
done(); | ||
}); | ||
}); | ||
it('should return null if an invalid pmid is passed to the abstract method', function(done) { | ||
pubmed.abstract(0).then(results => { | ||
assert.equal(results, null); | ||
done(); | ||
}); | ||
}); | ||
}); |
77652
2021