optional.fromNullable
This function wraps a value, and gives `none` for `null` and `undefined`.
CLI- Package
- @procedures/optional · README
- Path
["optional","fromNullable"]- CLI
mark optional fromNullable --value <any>- As data
{"$proc":["optional","fromNullable"],"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","fromNullable"], { value: "<value>" });
console.log(JSON.stringify(result));From the command line
$ mark optional fromNullable --value <any>
As data, in a program
{
"$proc": ["optional", "fromNullable"],
"input": { "value": "<value>" }
}Input
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
value | any | yes |
Output
The schema does not list fields (object | object).
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"value": {}
},
"required": [
"value"
],
"additionalProperties": false
},
"output": {
"anyOf": [
{
"type": "object",
"properties": {
"tag": {
"type": "string",
"const": "none"
}
},
"required": [
"tag"
],
"additionalProperties": {}
},
{
"type": "object",
"properties": {
"tag": {
"type": "string",
"const": "some"
},
"value": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "number"
},
{
"type": "string"
},
{
"type": "array",
"items": {}
},
{
"type": "object",
"properties": {},
"additionalProperties": {}
}
]
}
},
"required": [
"tag",
"value"
],
"additionalProperties": {}
}
]
}
}