Skip to main content

Crate edtf_wasm

Crate edtf_wasm 

Source
Expand description

WebAssembly bindings for edtf_core — the same validator the database runs, compiled for JavaScript. The app imports this in place of edtf.js.

Exported API (JS names):

  • isValid(input)boolean
  • level(input)0 | 1 | 2 | -1 (-1 = invalid)
  • canonical(input)string | undefined (spec-preferred form)
  • parse(input) → JSON string of a Summary or undefined
  • relation(a, b) → JSON string of a RelationSummary or undefined
  • normalize(input, options?) → JSON string of a NormalizeSummary (always returns; {"kind":"noMatch"} when the prose is outside the grammar). options is a JSON string: {"language": "en"|"ru", "numericOrder": "dayFirst"|"monthFirst", "defaultCentury": 1900} — all fields optional.

Structs§

InterpretationJson
One reading of an ambiguous input.
NoteJson
One note: the governing N-decision (or null) and a human-readable message.
RelationSummary
The JSON shape relation returns.
Summary
The JSON shape parse returns; one object per valid expression.

Enums§

NormalizeSummary
The JSON shape normalize returns, discriminated by kind: "normalized" | "ambiguous" | "noMatch". Semantics and the N-decision ids inside notes: docs/normalize-notes.md.

Functions§

canonical
The canonical (spec-preferred) form of input, or undefined if invalid.
is_valid
True if input is valid EDTF (levels 0–2).
level
Minimum conformance level of input: 0, 1 or 2; -1 if invalid.
normalize
Deterministic prose-date normalization (“1980s” → 198X) as a JSON string.
normalize_summary
Build the NormalizeSummary for an input. None only for invalid options JSON.
parse
Full parse summary as a JSON string, or undefined if invalid. See Summary for the object shape.
relate
Build the RelationSummary for two inputs, if both are valid EDTF.
relation
Three-valued temporal relation between a and b as a JSON string, or undefined if either input is invalid. See RelationSummary for the object shape.
summarize
Build the Summary for an input, if it is valid EDTF.