MCPcopy Index your code
hub / github.com/ether/etherpad / _extendChangesetWithAuthor

Method _extendChangesetWithAuthor

src/node/utils/padDiff.ts:212–238  ·  view source on GitHub ↗
(changeset: any, author: any, apool: any)

Source from the content-addressed store, hash-verified

210 }
211
212 _extendChangesetWithAuthor(changeset: any, author: any, apool: any){
213 // unpack
214 const unpacked = unpack(changeset);
215
216 const assem = new OpAssembler();
217
218 // create deleted attribs
219 const authorAttrib = apool.putAttrib(['author', author || '']);
220 const deletedAttrib = apool.putAttrib(['removed', true]);
221 const attribs = `*${numToString(authorAttrib)}*${numToString(deletedAttrib)}`;
222
223 for (const operator of deserializeOps(unpacked.ops)) {
224 if (operator.opcode === '-') {
225 // this is a delete operator, extend it with the author
226 operator.attribs = attribs;
227 } else if (operator.opcode === '=' && operator.attribs) {
228 // this is operator changes only attributes, let's mark which author did that
229 operator.attribs += `*${numToString(authorAttrib)}`;
230 }
231
232 // append the new operator to our assembler
233 assem.append(operator);
234 }
235
236 // return the modified changeset
237 return pack(unpacked.oldLen, unpacked.newLen, assem.toString(), unpacked.charBank);
238 }
239 _createDeletionChangeset(cs: any, startAText: any, apool: any){
240 const lines = splitTextLines(startAText.text);
241 const alines = splitAttributionLines(startAText.attribs, startAText.text);

Callers 1

_createDiffAtextMethod · 0.95

Calls 6

unpackFunction · 0.90
numToStringFunction · 0.90
packFunction · 0.90
putAttribMethod · 0.80
appendMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected