UNPKG

@magnetarjs/core

Version:
17 lines (16 loc) 587 B
/** * await if there's a WriteLock for the document, and return the latest version of the doc after this */ export function getDocAfterWritelock(params) { const { lastIncomingDocs, docIdentifier } = params; // grab from lastIncoming map const lastIncoming = lastIncomingDocs.get(docIdentifier); if (!lastIncoming) { // do nothing if there is no more last incoming // Sometimes multiple added & modified calls can cause this return; } // delete from lastIncoming map lastIncomingDocs.delete(docIdentifier); return lastIncoming; }