97 lines
5.1 KiB
JavaScript
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLnN0cmluZ21hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2xpay5zdHJpbmdtYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSx5Q0FBd0M7QUFVeEM7SUFHSTtRQUZRLGlCQUFZLEdBQWEsRUFBRSxDQUFBO1FBQzNCLG1DQUE4QixHQUF1QixFQUFFLENBQUE7SUFDaEQsQ0FBQztJQUNoQjs7T0FFRztJQUNILFNBQVMsQ0FBQyxTQUFpQjtRQUN2QixJQUFJLENBQUMsWUFBWSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQTtRQUNqQyxJQUFJLENBQUMsYUFBYSxFQUFFLENBQUE7SUFDeEIsQ0FBQztJQUVEOztPQUVHO0lBQ0gsY0FBYyxDQUFDLGNBQXdCO1FBQ25DLEdBQUcsQ0FBQyxDQUFDLElBQUksVUFBVSxJQUFJLGNBQWMsQ0FBQyxDQUFBLENBQUM7WUFDbkMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxVQUFVLENBQUMsQ0FBQTtRQUM5QixDQUFDO0lBQ0wsQ0FBQztJQUVEOztPQUVHO0lBQ0gsWUFBWSxDQUFDLFNBQWlCO1FBQzFCLEdBQUcsQ0FBQyxDQUFDLElBQUksTUFBTSxJQUFJLElBQU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