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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLnN0cmluZ21hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2xpay5zdHJpbmdtYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSx5Q0FBeUM7QUFVekM7SUFHRTtRQUZRLGlCQUFZLEdBQWEsRUFBRSxDQUFDO1FBQzVCLG1DQUE4QixHQUF1QixFQUFFLENBQUM7SUFDakQsQ0FBQztJQUNoQjs7T0FFRztJQUNILFNBQVMsQ0FBQyxTQUFpQjtRQUN6QixJQUFJLENBQUMsWUFBWSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQztRQUNsQyxJQUFJLENBQUMsYUFBYSxFQUFFLENBQUM7SUFDdkIsQ0FBQztJQUVEOztPQUVHO0lBQ0gsY0FBYyxDQUFDLGNBQXdCO1FBQ3JDLEdBQUcsQ0FBQyxDQUFDLElBQUksVUFBVSxJQUFJLGNBQWMsQ0FBQyxDQUFDLENBQUM7WUFDdEMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxVQUFVLENBQUMsQ0FBQztRQUM3QixDQUFDO0lBQ0gsQ0FBQztJQUVEOztPQUVHO0lBQ0gsWUFBWSxDQUFDLFNBQWlCO1FBQzVCLEdBQUcsQ0FBQyxDQUFDLElBQUksTUFBTSxJQUFJLElBQUksQ0F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