fix: add optional chaining operator in toHuman (#5825)

* fix: add optional chaining operator in toHuman

* fix typo
This commit is contained in:
Dominique
2024-03-18 12:10:22 -04:00
committed by GitHub
parent 8dbc373ac5
commit 1a0677800e
+2 -2
View File
@@ -88,11 +88,11 @@ export class Json extends Map<string, any> implements Codec {
}
/**
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
* @description Converts the Object to a human-friendly JSON, with additional fields, expansion and formatting of information
*/
public toHuman (): Record<string, AnyJson> {
return [...this.entries()].reduce<Record<string, AnyJson>>((json, [key, value]): Record<string, AnyJson> => {
json[key] = isFunction((value as Codec).toHuman)
json[key] = isFunction((value as Codec)?.toHuman)
? (value as Codec).toHuman()
: value as AnyJson;