2016-07-21 22:16:45 +00:00
|
|
|
"use strict";
|
2017-04-09 14:29:14 +00:00
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
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
|
|
|
}
|
2016-09-21 13:57:57 +00:00
|
|
|
/**
|
|
|
|
* like addString, but accepts an array of strings
|
|
|
|
*/
|
|
|
|
addStringArray(stringArrayArg) {
|
|
|
|
for (let stringItem of stringArrayArg) {
|
|
|
|
this.addString(stringItem);
|
|
|
|
}
|
|
|
|
}
|
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() {
|
2018-01-27 17:11:11 +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() {
|
2018-01-27 17:11:11 +00:00
|
|
|
let filteredArray = this._triggerUntilTrueFunctionArray.filter(functionArg => {
|
2016-09-21 11:44:11 +00:00
|
|
|
return !functionArg();
|
|
|
|
});
|
|
|
|
this._triggerUntilTrueFunctionArray = filteredArray;
|
|
|
|
}
|
2016-07-21 22:16:45 +00:00
|
|
|
}
|
|
|
|
exports.Stringmap = Stringmap;
|
2018-01-27 17:11:11 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLnN0cmluZ21hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2xpay5zdHJpbmdtYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSx5Q0FBeUM7QUFVekM7SUFHRTtRQUZRLGlCQUFZLEdBQWEsRUFBRSxDQUFDO1FBQzVCLG1DQUE4QixHQUF1QixFQUFFLENBQUM7SUFDakQsQ0FBQztJQUNoQjs7T0FFRztJQUNILFNBQVMsQ0FBQyxTQUFpQjtRQUN6QixJQUFJLENBQUMsWUFBWSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQztRQUNsQyxJQUFJLENBQUMsYUFBYSxFQUFFLENBQUM7SUFDdkIsQ0FBQztJQUVEOztPQUVHO0lBQ0gsY0FBYyxDQUFDLGNBQXdCO1FBQ3JDLEdBQUcsQ0FBQyxDQUFDLElBQUksVUFBVSxJQUFJLGNBQWMsQ0FBQyxDQUFDLENBQUM7WUFDdEMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxVQUFVLENBQUMsQ0FBQztRQUM3QixDQUFDO0lBQ0gsQ0FBQztJQUVEOztPQUVHO0lBQ0gsWUFBWSxDQUFDLFNBQWlCO1FBQzVCLEdBQUcsQ0FBQyxDQUFDLElBQUksTUFBTSxJQUFJLElBQUksQ0FBQyxZQUFZLENBQUMsQ0FBQyxDQUFDO1lBQ3JDLEVBQUUsQ0FBQyxDQUFDL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