@magnetarjs/core
Advanced tools
Comparing version 0.11.0 to 0.11.2
@@ -163,9 +163,13 @@ "use strict"; | ||
// src/helpers/executeOnFns.ts | ||
function executeOnFns(fns, payload, otherArgs) { | ||
for (const fn of fns) { | ||
if (!payload) | ||
return; | ||
payload = fn(payload, ...otherArgs); | ||
function executeOnFns(params) { | ||
const { modifyReadResultFns, localStoreFns, payload, docMetaData } = params; | ||
let newPayload = payload; | ||
for (const fn of modifyReadResultFns) { | ||
if (newPayload) | ||
newPayload = fn(newPayload, docMetaData); | ||
} | ||
return payload; | ||
for (const fn of localStoreFns) { | ||
newPayload = fn(newPayload, docMetaData); | ||
} | ||
return newPayload; | ||
} | ||
@@ -446,7 +450,8 @@ | ||
for (const docMetaData of docs) { | ||
const docResult = executeOnFns( | ||
[...doOnAddedFns, ...doOnFetchFns], | ||
docMetaData.data, | ||
[docMetaData] | ||
); | ||
const docResult = executeOnFns({ | ||
modifyReadResultFns: doOnAddedFns, | ||
localStoreFns: doOnFetchFns, | ||
payload: docMetaData.data, | ||
docMetaData | ||
}); | ||
if (docResult) | ||
@@ -593,3 +598,3 @@ collectionFetchResult.set(docMetaData.id, docResult); | ||
const streamInfoPerStore = {}; | ||
const doOnStreamFns = { | ||
const modifyReadResponseFns = { | ||
added: modifyReadResponseMap.added, | ||
@@ -599,2 +604,7 @@ modified: modifyReadResponseMap.modified, | ||
}; | ||
const doOnStreamFns = { | ||
added: [], | ||
modified: [], | ||
removed: [] | ||
}; | ||
const lastIncomingDocs = /* @__PURE__ */ new Map(); | ||
@@ -613,3 +623,8 @@ const mustExecuteOnRead = { | ||
return; | ||
return executeOnFns(doOnStreamFns.added, result.payload, [result.meta]); | ||
return executeOnFns({ | ||
modifyReadResultFns: modifyReadResponseFns.added, | ||
localStoreFns: doOnStreamFns.added, | ||
payload: result.payload, | ||
docMetaData: result.meta | ||
}); | ||
}, | ||
@@ -627,3 +642,8 @@ modified: async (_payload, _meta) => { | ||
return; | ||
return executeOnFns(doOnStreamFns.added, result.payload, [result.meta]); | ||
return executeOnFns({ | ||
modifyReadResultFns: modifyReadResponseFns.added, | ||
localStoreFns: doOnStreamFns.added, | ||
payload: result.payload, | ||
docMetaData: result.meta | ||
}); | ||
}, | ||
@@ -634,3 +654,8 @@ removed: async (_payload, _meta) => { | ||
await writeLockPromise(writeLockMap, docIdentifier); | ||
return executeOnFns(doOnStreamFns.removed, _payload, [_meta]); | ||
return executeOnFns({ | ||
modifyReadResultFns: modifyReadResponseFns.removed, | ||
localStoreFns: doOnStreamFns.removed, | ||
payload: _payload, | ||
docMetaData: _meta | ||
}); | ||
} | ||
@@ -637,0 +662,0 @@ }; |
{ | ||
"name": "@magnetarjs/core", | ||
"version": "0.11.0", | ||
"version": "0.11.2", | ||
"sideEffects": false, | ||
@@ -23,4 +23,4 @@ "description": "Magnetar core library.", | ||
"dependencies": { | ||
"@magnetarjs/types": "0.11.0", | ||
"@magnetarjs/utils": "0.11.0", | ||
"@magnetarjs/types": "0.11.2", | ||
"@magnetarjs/utils": "0.11.2", | ||
"getorset-anything": "^0.0.3", | ||
@@ -31,3 +31,3 @@ "is-what": "^4.1.7", | ||
"devDependencies": { | ||
"@magnetarjs/test-utils": "0.11.0" | ||
"@magnetarjs/test-utils": "0.11.2" | ||
}, | ||
@@ -34,0 +34,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73122
1840
+ Added@magnetarjs/types@0.11.2(transitive)
+ Added@magnetarjs/utils@0.11.2(transitive)
- Removed@magnetarjs/types@0.11.0(transitive)
- Removed@magnetarjs/utils@0.11.0(transitive)
Updated@magnetarjs/types@0.11.2
Updated@magnetarjs/utils@0.11.2