fold
Given a JSON object where the data values and headers have been split into separate key lookups, this function will combine the data values with the headers and returns one large array of objects.
Basic example
Section titled “Basic example”Zips the flat headers array against each row of data, emitting one object per row keyed by header — the first row becomes {year: 2020, apples: 5, bananas: 8}.
import {fold} from "@d3plus/data";
fold({
headers: ["year", "apples", "bananas"],
data: [
[2020, 5, 8],
[2021, 7, 6],
],
});
Parameters
import {fold} from "@d3plus/data";