utilities.js 631 B

1234567891011121314151617181920212223242526272829
  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. if(idset == null) {
  14. return null;
  15. }
  16. for(var index in idset) {
  17. var objId = idset[index];
  18. if(objId == null) {
  19. continue;
  20. }
  21. var otherItem = objectset[idset[index]];
  22. if(otherItem.keywords.indexOf(key) != -1 && objOffsetCounter-- == 0) {
  23. return otherItem;
  24. }
  25. }
  26. }
  27. }
  28. module.exports = new Utilities();