jodit-pro
Version:
PRO Version of Jodit Editor
2 lines (1 loc) • 1.08 kB
JavaScript
var U=Object.defineProperty;var v=(C,e)=>U(C,"name",{value:e,configurable:!0});const u=class u{static reconcile(e,i,d){const{getId:o,isEqual:t=v((n,s)=>o(n)===o(s),"isEqual"),preserveOrder:p=!0}=d,a=new Map,h=new Map;e.forEach((n,s)=>{const c=o(n);a.set(c,n),h.set(c,s)});const r=new Map,O=new Map;i.forEach((n,s)=>{const c=o(n);r.set(c,n),O.set(c,s)});const E=[],l=[],g=[],M=[];return i.forEach((n,s)=>{const c=o(n),f=a.get(c);f?!t(f,n)||p&&h.get(c)!==s?l.push({oldItem:f,newItem:n,index:p?s:h.get(c)}):M.push(f):E.push(n)}),e.forEach(n=>{const s=o(n);r.has(s)||g.push(n)}),{toCreate:E,toUpdate:l,toRemove:g,unchanged:M}}static applyResult(e,i,d={}){i.toRemove.forEach(o=>{var t;const p=e.indexOf(o);p!==-1&&((t=d.onRemove)===null||t===void 0||t.call(d,o,p),e.splice(p,1))}),i.toUpdate.forEach(({oldItem:o,newItem:t,index:p})=>{var a;const h=e.indexOf(o);h!==-1&&((a=d.onUpdate)===null||a===void 0||a.call(d,o,t,p),e[h]=t)}),i.toCreate.forEach(o=>{var t;(t=d.onCreate)===null||t===void 0||t.call(d,o,e.length),e.push(o)})}};v(u,"ListReconciler");let x=u;export{x as ListReconciler};