deno.land / x / pothos@release-1713397530 / packages / core / utils / sort-classes.ts

sort-classes.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// @ts-nocheckexport function classDepth(obj: {}): number { const proto = Object.getPrototypeOf(obj) as {} | null; if (!proto) { return 0; } return 1 + classDepth(proto);}export function sortClasses<T extends new (...args: any[]) => unknown>(classes: T[]) { return [...classes].sort((a, b) => { const depthA = classDepth(a); const depthB = classDepth(b); if (depthA > depthB) { return -1; } if (depthB > depthA) { return 1; } return 0; });}
pothos

Version Info

Tagged at
a year ago