IF Commons GitHub

sql/lifecycle/hash

Written to: 2 requirements: 2 proved, 0 partly, 0 failing, 0 with no test recorded. 0011-sql-lifecycle FR-002, 0011-sql-lifecycle FR-010

Hashes (commons data 0011-sql-lifecycle FR-002, FR-010): a plan is a pure function, so the SHA-256 it needs is made here, in plain code, and is the same one the kernel makes (a test says so), and a value is hashed as canonical JSON, with its keys in order, so that the same structure has the same hash wherever it was built.

Source: commons/data/sql/lifecycle/hash.ts

2 of 3 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

canonicalfunctionno test imports it
function canonical(value: unknown): string

A value as canonical JSON: object keys in order, no space, undefined left out.

ParameterWhat it is
valuea JSON value

Returns: its canonical text

hashOfconst
const hashOf: (value: unknown) => string

The hash of a value's canonical JSON.

ParameterWhat it is
valuea JSON value

Returns: 64 hexadecimal digits

Imported by 22 tests of the run (22 passed, 0 failed): the library's results

sha256Hexfunction
function sha256Hex(text: string): string

The SHA-256 of a text, as 64 lower-case hexadecimal digits.

ParameterWhat it is
textthe text, hashed as UTF-8

Returns: the digest

Imported by 44 tests of the run (44 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.