generators.stablePick
One item of a list, chosen by highest random weight: each key has a weight from `seed`, and the largest weight wins.
CLI- Package
- @procedures/generators · README
- Path
["generators","stablePick"]- CLI
mark generators stablePick --seed <number> --items <any[]>- As data
{"$proc":["generators","stablePick"],"input":{}}
Use it
In TypeScript
import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/generators/register"; // registers its procedures
const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["generators","stablePick"], { seed: 1, items: [] });
console.log(JSON.stringify(result));From the command line
$ mark generators stablePick --seed <number> --items <any[]>
As data, in a program
{
"$proc": ["generators", "stablePick"],
"input": { "seed": 1, "items": [] }
}Input
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
seed | number | yes | ||
items | any[] | yes | ||
keyOf | object | no | One call of a pure procedure, as data, for the function (item: T) => string. It reads each parameter as {"$ref": "<name>"}: item. |
Output
The schema does not list fields (any).
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"seed": {
"type": "number"
},
"items": {
"type": "array",
"items": {}
},
"keyOf": {
"type": "object",
"properties": {
"$proc": {
"minItems": 1,
"type": "array",
"items": {
"type": "string"
}
},
"input": {},
"$when": {
"type": "string",
"const": "$never"
}
},
"required": [
"$proc"
],
"additionalProperties": {},
"x-procedures-program": {
"params": [
"item"
],
"inputs": [
{}
],
"output": {
"type": "string"
}
},
"description": "One call of a pure procedure, as data, for the function (item: T) => string. It reads each parameter as {\"$ref\": \"<name>\"}: item."
}
},
"required": [
"seed",
"items"
],
"additionalProperties": false
},
"output": {}
}