cht-nootils
Advanced tools
Comparing version 4.1.0 to 4.2.0
{ | ||
"name": "cht-nootils", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"description": "CHT extensions for Nools for use in tasks-rules", | ||
@@ -5,0 +5,0 @@ "main": "src/nootils.js", |
@@ -44,6 +44,9 @@ const _ = require('underscore'); | ||
getMostRecentReport: function(reports, form, fields) { | ||
getMostRecentReport: function(reports, forms, fields) { | ||
if (!Array.isArray(forms)) { | ||
forms = [forms]; | ||
} | ||
let result = null; | ||
reports.forEach(function(report) { | ||
if (report.form === form && | ||
if (forms.includes(report.form) && | ||
!report.deleted && | ||
@@ -50,0 +53,0 @@ (!result || (report.reported_date > result.reported_date)) && |
@@ -102,2 +102,16 @@ const { expect } = require('chai'); | ||
it('returns most recent matching report from multiple forms', () => { | ||
const reports = [ | ||
{ _id: 6, form: 'B', reported_date: 9 }, | ||
{ _id: 3, form: 'V', reported_date: 3 }, | ||
{ _id: 4, form: 'H', reported_date: 4 }, | ||
{ _id: 2, form: 'V', reported_date: 2 }, | ||
{ _id: 5, form: 'A', reported_date: 6 }, | ||
{ _id: 1, form: 'H', reported_date: 1 }, | ||
{ _id: 7, form: 'C', reported_date: 12 }, | ||
]; | ||
const actual = nootils.getMostRecentReport(reports, ['H', 'V']); | ||
expect(actual._id).to.eq(4); | ||
}); | ||
it('ignores deleted reports', () => { | ||
@@ -104,0 +118,0 @@ const reports = [ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
24900
286
1