← All procedures

client.count

Count items matching criteria (or total if no criteria)

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

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","count"], { items: [] });
console.log(JSON.stringify(result));

As data, in a program

{ "$proc": ["client", "count"], "input": { "items": [] } }

Input

FieldTypeRequired
itemsunknown[]yes
keystringno
valueunknownno

Output

The schema does not list fields (number).

JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "items": {
        "type": "array",
        "items": {},
        "description": "Array to count"
      },
      "key": {
        "description": "Optional property to check for truthiness",
        "type": "string"
      },
      "value": {
        "description": "Optional value to match"
      }
    },
    "required": [
      "items"
    ]
  },
  "output": {
    "type": "number",
    "description": "The number of matching items"
  }
}