File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -65,12 +65,21 @@ export function useAsyncDataWrapper<T extends Record<string, any>>(
65
65
obj : T ,
66
66
) : AsyncDataWrapper < T > {
67
67
const composable = { } as AsyncDataWrapper < T > ;
68
- const proto = Object . getPrototypeOf ( obj ) ;
69
68
70
- // Get function names from the object's prototype, excluding the constructor
71
- const functionNames = Object . getOwnPropertyNames ( proto ) . filter (
72
- key => key !== 'constructor' && typeof obj [ key ] === 'function' ,
73
- ) ;
69
+ // Get all function names from the object and its prototypes
70
+ const functionNameSet = new Set < string > ( ) ;
71
+ let currentObj = obj ;
72
+ while ( currentObj && currentObj !== Object . prototype ) {
73
+ const keys = Object . getOwnPropertyNames ( currentObj ) ;
74
+ for ( const key of keys ) {
75
+ // Exclude constructor and non-function properties
76
+ if ( key !== 'constructor' && typeof currentObj [ key ] === 'function' ) {
77
+ functionNameSet . add ( key ) ;
78
+ }
79
+ }
80
+ currentObj = Object . getPrototypeOf ( currentObj ) ;
81
+ }
82
+ const functionNames = Array . from ( functionNameSet ) ;
74
83
75
84
for ( const key of functionNames ) {
76
85
// Bind the function to preserve context
You can’t perform that action at this time.
0 commit comments