← All procedures

quantity.add

This function gives a + b in the unit of a. It is exact for decimal inputs, thus money adds to the cent.

CLI
Package
@procedures/quantity · README
Path
["quantity","add"]
CLI
mark quantity add --a <object> --b <object>
As data
{"$proc":["quantity","add"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/quantity/register"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["quantity","add"], { a: {}, b: {} });
console.log(JSON.stringify(result));

From the command line

$ mark quantity add --a <object> --b <object>

As data, in a program

{ "$proc": ["quantity", "add"], "input": { "a": {}, "b": {} } }

Input

FieldTypeRequiredDefaultDescription
aobjectyes
bobjectyes

Output

FieldTypeRequiredDefaultDescription
valuenumberyes
unitstringyes
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "a": {
        "type": "object",
        "properties": {
          "value": {
            "type": "number"
          },
          "unit": {
            "type": "string"
          }
        },
        "required": [
          "value",
          "unit"
        ],
        "additionalProperties": {}
      },
      "b": {
        "type": "object",
        "properties": {
          "value": {
            "type": "number"
          },
          "unit": {
            "type": "string"
          }
        },
        "required": [
          "value",
          "unit"
        ],
        "additionalProperties": {}
      }
    },
    "required": [
      "a",
      "b"
    ],
    "additionalProperties": false
  },
  "output": {
    "type": "object",
    "properties": {
      "value": {
        "type": "number"
      },
      "unit": {
        "type": "string"
      }
    },
    "required": [
      "value",
      "unit"
    ],
    "additionalProperties": {}
  }
}