Skip to content

Commit a757f44

Browse files
authored
fix: Revert "fix: Remove unnecessary use of underscore for Array find/filter/map. Bump dcmjs version" (#49)
This reverts commit 8b3ecfe.
1 parent e7aa179 commit a757f44

File tree

3 files changed

+33
-26
lines changed

3 files changed

+33
-26
lines changed

package-lock.json

Lines changed: 26 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"axios": "^0.19.0",
99
"chai": "^4.2.0",
1010
"chai-http": "^4.3.0",
11-
"dcmjs": "0.13.2",
11+
"dcmjs": "0.8.3",
1212
"fastify": "^2.10.0",
1313
"fastify-basic-auth": "^0.5.0",
1414
"fastify-cors": "^3.0.0",
@@ -23,6 +23,7 @@
2323
"p-queue": "^6.2.1",
2424
"split2": "^3.1.1",
2525
"to-array-buffer": "^3.2.0",
26+
"underscore": "^1.9.1",
2627
"xmlhttprequest": "^1.8.0"
2728
},
2829
"devDependencies": {

plugins/CouchDB.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable no-underscore-dangle, no-async-promise-executor */
22
const fp = require('fastify-plugin');
3+
const _ = require('underscore');
34
const toArrayBuffer = require('to-array-buffer');
45
// eslint-disable-next-line no-global-assign
56
window = {};
@@ -176,7 +177,7 @@ async function couchdb(fastify, options) {
176177
Promise.all([bodySeriesInfo, bodyStudies])
177178
.then(values => {
178179
const studies = {};
179-
studies.rows = values[1].rows.filter(obj =>
180+
studies.rows = _.filter(values[1].rows, obj =>
180181
fastify.queryObj(request.query, obj.key[1], queryKeys)
181182
);
182183
const res = [];
@@ -222,7 +223,7 @@ async function couchdb(fastify, options) {
222223
// if both studies have values, cumulate them but don't make duplicates
223224
(typeof studySeriesObj[tag].Value[0] === 'string' &&
224225
!studySeriesObj[tag].Value.includes(val)) ||
225-
!studySeriesObj[tag].Value.findIndex(val) === -1
226+
!_.findIndex(studySeriesObj[tag].Value, val) === -1
226227
) {
227228
studySeriesObj[tag].Value.push(val);
228229
}
@@ -743,7 +744,7 @@ async function couchdb(fastify, options) {
743744
},
744745
async (error, body) => {
745746
if (!error) {
746-
const docs = body.rows.map(instance => {
747+
const docs = _.map(body.rows, instance => {
747748
return { _id: instance.key[2], _rev: instance.doc._rev, _deleted: true };
748749
});
749750
await fastify.dbPqueue.add(() => {
@@ -787,7 +788,7 @@ async function couchdb(fastify, options) {
787788
},
788789
async (error, body) => {
789790
if (!error) {
790-
const docs = body.rows.map(instance => {
791+
const docs = _.map(body.rows, instance => {
791792
return { _id: instance.key[2], _rev: instance.doc._rev, _deleted: true };
792793
});
793794
await fastify.dbPqueue.add(() => {

0 commit comments

Comments
 (0)