Files
typikon/npm/README.md
T
funkpower 69907eb186 javascript and typescript, as one wasm package for every runtime
WebAssembly rather than a native Node addon: one artifact serves Node,
Deno, Bun, a browser and anything built on them, where napi would have
meant a prebuilt binary per platform and a source build for whoever the
matrix missed. The engine is pure computation and the menologion is
already compiled in, so there is nothing for it to give up.

A day comes back as a plain object, not a handle. A wasm class would
have meant a .free() that every caller eventually forgets, and this way
JSON.stringify works and the thing spreads into state. Two serializer
defaults had to be overridden to keep the promise that it is the same
document --json emits: maps as objects, and an absent field as null
rather than undefined, which stringify would otherwise drop entirely.

The TypeScript is hand-written, because the generated types for a value
crossing as JsValue are `any`, and a binding that types its whole
return as `any` is a binding TypeScript cannot check. tsc --strict is a release
gate now, the way mypy --strict already is, and the check includes three
lines that must fail to compile.

The one place this differs from every other binding: no remembered
default jurisdiction, because a browser has nowhere to keep one. It is
called out in the README, in the types and in docs/versioning.md.

The test resolves typikon through a staged node_modules rather than a
relative path, so what it exercises is the exports map, and it compares
a year of days field by field against the command line for four
jurisdictions.
2026-09-18 14:55:40 -04:00

85 lines
2.9 KiB
Markdown

# typikon
The Orthodox liturgical day: feasts, seasons and the fast, computed rather
than fetched. No network, no data files, no service to be up.
```sh
npm install typikon
```
```js
import { today } from "typikon";
const day = today({ jurisdiction: "rocor" });
day.churchDate; // "5 September"
day.fast; // "xerophagy"
day.fastLabel; // "xerophagy — no oil or wine"
day.emoji; // the glyph for the level
day.title; // "The Holy Prophet Zachariah, father of the Forerunner"
day.season; // null in ordinary time
day.daysToPascha;
```
In a browser or a bundler, load the module first:
```js
import init, { today } from "typikon";
await init();
const day = today({ jurisdiction: "rocor" });
```
Node needs no `init`, because it can read the WebAssembly itself. The exports
map picks the right build; `typikon/node` and `typikon/web` force one.
## What comes back
A plain object, not a handle: the same document `typikon --json` emits, with
the same field names and the same stability promise. Nothing has to be freed
and `JSON.stringify` works on it. TypeScript types ship with the package.
## The rest of it
```js
import { describe, describeIso, week, pascha, jurisdictions } from "typikon";
describe(new Date(2026, 3, 12), { jurisdiction: "moscow" });
describeIso("2026-04-12", { jurisdiction: "moscow" });
week(new Date(), 7, { jurisdiction: "goarch" }); // seven consecutive days
pascha(2027, "old"); // 2027-05-02
jurisdictions(); // [{ key, name, note }, ...]
```
`week` reckons the year's movable cycle once rather than once a day, so it is
the thing to call for a calendar grid.
## Which calendar
`jurisdiction` takes a church key, or a bare calendar where the church does not
matter: `"old"` (Julian throughout), `"new"` (Revised Julian fixed feasts with
the Julian Paschalion, the default) or `"western"` (Gregorian throughout,
Pascha included). `jurisdictions()` lists the rest. Two more options:
- `tradition`, `"slavic"` or `"greek"`, overriding the church's own usage. It
moves fish in the Nativity Fast and the rank of the Protection.
- `typikon: true`, to show a day at the Typikon's full discipline rather than
at the minimum a church's own particular law requires. What binds is reported
either way, in `binds` and `obligation`. This is for the Byzantine Catholic
churches, whose law asks very much less than the tradition they keep.
Unlike the command line and the Python bindings, there is no remembered
default: a browser has nowhere to keep one, so the default is the New Calendar
and anything else is passed.
## Accuracy
The Paschalion is exact. The fast follows the Typikon as the standard printed
calendars apply it, which is the part where careful people differ; a parish
calendar or a confessor overrides this, and neither is a bug report.
## Licence
GPL-2.0-only. Source: https://git.pumpin.online/funkpower/typikon