UNPKG

@loom-io/front-matter-converter

Version:

Convert front matter yaml and json into json from loom-io files

52 lines (51 loc) 1.11 kB
export class LineResultMock { lines; index; constructor(lines = []) { this.lines = lines; this.index = 0; } async next() { this.index++; } async hasNext() { return this.index < this.lines.length; } // eslint-disable-next-line @typescript-eslint/no-unused-vars async read(...params) { return this.lines[this.index]; } } export class EditorMock { lines; constructor(lines) { this.lines = lines; } async firstLine() { if (this.lines.length === 0) { return undefined; } return new LineResultMock(this.lines); } close() { return Promise.resolve(); } } export class FileMock { lines; extension; constructor(lines = [''], extension = 'md') { this.lines = lines; this.extension = extension; } get name() { return 'file.' + this.extension; } reader() { return new EditorMock(this.lines); } write(content) { this.lines = content.split('\n'); return Promise.resolve(); } }