data-array-group-by Edge Function — Data
DataGroups an array of objects into a map keyed by the value of a specified property. Zero dependencies.
Edge function data-array-group-by Groups an array of objects into a map keyed by the value of a specified property. Zero dependencies.. Deployed on Cloudflare Workers — zero cold starts, globally distributed. Mount it via your Aerostack workspace to call it from any AI agent.
npx aerostack add navin/data-array-group-by Use with AI Assistants
MCPConnect Claude, Cursor, or any MCP-compatible client — then call this function by slug
① Add MCP Server
Add this once — access all Aerostack functions from your AI tool.
{
"mcpServers": {
"aerostack": {
"url": "https://mcp.aerostack.dev",
"type": "http"
}
}
} ② Call this function
Ask your AI to use the call_function tool with this slug:
call_function({
slug: "data-array-group-by",
args: {
"array": null,
"key": "example_key"
}
}) data-array-group-by
Groups an array of objects into a map keyed by the value of a specified property. Zero external dependencies.
Install
aerostack function add data-array-group-by
Usage
import { groupBy } from './functions/data-array-group-by';
const users = [
{ name: 'Alice', role: 'admin' },
{ name: 'Bob', role: 'user' },
{ name: 'Charlie', role: 'admin' },
];
groupBy(users, 'role');
// {
// groups: {
// admin: [{ name: 'Alice', role: 'admin' }, { name: 'Charlie', role: 'admin' }],
// user: [{ name: 'Bob', role: 'user' }]
// }
// }
API
POST /api/data-array-group-by
{
"array": [
{ "name": "Alice", "role": "admin" },
{ "name": "Bob", "role": "user" },
{ "name": "Charlie", "role": "admin" }
],
"key": "role"
}
{
"success": true,
"data": {
"groups": {
"admin": [
{ "name": "Alice", "role": "admin" },
{ "name": "Charlie", "role": "admin" }
],
"user": [
{ "name": "Bob", "role": "user" }
]
}
}
}
| Field | Type | Required | Description |
|---|---|---|---|
array |
array | Yes | Array of objects to group |
key |
string | Yes | Property name to group by |
Edge Cases
- Missing key in some objects: grouped under
"undefined" nullvalues: grouped under"undefined"- Number/boolean values: converted to string keys (
5becomes"5",truebecomes"true") - Empty array: returns error
EMPTY_ARRAY - Empty key string: returns error
MISSING_KEY
Metadata
Tags
Publisher
@navin verified
Build and publish your own functions
Write a TypeScript function, deploy it to the edge, and share it with thousands of developers — in minutes.
More Data Functions
Browse Data Functions →data-aggregate-stats
by @navin
Computes descriptive statistics (count, sum, min, max, mean, median, stdDev, variance, percentiles) for an array of numbers.
data-csv-parse
by @navin
Parses a CSV string into an array of row objects with headers, handling quoted fields, custom delimiters, and escaped characters.
data-csv-to-json
by @navin
Converts a CSV string to a typed JSON array, automatically inferring numbers, booleans, and null values from string fields.
data-deep-diff
by @navin
Computes a structural deep diff between two JSON-serializable values, classifying each change as added, removed, or modified.
data-sort-objects
by @navin
Sorts an array of objects by one or more fields with configurable direction, null handling, and nested field dot-notation support.
data-dedupe-array
by @navin
Removes duplicate items from an array using strict equality for primitives, deep equality for objects, or a key field for object arrays.
Frequently asked questions
What does the data-array-group-by function do? +
data-array-group-by is a serverless edge function for data automation written in aerostack. Deploy it to Cloudflare Workers via your Aerostack workspace.
How do I deploy the data-array-group-by function? +
Install the Aerostack CLI and run: ```bash aerostack deploy function @navin/data-array-group-by ``` It will be live on Cloudflare Workers in seconds.
What runtime does data-array-group-by use? +
data-array-group-by runs on aerostack on the Cloudflare Workers edge runtime — zero cold starts, globally distributed.
Can I customise the data-array-group-by function? +
Yes. Fork the function from your Aerostack dashboard, modify the source, and redeploy. All changes are version-controlled.