UNPKG

md-curcuma

Version:

A Typescript library for transporting and converting markdown and other data.

63 lines (62 loc) 2.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Markdown_IO = exports.IO_Observer_Props = exports.IO_Meta = void 0; const observer_1 = require("../core/observer"); const filesystem_1 = require("../core/filesystem"); class IO_Meta { } exports.IO_Meta = IO_Meta; class IO_Observer_Props { } exports.IO_Observer_Props = IO_Observer_Props; class Markdown_IO { constructor(props) { this.observer_subject = new observer_1.Observer_Subject(); this.props = null; this.props = props; } add_observer(observer, id) { this.observer_subject.add_observer(observer, id); } notify_all(props) { this.observer_subject.notify_all(props); } notify(props) { this.observer_subject.notify(props); } read() { var file_list = []; if (filesystem_1.Filesystem.isFolder(this.props.readPath)) { file_list = filesystem_1.Filesystem.get_files_list(this.props.readPath); } else if (filesystem_1.Filesystem.isFile(this.props.readPath)) { file_list.push(this.props.readPath); } else { console.log(`not supported: '${this.props.readPath}'`); } console.log("Markdown_IO.read: ", file_list); file_list.forEach((file) => { let o_props = new IO_Observer_Props(); o_props.from = "markdown-io"; o_props.to = "runner"; o_props.command = "perform-tasks"; o_props.dao = filesystem_1.Filesystem.read_file_txt(file); let io_meta = new IO_Meta(); io_meta.file_list_reader = file_list; io_meta.file_name_reader = file; io_meta.file_name_writer = this.props.writePath; o_props.io_meta = io_meta; console.log("markdown-io.do_command: perform tasks for", file); this.notify_all(o_props); }); let m_props = new IO_Observer_Props(); m_props.from = "markdown-io"; m_props.to = "runner"; m_props.command = "tasks-finnished"; this.notify_all(m_props); } write(dao) { } } exports.Markdown_IO = Markdown_IO;