← All procedures

client.groupBy

Group array items by key value

browsernot registered
Package
@procedures/client · README
Path
["client","groupBy"]
CLI
Not a mark command: it is not in the default registry.
As data
{"$proc":["client","groupBy"],"input":{}}
Tags
core, array

Try it in the Composer →

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY, allCoreProcedures } from "@procedures/client";

for (const procedure of allCoreProcedures) {
  if (!PROCEDURE_REGISTRY.has(procedure.path)) PROCEDURE_REGISTRY.register(procedure);
}

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["client","groupBy"], { items: [], key: "<key>" });
console.log(JSON.stringify(result));

As data, in a program

{
  "$proc": ["client", "groupBy"],
  "input": { "items": [], "key": "<key>" }
}

Input

FieldTypeRequired
itemsunknown[]yes
keystringyes

Output

The schema does not list fields (object).

JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "items": {
        "type": "array",
        "items": {},
        "description": "The array"
      },
      "key": {
        "type": "string",
        "description": "The key (a field name of the items)"
      }
    },
    "required": [
      "items",
      "key"
    ]
  },
  "output": {
    "type": "object",
    "propertyNames": {
      "type": "string"
    },
    "additionalProperties": {
      "type": "array",
      "items": {}
    },
    "description": "The items, grouped by the value of the key"
  }
}