Closed ForbesLindesay closed 4 years ago
Added Object.pick
and Object.omit
These mirror the TypeScript types of Pick
and Omit
. Usage:
const CrewMember = Object({
name: String,
rank: Rank,
home: Planet,
});
const PetMember = CrewMember.pick('name', 'home');
Static<typeof PetMember> // { name: string; home: Planet; }
const Background = CrewMember.omit('name');
Static<typeof Background> // { rank: Rank; home: Planet; }
P.S. You can supply any number of property names to pick/omit in a single call.
Thanks to @ivawzh for doing most of the work for this one in https://github.com/pelotom/runtypes/pull/161
[see #13]