UNPKG

@s-hiroshi/bks

Version:

Cli bookmarks application

29 lines 875 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HistoryWriter = void 0; const fs = require("fs"); const readLinesToArray_1 = require("../service/readLinesToArray"); class HistoryWriter { constructor(filePath) { this.filePath = filePath; } async init() { this.histories = await (0, readLinesToArray_1.readLinesToArray)(this.filePath); } getRows() { return this.histories.length; } write(content) { if (this.getRows() < 10000) { fs.writeFileSync(this.filePath, content + "\n", { flag: "a" }, (err) => { if (err) throw err; }); return; } this.histories.pop(); this.histories.push(content + "\n"); } } exports.HistoryWriter = HistoryWriter; //# sourceMappingURL=HistoryWriter.js.map