Public
Edited
Aug 14, 2023
Fork of Diff tool
Insert cell
Insert cell
Insert cell
diff("rtfm", "rtfpessoa")
Insert cell
diff(
(a, b) => a + b,
(a, b) => a - b
)
Insert cell
diff(
{
min: 0,
max: 10,
toString() {
return `{${this.min},${this.max}}`;
}
},
{
min: 10,
max: 20,
toString() {
return `{${this.min},${this.max}}`;
}
}
)
Insert cell
Insert cell
diff = (left, right, options = {}) => {
const defaults = {
wrapper: html`<div>`,
outputFormat: "side-by-side",
drawFileList: false,
drawFileHeaders: false
};
const { wrapper, drawFileHeaders, ...opts } = { ...defaults, ...options };

const diff = jsdiff.createTwoFilesPatch(
left.name || "left",
right.name || "right",
"" + left,
"" + right,
undefined,
undefined,
{ context: options.context || 2 }
);
const json = diff2html.parse(diff);
wrapper.innerHTML = diff2html.html(json, opts);
if (!drawFileHeaders) {
for (const n of wrapper.querySelectorAll(".d2h-file-header")) n.remove();
}
return wrapper;
}
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more