← All procedures
client.map
Map over an array: run fn for each item (the item is { $ref: "item" })
MCPCLIbrowser- Package
- @procedures/client · README
- Path
["client","map"]- CLI
mark client map- MCP tool
client.map on the dev-tools server- As data
{"$proc":["client","map"],"input":{}}- Tags
- core, collection, runs-refs
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","map"], { items: [] });
console.log(JSON.stringify(result));From the command line
$ mark client map
As data, in a program
{ "$proc": ["client", "map"], "input": { "items": [] } }Input
| Field | Type | Required |
|---|
items | unknown[] | yes |
fn | unknown | no |
as | string | no |
results | unknown[] | no |
Output
| Field | Type | Required | Default | Description |
|---|
results | any[] | yes | | The result of fn for each item, in order |
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"items": {
"description": "The array, or a call that gives it"
},
"fn": {
"description": "The call to run for each item. It reads the item as { $ref: \"item\" } (or the name in as) and the position as { $ref: \"index\" }."
},
"as": {
"description": "The $ref name of the item in fn (default: item)",
"type": "string"
},
"results": {
"description": "Results that were computed before (old form)"
}
},
"additionalProperties": {}
},
"output": {
"type": "object",
"properties": {
"results": {
"type": "array",
"items": {},
"description": "The result of fn for each item, in order"
}
},
"required": [
"results"
],
"additionalProperties": {}
}
}