generators.canonicalHash
This function gives the content hash of a value: `sha256Hex(canonicalJson(value, options))`.
CLI- Package
- @procedures/generators · README
- Path
["generators","canonicalHash"]- CLI
mark generators canonicalHash --value <any>- As data
{"$proc":["generators","canonicalHash"],"input":{}}
Use it
In TypeScript
import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/generators/register"; // registers its procedures
const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["generators","canonicalHash"], { value: "<value>" });
console.log(JSON.stringify(result));From the command line
$ mark generators canonicalHash --value <any>
As data, in a program
{
"$proc": ["generators", "canonicalHash"],
"input": { "value": "<value>" }
}Input
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
value | any | yes | ||
options | object | no |
Output
The schema does not list fields (string).
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"value": {},
"options": {
"type": "object",
"properties": {
"form": {
"type": "string",
"enum": [
"jcs",
"json"
],
"description": "The form of the values that JSON does not have:"
},
"bigint": {
"type": "string",
"enum": [
"error",
"suffix"
],
"description": "The form of a `bigint`. `\"error\"` (the default) causes a `TypeError`, as `JSON.stringify` does. `\"suffix\"` writes the digits and the letter `n`, for example `12n`. This text is not JSON, so use it only for a key."
},
"tags": {
"type": "string",
"enum": [
"none",
"typed"
],
"description": "The form of a `Date`, a `RegExp`, a `Map`, a `Set` and a `bigint`:"
}
},
"additionalProperties": {}
}
},
"required": [
"value"
],
"additionalProperties": false
},
"output": {
"type": "string"
}
}