67 lines
2.8 KiB
JavaScript
67 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];
|
|
}
|
|
;
|
|
}
|
|
/**
|
|
* 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLm9iamVjdG1hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2xpay5vYmplY3RtYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUtDLENBQUM7QUFJRCxDQUFDO0FBR0Y7O0dBRUc7QUFDSDtJQUdJOztPQUVHO0lBQ0g7UUFMUSxnQkFBVyxHQUFHLEVBQUUsQ0FBQztJQU96Qix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