Skip to content

Commit 65ce8d9

Browse files
author
Niels V
committed
code cleanup
- fixed typo - removed duplication function declaration
1 parent 9a39a38 commit 65ce8d9

2 files changed

Lines changed: 3 additions & 30 deletions

File tree

app.js

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { foldChangeSets } from './folding';
77
import { sendRequest } from './send-request';
88
import { sendBundledRequest } from './bundle-requests';
99
import {
10-
filterChangesestOnPattern,
10+
filterChangesetsOnPattern,
1111
tripleMatchesSpec,
1212
filterMatchesForOrigin,
1313
hostnameForEntry
@@ -60,33 +60,6 @@ app.post( '/', bodyParser.json({limit: '500mb'}), function( req, res ) {
6060
res.status(204).send();
6161
} );
6262

63-
64-
/**
65-
* Filters the change sets based on a specified pattern.
66-
*
67-
* @param {Array<Object>} changeSets - An array of change set objects,
68-
* each containing `insert` and `delete` properties.
69-
* @param {Object} entry - An object containing the matching criteria.
70-
* @param {Array} entry.match - The pattern used to filter the triples
71-
* in the `insert` and `delete` arrays.
72-
* @returns {Array<Object>} A new array of change set objects with
73-
* filtered `insert` and `delete` properties.
74-
*/
75-
function filterChangesestOnPattern(changeSets, entry) {
76-
const filteredChangesets = [];
77-
for (const changeSet of changeSets) {
78-
const { insert, delete: deleteSet } = changeSet;
79-
const clonedChangeSet = {
80-
...changeSet,
81-
insert: insert.filter((triple) => tripleMatchesSpec(triple, entry.match)),
82-
delete: deleteSet.filter((triple) => tripleMatchesSpec(triple, entry.match))
83-
};
84-
filteredChangesets.push(clonedChangeSet);
85-
};
86-
return filteredChangesets;
87-
}
88-
89-
9063
async function informWatchers( changeSets, res, muCallIdTrail, muSessionId ){
9164
// Iterate over each unique match pattern
9265
for (const matchKey in groupedServices) {
@@ -95,7 +68,7 @@ async function informWatchers( changeSets, res, muCallIdTrail, muSessionId ){
9568
const sendMatchesOnly = firstEntry.options.sendMatchesOnly;
9669
let maybePatternFilteredChangesets = changeSets;
9770
if (sendMatchesOnly) {
98-
maybePatternFilteredChangesets = filterChangesestOnPattern(changeSets, firstEntry);
71+
maybePatternFilteredChangesets = filterChangesetsOnPattern(changeSets, firstEntry);
9972
}
10073

10174
let allInserts = [];

matching.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* @returns {Array<Object>} A new array of change set objects with
1111
* filtered `insert` and `delete` properties.
1212
*/
13-
export function filterChangesestOnPattern(changeSets, entry) {
13+
export function filterChangesetsOnPattern(changeSets, entry) {
1414
const filteredChangesets = [];
1515
for (const changeSet of changeSets) {
1616
const { insert, delete: deleteSet } = changeSet;

0 commit comments

Comments
 (0)