lik/dist/lik.stringmap.js

97 lines
5.1 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./lik.plugins");
class Stringmap {
constructor() {
this._stringArray = [];
this._triggerUntilTrueFunctionArray = [];
}
/**
* add a string to the Stringmap
*/
addString(stringArg) {
this._stringArray.push(stringArg);
this.notifyTrigger();
}
/**
* like addString, but accepts an array of strings
*/
addStringArray(stringArrayArg) {
for (let stringItem of stringArrayArg) {
this.addString(stringItem);
}
}
/**
* removes a string from Stringmap
*/
removeString(stringArg) {
for (let keyArg in this._stringArray) {
if (this._stringArray[keyArg] === stringArg) {
this._stringArray.splice(parseInt(keyArg), 1);
}
}
this.notifyTrigger();
}
/**
* wipes the Stringmap
*/
wipe() {
this._stringArray = [];
this.notifyTrigger();
}
/**
* check if string is in Stringmap
*/
checkString(stringArg) {
return this._stringArray.indexOf(stringArg) !== -1;
}
/**
* checks stringPresence with minimatch
*/
checkMinimatch(miniMatchStringArg) {
let foundMatch = false;
for (let stringItem of this._stringArray) {
if (plugins.minimatch(stringItem, miniMatchStringArg)) {
foundMatch = true;
}
}
return foundMatch;
}
/**
* checks if the Stringmap is empty
*/
checkIsEmpty() {
return (this._stringArray.length === 0);
}
/**
* gets a cloned copy of the current string Array
*/
getStringArray() {
return plugins.lodash.cloneDeep(this._stringArray);
}
// trigger registering
/**
* register a new trigger
*/
registerUntilTrue(functionArg, doFunctionArg) {
this._triggerUntilTrueFunctionArray.push(() => {
let result = functionArg();
if (result === true) {
doFunctionArg();
}
return result;
});
this.notifyTrigger();
}
/**
* notifies triggers
*/
notifyTrigger() {
let filteredArray = this._triggerUntilTrueFunctionArray.filter((functionArg) => {
return !functionArg();
});
this._triggerUntilTrueFunctionArray = filteredArray;
}
}
exports.Stringmap = Stringmap;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLnN0cmluZ21hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpb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