Skip to content

Latest commit

 

History

History
52 lines (45 loc) · 1.03 KB

README.md

File metadata and controls

52 lines (45 loc) · 1.03 KB

@unction/plucks

Tests Stability Dependencies

Array<KeyChainType> => KeyedEnumerabletype<B, A> => Array

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

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

Which will return:

[
  ["Kurtis", 29, null, "1"],
  ["Chris", 29, null, "2"]
]