UNPKG

@2toad/profanity

Version:

A JavaScript profanity filter

28 lines 794 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.List = void 0; const fs_1 = require("fs"); class List { constructor(onListChanged) { this.onListChanged = onListChanged; this.words = []; } get empty() { return !this.words.length; } loadFile(filename) { const file = fs_1.readFileSync(filename, 'utf8'); this.words = file.split('\n').filter(x => x); this.onListChanged(); } removeWords(words) { this.words = this.words.filter(x => !words.includes(x)); this.onListChanged(); } addWords(words) { this.words = this.words.concat(words); this.onListChanged(); } } exports.List = List; //# sourceMappingURL=list.js.map