import { assertEquals } from "jsr:@std/assert"
const now_i_know_my = { a: 1, b: 2, c: 3, s: "nein" }
const now_i_know_my_greek = recordMap({
a: (v) => `${v}-alpha`,
b: (v) => `${v}-beta`,
c: (v) => `${v}-theta`,
s: (v) => 9,
}, now_i_know_my)
now_i_know_my_greek satisfies ({ a: string, b: string, c: string, s: number })
assertEquals(now_i_know_my_greek, { a: "1-alpha", b: "2-beta", c: "3-theta", s: 9 })
applies the function
mapping_funcs[K]
to inputinput_data[K]
, for every keyK in mapping_funcs
.see RecordMapper to get an understanding of what
mapping_funcs
is supposed to look like, and how to type it. moreover, the 3 generic parameters (R
,U
,D
) used here are the same as the ones at RecordMapper, so check it out.