lik/dist/lik.objectmap.js

62 lines
2.8 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLm9iamVjdG1hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2xpay5vYmplY3RtYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQVVBOztHQUVHO0FBQ0g7SUFHSTs7T0FFRztJQUNIO1FBTFEsZ0JBQVcsR0FBUSxFQUFFLENBQUE7SUFPN0IsQ0FBQztJQUVEOztPQUVHO0lBQ0gsR0FBRyxDQUFDLFNBQVk7UUFDWixJQUFJLENBQUMsV0FBVyxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQTtJQUNwQyxDQUFDO0lBRUQ7O09BRUc7SUFDSCxNQUFNLENBQUMsU0FBWTtRQUNmLElBQUksZUFBZSxHQUFHLEVBQUUsQ0FBQTtRQUN4QixHQUFHLENBQUMsQ0FBQyxJQUFJLElBQUksSUFBSSxJQUFJLENBQUMsV0FBVyxDQUFDLENBQUMsQ0FBQztZQUNoQyx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