data-dedupe-array Edge Function — Data
DataRemoves duplicate items from an array using strict equality for primitives, deep equality for objects, or a key field for object arrays.
Edge function data-dedupe-array Removes duplicate items from an array using strict equality for primitives, deep equality for objects, or a key field for object arrays.. 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-dedupe-array 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-dedupe-array",
args: {
"items": null,
"key": "example_key"
}
}) data-dedupe-array — Remove duplicate items from an array
Deduplicates arrays using strict equality for primitives, deep equality for objects, or a key field for efficient object deduplication.
API
POST /api/data-dedupe-array
Request body
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
items |
unknown[] |
✅ | — | Array to deduplicate |
key |
string |
❌ | — | Field name to dedupe objects by (e.g. "id") |
Success response (200)
{
"success": true,
"data": {
"items": [1, 2, 3],
"removedCount": 2
}
}
Error responses
| Code | HTTP | When |
|---|---|---|
INVALID_INPUT |
400 | items is not an array |
INTERNAL_ERROR |
500 | key provided but items contain non-objects |
Usage
cURL
curl -X POST "$FUNCTION_URL" \
-H "Content-Type: application/json" \
-d '{"items": [{"id":1},{"id":2},{"id":1}], "key": "id"}'
TypeScript / JavaScript (HTTP)
const response = await fetch(FUNCTION_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ items: users, key: 'email' }),
});
const { data } = await response.json();
console.log(data.items, `removed: ${data.removedCount}`);
Direct import (Node / Bun / Deno)
import { dedupeArray } from '@aerostack/functions/data-dedupe-array';
const { items, removedCount } = dedupeArray({ items: userList, key: 'userId' });
Use Cases
- Deduplicating user records merged from multiple data sources before database import
- Removing duplicate tag or category values from user-generated content
- Ensuring uniqueness of items in a workflow pipeline before passing to a downstream step
Notes
- First occurrence is always kept; subsequent duplicates are removed
- For objects without
key: usesJSON.stringifydeep equality — key order matters - For primitives: uses strict value equality via
JSON.stringify
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-array-group-by
by @navin
Groups an array of objects into a map keyed by the value of a specified property. Zero dependencies.
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.
Frequently asked questions
What does the data-dedupe-array function do? +
data-dedupe-array 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-dedupe-array function? +
Install the Aerostack CLI and run: ```bash aerostack deploy function @navin/data-dedupe-array ``` It will be live on Cloudflare Workers in seconds.
What runtime does data-dedupe-array use? +
data-dedupe-array runs on aerostack on the Cloudflare Workers edge runtime — zero cold starts, globally distributed.
Can I customise the data-dedupe-array function? +
Yes. Fork the function from your Aerostack dashboard, modify the source, and redeploy. All changes are version-controlled.