← All procedures
client.partition
Split array into two arrays based on predicate
browsernot registered- Package
- @procedures/client · README
- Path
["client","partition"]- CLI
- Not a
mark command: it is not in the default registry. - As data
{"$proc":["client","partition"],"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","partition"], { items: [], key: "<key>" });
console.log(JSON.stringify(result));As data, in a program
{
"$proc": ["client", "partition"],
"input": { "items": [], "key": "<key>" }
}Input
| Field | Type | Required |
|---|
items | unknown[] | yes |
key | string | yes |
value | unknown | no |
Output
| Field | Type | Required | Default | Description |
|---|
truthy | any[] | yes | | The items that pass the condition |
falsy | any[] | yes | | The items that do not pass the condition |
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {},
"description": "Array to partition"
},
"key": {
"type": "string",
"description": "Property to check for truthiness"
},
"value": {
"description": "Value to match for truthy partition"
}
},
"required": [
"items",
"key"
]
},
"output": {
"type": "object",
"properties": {
"truthy": {
"type": "array",
"items": {},
"description": "The items that pass the condition"
},
"falsy": {
"type": "array",
"items": {},
"description": "The items that do not pass the condition"
}
},
"required": [
"truthy",
"falsy"
],
"additionalProperties": {}
}
}