lik/dist/lik.stringmap.js

90 lines
4.6 KiB
JavaScript

"use strict";
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();
}
;
/**
* 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);
}
// trigger registering
/**
* notifies triggers
*/
notifyTrigger() {
let filteredArray = this._triggerUntilTrueFunctionArray.filter((functionArg) => {
return !functionArg();
});
this._triggerUntilTrueFunctionArray = filteredArray;
}
;
/**
* register a new trigger
*/
registerUntilTrue(functionArg, doFunctionArg) {
this._triggerUntilTrueFunctionArray.push(() => {
let result = functionArg();
if (result == true) {
doFunctionArg();
}
return result;
});
this.notifyTrigger();
}
}
exports.Stringmap = Stringmap;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLnN0cmluZ21hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2xpay5zdHJpbmdtYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLGVBQWUsQ0FBQyxDQUFBO0FBVXpDO0lBR0k7UUFGUSxpQkF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