2016-07-21 22:16:45 +00:00
|
|
|
"use strict";
|
2016-07-23 02:39:42 +00:00
|
|
|
const plugins = require("./lik.plugins");
|
2016-07-21 22:16:45 +00:00
|
|
|
class Stringmap {
|
|
|
|
constructor() {
|
|
|
|
this._stringArray = [];
|
2016-07-23 02:39:42 +00:00
|
|
|
this._triggerUntilTrueFunctionArray = [];
|
2016-07-21 22:16:45 +00:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* add a string to the Stringmap
|
|
|
|
*/
|
|
|
|
addString(stringArg) {
|
|
|
|
this._stringArray.push(stringArg);
|
2016-07-23 02:39:42 +00:00
|
|
|
this.notifyTrigger();
|
2016-07-21 22:16:45 +00:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* removes a string from Stringmap
|
|
|
|
*/
|
|
|
|
removeString(stringArg) {
|
|
|
|
for (let keyArg in this._stringArray) {
|
2016-07-30 22:54:46 +00:00
|
|
|
if (this._stringArray[keyArg] === stringArg) {
|
2016-07-21 22:16:45 +00:00
|
|
|
this._stringArray.splice(parseInt(keyArg), 1);
|
|
|
|
}
|
|
|
|
}
|
2016-07-23 02:39:42 +00:00
|
|
|
this.notifyTrigger();
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* wipes the Stringmap
|
|
|
|
*/
|
|
|
|
wipe() {
|
|
|
|
this._stringArray = [];
|
|
|
|
this.notifyTrigger();
|
2016-07-21 22:16:45 +00:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* check if string is in Stringmap
|
|
|
|
*/
|
|
|
|
checkString(stringArg) {
|
2016-09-21 11:44:11 +00:00
|
|
|
return this._stringArray.indexOf(stringArg) !== -1;
|
2016-07-21 22:16:45 +00:00
|
|
|
}
|
2016-07-22 12:59:09 +00:00
|
|
|
/**
|
|
|
|
* checks stringPresence with minimatch
|
|
|
|
*/
|
2016-07-23 02:39:42 +00:00
|
|
|
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() {
|
2016-07-30 22:54:46 +00:00
|
|
|
return (this._stringArray.length === 0);
|
2016-07-23 02:39:42 +00:00
|
|
|
}
|
|
|
|
/**
|
2016-09-21 11:44:11 +00:00
|
|
|
* gets a cloned copy of the current string Array
|
2016-07-23 02:39:42 +00:00
|
|
|
*/
|
2016-09-21 11:44:11 +00:00
|
|
|
getStringArray() {
|
|
|
|
return plugins.lodash.cloneDeep(this._stringArray);
|
2016-07-23 02:39:42 +00:00
|
|
|
}
|
2016-09-21 11:44:11 +00:00
|
|
|
// trigger registering
|
2016-07-23 02:39:42 +00:00
|
|
|
/**
|
|
|
|
* register a new trigger
|
|
|
|
*/
|
|
|
|
registerUntilTrue(functionArg, doFunctionArg) {
|
|
|
|
this._triggerUntilTrueFunctionArray.push(() => {
|
|
|
|
let result = functionArg();
|
2016-07-30 22:54:46 +00:00
|
|
|
if (result === true) {
|
2016-07-23 02:39:42 +00:00
|
|
|
doFunctionArg();
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
});
|
|
|
|
this.notifyTrigger();
|
2016-07-22 12:59:09 +00:00
|
|
|
}
|
2016-09-21 11:44:11 +00:00
|
|
|
/**
|
|
|
|
* notifies triggers
|
|
|
|
*/
|
|
|
|
notifyTrigger() {
|
|
|
|
let filteredArray = this._triggerUntilTrueFunctionArray.filter((functionArg) => {
|
|
|
|
return !functionArg();
|
|
|
|
});
|
|
|
|
this._triggerUntilTrueFunctionArray = filteredArray;
|
|
|
|
}
|
2016-07-21 22:16:45 +00:00
|
|
|
}
|
|
|
|
exports.Stringmap = Stringmap;
|
2016-09-21 11:44:11 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uI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