lik/dist/lik.objectmap.js

70 lines
2.9 KiB
JavaScript

"use strict";
;
;
/**
* allows keeping track of objects
*/
class Objectmap {
/**
* returns a new instance
*/
constructor() {
this.objectArray = [];
}
;
/**
* add object to Objectmap
*/
add(objectArg) {
this.objectArray.push(objectArg);
}
;
/**
* remove object from Objectmap
*/
remove(objectArg) {
let replacmentArray = [];
for (let item of this.objectArray) {
if (item !== objectArg) {
replacmentArray.push(item);
}
}
;
this.objectArray = replacmentArray;
}
;
/**
* check if object is in Objectmap
*/
checkForObject(objectArg) {
return this.objectArray.indexOf(objectArg !== -1);
}
;
/**
* find object
*/
find(findFunction) {
let resultArray = this.objectArray.filter(findFunction);
if (resultArray.length > 0) {
return resultArray[0];
}
else {
return undefined;
}
;
}
/**
* run function for each item in Objectmap
*/
forEach(functionArg) {
return this.objectArray.forEach(functionArg);
}
/**
* wipe Objectmap
*/
wipe() {
this.objectArray = [];
}
}
exports.Objectmap = Objectmap;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLm9iamVjdG1hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2xpay5vYmplY3RtYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUtDLENBQUM7QUFJRCxDQUFDO0FBR0Y7O0dBRUc7QUFDSDtJQUdJOztPQUVHO0lBQ0g7UUFMUSxnQkFBVyxHQUFHLEVBQUUsQ0FBQztJQU96QixDQUFDOztJQUdEOztPQUVHO0lBQ0gsR0FBRyxDQUFDLFNBQVM7UUFDVCxJQUFJLENBQUMsV0FBVyxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQztJQUNyQyxDQUFDOztJQUVEOztPQUVHO0lBQ0gsTUFBTSxDQUFDLFNBQVM7UUFDWixJQUFJLGVBQWUsR0FBRyxFQUFFLENBQUM7UUFDekIsR0FBRyxDQUFBLENBQUMsSUFBSSxJQUFJLElBQUksSUFBSS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