optional.map
This function applies `f` to a present value. An absent value stays absent.
CLI- Package
- @procedures/optional · README
- Path
["optional","map"]- CLI
mark optional map --o <object | object> --f <object>- As data
{"$proc":["optional","map"],"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","map"], { o: "<o>", f: {} });
console.log(JSON.stringify(result));From the command line
$ mark optional map --o <object | object> --f <object>
As data, in a program
{ "$proc": ["optional", "map"], "input": { "o": "<o>", "f": {} } }Input
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
o | object | object | yes | ||
f | object | yes | One call of a pure procedure, as data, for the function (v: T) => U. It reads each parameter as {"$ref": "<name>"}: v. |
Output
The schema does not list fields (object | object).
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"o": {
"anyOf": [
{
"type": "object",
"properties": {
"tag": {
"type": "string",
"const": "none"
}
},
"required": [
"tag"
],
"additionalProperties": {}
},
{
"type": "object",
"properties": {
"tag": {
"type": "string",
"const": "some"
},
"value": {}
},
"required": [
"tag",
"value"
],
"additionalProperties": {}
}
]
},
"f": {
"type": "object",
"properties": {
"$proc": {
"minItems": 1,
"type": "array",
"items": {
"type": "string"
}
},
"input": {},
"$when": {
"type": "string",
"const": "$never"
}
},
"required": [
"$proc"
],
"additionalProperties": {},
"x-procedures-program": {
"params": [
"v"
],
"inputs": [
{}
],
"output": {}
},
"description": "One call of a pure procedure, as data, for the function (v: T) => U. It reads each parameter as {\"$ref\": \"<name>\"}: v."
}
},
"required": [
"o",
"f"
],
"additionalProperties": false
},
"output": {
"anyOf": [
{
"type": "object",
"properties": {
"tag": {
"type": "string",
"const": "none"
}
},
"required": [
"tag"
],
"additionalProperties": {}
},
{
"type": "object",
"properties": {
"tag": {
"type": "string",
"const": "some"
},
"value": {}
},
"required": [
"tag",
"value"
],
"additionalProperties": {}
}
]
}
}