29 lines
631 B
JavaScript
29 lines
631 B
JavaScript
import { parseLine as r, createLineData as u } from "./parser.js";
|
|
function h(s, f = " ") {
|
|
const e = u("", f);
|
|
let n = !1;
|
|
async function c(t = -1) {
|
|
if (n)
|
|
n = !1;
|
|
else {
|
|
const i = await s();
|
|
if (i == null)
|
|
return !1;
|
|
e.line = i, r(e);
|
|
}
|
|
return l() <= t ? (n = !0, !1) : !0;
|
|
}
|
|
const l = () => e.level, o = (t = e.offsetHead) => e.line.slice(t), a = () => e.line.slice(e.offsetHead, e.offsetTail);
|
|
return {
|
|
next: c,
|
|
level: l,
|
|
line: o,
|
|
head: a,
|
|
tail: () => e.line.slice(e.offsetTail),
|
|
match: (t) => t === a()
|
|
};
|
|
}
|
|
export {
|
|
h as useDocument
|
|
};
|