← All procedures

quantity.convertExact

This function converts a value in one unit, exactly, into another unit.

CLI
Package
@procedures/quantity · README
Path
["quantity","convertExact"]
CLI
mark quantity convertExact --value <object> --from <string> --to <string>
As data
{"$proc":["quantity","convertExact"],"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","convertExact"], { value: {}, from: "<from>", to: "<to>" });
console.log(JSON.stringify(result));

From the command line

$ mark quantity convertExact --value <object> --from <string> --to <string>

As data, in a program

{
  "$proc": ["quantity", "convertExact"],
  "input": { "value": {}, "from": "<from>", "to": "<to>" }
}

Input

FieldTypeRequiredDefaultDescription
valueobjectyes
fromstringyes
tostringyes
onobjectno

Output

FieldTypeRequiredDefaultDescription
nstringyes
dstringyes
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "value": {
        "type": "object",
        "properties": {
          "n": {
            "type": "string",
            "pattern": "^-?(0|[1-9][0-9]*)$",
            "x-procedures-codec": "bigint"
          },
          "d": {
            "type": "string",
            "pattern": "^-?(0|[1-9][0-9]*)$",
            "x-procedures-codec": "bigint"
          }
        },
        "required": [
          "n",
          "d"
        ],
        "additionalProperties": {}
      },
      "from": {
        "type": "string"
      },
      "to": {
        "type": "string"
      },
      "on": {
        "type": "object",
        "properties": {
          "hz": {
            "type": "number",
            "description": "The timer frequency of the kernel converts jiffies: at 250, one jiffy is 4 ms."
          }
        },
        "additionalProperties": {}
      }
    },
    "required": [
      "value",
      "from",
      "to"
    ],
    "additionalProperties": false
  },
  "output": {
    "type": "object",
    "properties": {
      "n": {
        "type": "string",
        "pattern": "^-?(0|[1-9][0-9]*)$",
        "x-procedures-codec": "bigint"
      },
      "d": {
        "type": "string",
        "pattern": "^-?(0|[1-9][0-9]*)$",
        "x-procedures-codec": "bigint"
      }
    },
    "required": [
      "n",
      "d"
    ],
    "additionalProperties": {}
  }
}