client.indexOf
Find index of value in array (-1 if not found)
browsernot registered- Package
- @procedures/client · README
- Path
["client","indexOf"]- CLI
- Not a
markcommand: it is not in the default registry. - As data
{"$proc":["client","indexOf"],"input":{}}- Tags
- core, array
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","indexOf"], { items: [] });
console.log(JSON.stringify(result));As data, in a program
{ "$proc": ["client", "indexOf"], "input": { "items": [] } }Input
| Field | Type | Required |
|---|---|---|
items | unknown[] | yes |
value | unknown | no |
fromIndex | number | no |
Output
The schema does not list fields (number).
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {},
"description": "The array"
},
"value": {
"description": "The value"
},
"fromIndex": {
"description": "The position to start the search from",
"type": "number"
}
},
"required": [
"items"
]
},
"output": {
"type": "number",
"description": "The index of the item, or -1"
}
}