struct
import { struct } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/showable.ts";Create a Showable instance for an object type by providing Showable instances for each of its properties. The resulting show function will format the object as a string with property names and their string representations.
@example
import * as S from "./showable.ts";
import * as N from "./number.ts";
import * as Str from "./string.ts";
type Person = {
name: string;
age: number;
};
const ShowablePerson = S.struct<Person>({
name: Str.ShowableString,
age: N.ShowableNumber
});
const person: Person = { name: "Alice", age: 30 };
const result = ShowablePerson.show(person);
// "{ name: Alice, age: 30 }"
const emptyPerson: Person = { name: "", age: 0 };
const emptyResult = ShowablePerson.show(emptyPerson);
// "{ name: , age: 0 }"