UNPKG

on-codemerge

Version:

A WYSIWYG editor for on-codemerge is a user-friendly interface that allows users to edit and view their code in real time, exactly as it will appear in the final product

3 lines (2 loc) 967 B
/*! on-codemerge v1.3.1 @author Pavel Kuzmin @license MIT @homepage https://s00d.github.io/on-codemerge/ @repository git+https://github.com/s00d/on-codemerge.git Copyright (c) 2026 Pavel Kuzmin - Built on 2026-07-02T13:39:17.947Z */ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function f(p,n){const o=[],l=p.split(/(\s+|<[^>]+>)/),u=n.split(/(\s+|<[^>]+>)/);let e=0,t=0;for(;e<l.length||t<u.length;)if(e>=l.length)o.push({type:"add",value:u[t]}),t++;else if(t>=u.length)o.push({type:"remove",value:l[e]}),e++;else if(l[e]===u[t])o.push({type:"equal",value:l[e]}),e++,t++;else{let h=!1,s=1;const i=3;for(;s<=i&&!h;){if(e+s<l.length&&l[e+s]===u[t]){for(let a=0;a<s;a++)o.push({type:"remove",value:l[e+a]});e+=s,h=!0}else if(t+s<u.length&&l[e]===u[t+s]){for(let a=0;a<s;a++)o.push({type:"add",value:u[t+a]});t+=s,h=!0}s++}h||(o.push({type:"remove",value:l[e]}),o.push({type:"add",value:u[t]}),e++,t++)}return o}exports.computeDiff=f;