Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

256 B
Raw Blame
// Extracts a property from each object in an array.
// Example: pluck([{ id: "a" }, { id: "b" }], "id") => ["a", "b"]
export const pluck = <T, K extends keyof T>(
  items: readonly T[],
  key: K,
): T[K][] => {
  return items.map((item) => item[key]);
};