lik/dist/lik.objectmap.js

62 lines
2.8 KiB
JavaScript
Raw Normal View History

2016-07-30 22:54:46 +00:00
"use strict";
/**
* allows keeping track of objects
*/
class Objectmap {
2016-08-07 16:08:52 +00:00
/**
* returns a new instance
*/
2016-07-30 22:54:46 +00:00
constructor() {
this.objectArray = [];
}
2016-07-31 12:36:28 +00:00
/**
* add object to Objectmap
*/
2016-07-30 22:54:46 +00:00
add(objectArg) {
this.objectArray.push(objectArg);
}
2016-07-31 12:36:28 +00:00
/**
* remove object from Objectmap
*/
2016-07-30 22:54:46 +00:00
remove(objectArg) {
let replacmentArray = [];
for (let item of this.objectArray) {
if (item !== objectArg) {
replacmentArray.push(item);
}
}
this.objectArray = replacmentArray;
}
2016-07-31 12:36:28 +00:00
/**
* check if object is in Objectmap
*/
2016-07-30 22:54:46 +00:00
checkForObject(objectArg) {
return this.objectArray.indexOf(objectArg) !== -1;
2016-07-30 22:54:46 +00:00
}
/**
* find object
*/
find(findFunction) {
let resultArray = this.objectArray.filter(findFunction);
if (resultArray.length > 0) {
return resultArray[0];
}
else {
return undefined;
}
}
2016-07-31 12:36:28 +00:00
/**
* run function for each item in Objectmap
*/
forEach(functionArg) {
2016-07-31 13:01:24 +00:00
return this.objectArray.forEach(functionArg);
2016-07-31 12:36:28 +00:00
}
/**
* wipe Objectmap
*/
2016-07-30 22:54:46 +00:00
wipe() {
this.objectArray = [];
}
}
exports.Objectmap = Objectmap;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLm9iamVjdG1hcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2xpay5vYmplY3RtYXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQVVBOztHQUVHO0FBQ0g7SUFHSTs7T0FFRztJQUNIO1FBTFEsZ0JBQVcsR0FBUSxFQUFFLENBQUE7SUFPN0IsQ0FBQztJQUVEOztPQUVHO0lBQ0gsR0FBRyxD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