getItem()function

getItem(id: I, data: T | Item<I, T>): Item<I, T>
ParamType
idI
The identifier to set on the data. required
dataT
Item<I, T>
The data or item object to attach the identifier to. required
Return
Item<I, T>
An item object with the given id.

Merge an ID into a set of data to make an Item.

  • Returns the data unchanged if it already has the given id.

Examples

getItem("abc", { name: "Dave" }) // { name: "Dave", id: "abc" }