Skip to content

merge

Combines an Array of Objects together and returns a new Object.

Collapses the two objects into one, applying the default aggregations: numeric value fields are summed to 30, the differing id strings collect into an array, and the shared group: "A" collapses to a single value.

import {merge} from "@d3plus/data";

merge([
  {id: "foo", group: "A", value: 10},
  {id: "bar", group: "A", value: 20},
]);

Parameters

import {merge} from "@d3plus/data";
objectsrequiredArray.<DataPoint>

The Array of objects to be merged together.

aggsRecordDefault {}

An object containing specific aggregation methods (functions) for each key type. By default, numbers are summed and strings are returned as an array of unique values.