Skip to content

unctionjs/onlyKeys

Repository files navigation

@unction/onlyKeys

Tests Stability Dependencies

Array | Set => Array | Set | Record<string | number | symbol, B> | Map<B, A> | string => Array | Set | Record<string | number | symbol, B> | Map<B, A> | string

Reduces the keyed enumerable to an object with only the keys provided.

onlyKeys(
  ["alpha", "beta", "delta"]
)(
  {
    feta: "0",
    alpha: "1",
    beta: "2",
    delta: "3",
  }
)

// {
//   alpha: "1",
//   beta: "2",
//   delta: "3",
// }