I found below line from somewhere. How does it work?
!g.handledFrom && g.from < c.index + e.length && g.from >= c.index && (a.push({ type: "start", offset: g.from - c.index, marker: g }), g.handledFrom = !0);
complete method
function(a, b, c, d, e) { a = []; if (b) { d = 0; for (var f = b.length; d < f; d++) { var g = b[d]; !g.handledFrom && g.from < c.index + e.length && g.from >= c.index && (a.push({ type: "start", offset: g.from - c.index, marker: g }), g.handledFrom = !0); !g.handledTo && [g.to](g.to) <= c.index + e.length && [g.to](http://g.to/) >= c.index && (g.handledFrom || (a.push({ type: "start", offset: g.from - c.index, marker: g }), g.handledFrom = !0), a.push({ type: "end", offset: [g.to](g.to) - c.index, marker: g }), g.handledTo = !0) } } return a }
Please format properly.
! g.handledFrom && g.from < c.index + e.length && g.from >= c.index && (a.push({
type: "start",
offset: g.from - c.index,
marker: g
}), g.handledFrom = ! 0);
Besides that it looks rather poor the code, so it's hard to explain. Especially the naming e, g, c is horrible.
it's a condensed version of this code:
if (
!g.handledFrom &&
g.from < c.index + e.length &&
g.from >= c.index
) {
a.push({ type: "start", offset: g.from - c.index, marker: g });
g.handledFrom = true;
}
Peter Scheler
JS enthusiast
Only call
a.push(...)ifg.handledFromis falsy andg.fromis smaller thenc.index + e.lengthandg.fromis greater then or equalc.index.Very bad style.