client.reduce
Reduce an array: run fn for each item (acc and item are $refs)
MCPCLIbrowser- Package
- @procedures/client · README
- Path
["client","reduce"]- CLI
mark client reduce- MCP tool
client.reduceon thedev-toolsserver- As data
{"$proc":["client","reduce"],"input":{}}- Tags
- core, collection, runs-refs
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","reduce"], { items: [], initial: "<initial>" });
console.log(JSON.stringify(result));From the command line
$ mark client reduce
As data, in a program
{
"$proc": ["client", "reduce"],
"input": { "items": [], "initial": "<initial>" }
}Input
| Field | Type | Required |
|---|---|---|
items | unknown[] | yes |
initial | unknown | yes |
fn | unknown | no |
accumulated | unknown | no |
Output
The schema does not list fields (any).
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"items": {
"description": "The array, or a call that gives it"
},
"initial": {
"description": "The first accumulator value"
},
"fn": {
"description": "The call to run for each item. It reads { $ref: \"acc\" }, { $ref: \"item\" } and { $ref: \"index\" }; its result is the next accumulator."
},
"accumulated": {
"description": "A result that was computed before (old form)"
}
},
"additionalProperties": {}
},
"output": {
"description": "The last accumulator: its shape depends on the program"
}
}