types.js 925 B

1234567891011121314151617181920212223242526272829303132
  1. // TODO: This file was created by bulk-decaffeinate.
  2. // Sanity-check the conversion and remove this comment.
  3. /*
  4. * decaffeinate suggestions:
  5. * DS104: Avoid inline assignments
  6. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
  7. */
  8. app.collections.Types = class Types extends app.Collection {
  9. static model = "Type";
  10. static GUIDES_RGX =
  11. /(^|\()(guides?|tutorials?|reference|book|getting\ started|manual|examples)($|[\):])/i;
  12. static APPENDIX_RGX = /appendix/i;
  13. groups() {
  14. const result = [];
  15. for (var type of this.models) {
  16. var name;
  17. (result[(name = this._groupFor(type))] || (result[name] = [])).push(type);
  18. }
  19. return result.filter((e) => e.length > 0);
  20. }
  21. _groupFor(type) {
  22. if (Types.GUIDES_RGX.test(type.name)) {
  23. return 0;
  24. } else if (Types.APPENDIX_RGX.test(type.name)) {
  25. return 2;
  26. } else {
  27. return 1;
  28. }
  29. }
  30. };