utilities.js 518 B

12345678910111213141516171819202122
  1. class Utilities {
  2. constructor() {
  3. }
  4. getSpecific(key, idset, objectset) {
  5. var objIndex = 0;
  6. var objOffsetCounter = 0;
  7. if(key.indexOf(".") != -1) {
  8. var counterString = key.split(".");
  9. objIndex = parseInt(counterString[0]) - 1;
  10. key = counterString[1];
  11. }
  12. objOffsetCounter = objIndex;
  13. for(var index in idset) {
  14. var otherItem = objectset[idset[index]];
  15. if(otherItem.keywords.indexOf(key) != -1 && objOffsetCounter-- == 0) {
  16. return otherItem;
  17. }
  18. }
  19. }
  20. }
  21. module.exports = new Utilities();