Skip to content

unctionjs/pluck

Repository files navigation

@unction/pluck

Tests Stability Dependencies

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

Given a keychain and records return the values at the keychain for each record.

pluck(
  ["attributes", "name"]
)(
  [
    {
      id: "1",
      attributes: {
        name: "Kurtis",
        age: 29,
        height: "5'10\"",
      },
    },
    {
      id: "2",
      attributes: {
        name: "Chris",
        age: 29,
        height: "5'8\"",
      },
    },
  ]
)

Which will return:

[
  "Kurtis",
  "Chris"
]