Skip to content

Commit

Permalink
oops
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne committed Mar 19, 2024
1 parent cd32587 commit 5dcb7eb
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/platform/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,17 +454,22 @@ export function getCellMetadata(cell: NotebookCell | NotebookCellData): JupyterC
export function sortObjectPropertiesRecursively<T>(obj: T): T {
return doSortObjectPropertiesRecursively(obj) as T;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function doSortObjectPropertiesRecursively(obj: any): any {
if (Array.isArray(obj)) {
return obj.map(sortObjectPropertiesRecursively);
}
if (obj !== undefined && obj !== null && typeof obj === 'object' && Object.keys(obj).length > 0) {
return Object.keys(obj)
.sort()
.reduce<Record<string, any>>((sortedObj, prop) => {
sortedObj[prop] = sortObjectPropertiesRecursively(obj[prop]);
return sortedObj;
}, {}) as any;
return (
Object.keys(obj)
.sort()
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.reduce<Record<string, any>>((sortedObj, prop) => {
sortedObj[prop] = sortObjectPropertiesRecursively(obj[prop]);
return sortedObj;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
}, {}) as any
);
}
return obj;
}

0 comments on commit 5dcb7eb

Please sign in to comment.