Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

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 }"
function struct<A>(shows: [K in keyof A]: Showable<A[K]>): Showable<readonly [K in keyof A]: A[K]>;
§
struct<A>(shows: [K in keyof A]: Showable<A[K]>): Showable<readonly [K in keyof A]: A[K]>
[src]

§Type Parameters

§Parameters

§
shows: [K in keyof A]: Showable<A[K]>
[src]

§Return Type

§
Showable<readonly [K in keyof A]: A[K]>
[src]