types.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // TODO: This file was created by bulk-decaffeinate.
  2. // Sanity-check the conversion and remove this comment.
  3. /*
  4. * decaffeinate suggestions:
  5. * DS101: Remove unnecessary use of Array.from
  6. * DS102: Remove unnecessary code created because of implicit returns
  7. * DS104: Avoid inline assignments
  8. * DS206: Consider reworking classes to avoid initClass
  9. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
  10. */
  11. (function() {
  12. let GUIDES_RGX = undefined;
  13. let APPENDIX_RGX = undefined;
  14. const Cls = (app.collections.Types = class Types extends app.Collection {
  15. static initClass() {
  16. this.model = 'Type';
  17. GUIDES_RGX = /(^|\()(guides?|tutorials?|reference|book|getting\ started|manual|examples)($|[\):])/i;
  18. APPENDIX_RGX = /appendix/i;
  19. }
  20. groups() {
  21. const result = [];
  22. for (var type of Array.from(this.models)) {
  23. var name;
  24. (result[name = this._groupFor(type)] || (result[name] = [])).push(type);
  25. }
  26. return result.filter(e => e.length > 0);
  27. }
  28. _groupFor(type) {
  29. if (GUIDES_RGX.test(type.name)) {
  30. return 0;
  31. } else if (APPENDIX_RGX.test(type.name)) {
  32. return 2;
  33. } else {
  34. return 1;
  35. }
  36. }
  37. });
  38. Cls.initClass();
  39. return Cls;
  40. })();