Comparing version 0.3.0 to 0.4.0
@@ -0,4 +1,7 @@ | ||
import { KVStore } from './store'; | ||
export declare class DocuPorter { | ||
private filePath; | ||
private muted; | ||
values: KVStore; | ||
conditions: KVStore; | ||
constructor(fileName: string); | ||
@@ -12,7 +15,7 @@ reset(): void; | ||
appendJs(js: string, comment?: string): void; | ||
appendTs(ts: any, comment?: string): void; | ||
appendTs(ts: string, comment?: string): void; | ||
text: (...text: string[]) => void; | ||
json: (json: any) => void; | ||
js: (js: string, comment?: string) => void; | ||
ts: (ts: any, comment?: string) => void; | ||
ts: (ts: string, comment?: string) => void; | ||
header: (header: string, order?: 1 | 2 | 3 | 4 | 5) => void; | ||
@@ -24,7 +27,7 @@ h1: (header: string) => void; | ||
h5: (header: string) => void; | ||
mute(value: boolean): void; | ||
match(key: string): boolean; | ||
valuesMatch(): boolean; | ||
log(...args: any[]): void; | ||
get quiet(): boolean; | ||
get loud(): boolean; | ||
stopMute(): void; | ||
mute(): void; | ||
unMute(): void; | ||
} |
@@ -6,5 +6,8 @@ "use strict"; | ||
const fs = require("fs"); | ||
const store_1 = require("./store"); | ||
class DocuPorter { | ||
constructor(fileName) { | ||
this.muted = false; | ||
this.values = new store_1.KVStore(); | ||
this.conditions = new store_1.KVStore(); | ||
this.text = this.appendText; | ||
@@ -27,3 +30,3 @@ this.json = this.appendJson; | ||
append(text) { | ||
if (!this.muted) { | ||
if (this.valuesMatch() && !this.muted) { | ||
fs.appendFileSync(this.filePath, `\n${text}`); | ||
@@ -52,7 +55,12 @@ } | ||
} | ||
mute(value) { | ||
if (this.muted) | ||
return; | ||
this.muted = value; | ||
match(key) { | ||
// if no condition is set, return true | ||
if (!this.conditions.get(key) || !this.values.get(key)) | ||
return true; | ||
return this.conditions.get(key) === this.values.get(key); | ||
} | ||
valuesMatch() { | ||
const currentValues = this.values.getAll(); | ||
return Object.keys(currentValues).every(key => this.match(key)); | ||
} | ||
log(...args) { | ||
@@ -63,9 +71,6 @@ if (!this.muted) { | ||
} | ||
get quiet() { | ||
return this.muted; | ||
mute() { | ||
this.muted = true; | ||
} | ||
get loud() { | ||
return !this.muted; | ||
} | ||
stopMute() { | ||
unMute() { | ||
this.muted = false; | ||
@@ -72,0 +77,0 @@ } |
{ | ||
"name": "docuporter", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Understand a file by documenting it in a markdown file", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
5119
6
143