added Objectmap

This commit is contained in:
2016-07-31 00:54:46 +02:00
parent 95fe1f7937
commit e3a811bffd
10 changed files with 138 additions and 10 deletions

View File

@ -2,4 +2,5 @@ import * as plugins from "./lik.plugins";
// import modules
export * from "./lik.stringmap";
export * from "./lik.stringmap";
export * from "./lik.objectmap";

26
ts/lik.objectmap.ts Normal file
View File

@ -0,0 +1,26 @@
import * as plugins from "./lik.plugins";
/**
* allows keeping track of objects
*/
export class Objectmap {
private objectArray = [];
add(objectArg){
this.objectArray.push(objectArg);
};
remove(objectArg){
let replacmentArray = [];
for(let item of this.objectArray){
if(item !== objectArg){
replacmentArray.push(item);
}
};
this.objectArray = replacmentArray;
};
checkForObject(objectArg){
return this.objectArray.indexOf(objectArg !== -1)
};
wipe(){
this.objectArray = [];
}
}

View File

@ -27,7 +27,7 @@ export class Stringmap {
*/
removeString(stringArg:string){
for (let keyArg in this._stringArray){
if(this._stringArray[keyArg] == stringArg){
if(this._stringArray[keyArg] === stringArg){
this._stringArray.splice(parseInt(keyArg),1);
};
};
@ -66,7 +66,7 @@ export class Stringmap {
* checks if the Stringmap is empty
*/
checkIsEmpty(){
return (this._stringArray.length == 0);
return (this._stringArray.length === 0);
}
// trigger registering
@ -88,7 +88,7 @@ export class Stringmap {
this._triggerUntilTrueFunctionArray.push(
() => {
let result = functionArg();
if(result == true){
if(result === true){
doFunctionArg();
}
return result;