← All procedures
quantity.sum
This function gives the sum in `unit`, or in the unit of the first amount. An empty sum needs `unit`.
CLI- Package
- @procedures/quantity · README
- Path
["quantity","sum"]- CLI
mark quantity sum --amounts <object[]>- As data
{"$proc":["quantity","sum"],"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","sum"], { amounts: [] });
console.log(JSON.stringify(result));From the command line
$ mark quantity sum --amounts <object[]>
As data, in a program
{ "$proc": ["quantity", "sum"], "input": { "amounts": [] } }Input
Output
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"amounts": {
"type": "array",
"items": {
"type": "object",
"properties": {
"value": {
"type": "number"
},
"unit": {
"type": "string"
}
},
"required": [
"value",
"unit"
],
"additionalProperties": {}
}
},
"unit": {
"type": "string"
}
},
"required": [
"amounts"
],
"additionalProperties": false
},
"output": {
"type": "object",
"properties": {
"value": {
"type": "number"
},
"unit": {
"type": "string"
}
},
"required": [
"value",
"unit"
],
"additionalProperties": {}
}
}