types.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. app.collections.Types = class Types extends app.Collection {
  15. static initClass() {
  16. this.model = "Type";
  17. GUIDES_RGX =
  18. /(^|\()(guides?|tutorials?|reference|book|getting\ started|manual|examples)($|[\):])/i;
  19. APPENDIX_RGX = /appendix/i;
  20. }
  21. groups() {
  22. const result = [];
  23. for (var type of Array.from(this.models)) {
  24. var name;
  25. (result[(name = this._groupFor(type))] || (result[name] = [])).push(
  26. type,
  27. );
  28. }
  29. return result.filter((e) => e.length > 0);
  30. }
  31. _groupFor(type) {
  32. if (GUIDES_RGX.test(type.name)) {
  33. return 0;
  34. } else if (APPENDIX_RGX.test(type.name)) {
  35. return 2;
  36. } else {
  37. return 1;
  38. }
  39. }
  40. };
  41. app.collections.Types.initClass();
  42. return app.collections.Types;
  43. })();