MCPcopy
hub / github.com/yjs/yjs / createAttributionFromAttributionItems

Function createAttributionFromAttributionItems

src/utils/AttributionManager.js:59–89  ·  view source on GitHub ↗
(attrs, deleted)

Source from the content-addressed store, hash-verified

57 * @return {Attribution?}
58 */
59export const createAttributionFromAttributionItems = (attrs, deleted) => {
60 if (attrs == null) {
61 return null
62 }
63 /**
64 * @type {Attribution}
65 */
66 const attribution = {}
67 if (deleted) {
68 attribution.delete = []
69 } else {
70 attribution.insert = []
71 }
72 attrs.forEach(attr => {
73 switch (attr.name) {
74 // eslint-disable-next-line no-fallthrough
75 case 'insert':
76 case 'delete': {
77 // needs to be non-ambiguous: don't add existing attr if it doesn't match the actual status
78 attribution[attr.name]?.push(attr.val)
79 break
80 }
81 default: {
82 if (attr.name[0] !== '_') {
83 /** @type {any} */ (attribution)[attr.name] = attr.val
84 }
85 }
86 }
87 })
88 return attribution
89}
90
91/**
92 * @template T

Callers 2

toDeltaMethod · 0.90
renderAttrsFunction · 0.90

Calls 2

pushMethod · 0.80
forEachMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…