optional.getOkOr
This function gives the value, or `fallback` for an error.
CLI- Package
- @procedures/optional · README
- Path
["optional","getOkOr"]- CLI
mark optional getOkOr --r <object | object> --fallback <any>- As data
{"$proc":["optional","getOkOr"],"input":{}}
Use it
In TypeScript
import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/optional/register"; // registers its procedures
const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["optional","getOkOr"], { r: "<r>", fallback: "<fallback>" });
console.log(JSON.stringify(result));From the command line
$ mark optional getOkOr --r <object | object> --fallback <any>
As data, in a program
{
"$proc": ["optional", "getOkOr"],
"input": { "r": "<r>", "fallback": "<fallback>" }
}Input
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
r | object | object | yes | ||
fallback | any | yes |
Output
The schema does not list fields (any).
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"r": {
"anyOf": [
{
"type": "object",
"properties": {
"tag": {
"type": "string",
"const": "err"
},
"error": {}
},
"required": [
"tag",
"error"
],
"additionalProperties": {}
},
{
"type": "object",
"properties": {
"tag": {
"type": "string",
"const": "ok"
},
"value": {}
},
"required": [
"tag",
"value"
],
"additionalProperties": {}
}
]
},
"fallback": {}
},
"required": [
"r",
"fallback"
],
"additionalProperties": false
},
"output": {}
}