← All procedures

rational.cmp

This function is `compare`, with the name that `@mark1russell7/quantity` uses.

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

Use it

In TypeScript

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

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

From the command line

$ mark rational cmp --a <object> --b <object>

As data, in a program

{ "$proc": ["rational", "cmp"], "input": { "a": {}, "b": {} } }

Input

FieldTypeRequiredDefaultDescription
aobjectyes
bobjectyes

Output

The schema does not list fields (number | number | number).

JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "a": {
        "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": {}
      },
      "b": {
        "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": {}
      }
    },
    "required": [
      "a",
      "b"
    ],
    "additionalProperties": false
  },
  "output": {
    "anyOf": [
      {
        "type": "number",
        "const": -1
      },
      {
        "type": "number",
        "const": 0
      },
      {
        "type": "number",
        "const": 1
      }
    ]
  }
}