{"id":25765393,"url":"https://github.com/rr0/facts","last_synced_at":"2026-06-15T05:34:05.227Z","repository":{"id":65606340,"uuid":"301084938","full_name":"RR0/facts","owner":"RR0","description":"Facts representation API","archived":false,"fork":false,"pushed_at":"2022-10-09T14:59:02.000Z","size":369,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2023-12-08T08:23:04.540Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RR0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-04T09:07:54.000Z","updated_at":"2021-11-12T17:09:22.000Z","dependencies_parsed_at":"2023-01-31T13:05:11.272Z","dependency_job_id":null,"html_url":"https://github.com/RR0/facts","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RR0%2Ffacts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RR0%2Ffacts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RR0%2Ffacts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RR0%2Ffacts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RR0","download_url":"https://codeload.github.com/RR0/facts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240941511,"owners_count":19882063,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-26T22:18:32.089Z","updated_at":"2025-11-21T05:04:21.182Z","avatar_url":"https://github.com/RR0.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# facts\n[![CircleCI](https://dl.circleci.com/status-badge/img/gh/RR0/facts/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/RR0/facts/tree/main)\n\nFacts representation and rendering API\n\n## Installation\n\n```\nnpm install @rr0/facts --save\n```\n\n## Design\nOnce facts are represented using assembled business objects \n(`Time`, `Place`, `People`, `Organization`, and several `Event` subtypes),\nthey can be provided as parameters to some `Renderer`, which will use a `Translator` to convert them to text (or HTML\n markup, etc.). \n\n## Example\nSay we want to render the timeline of some people:\n```js\nimport {\n  Translator, grammar_fr,\n  HTML, HTMLDocRenderer, HTMLDocRenderOptions,\n  Language, messages_en, messages_fr,\n  OrganizationDescriptionOptions,\n  PeopleNameFormat,\n  TimeRenderFormat,\n  User,\n} from '@rr0/facts';\n\n// The timeline\nconst hynek = new People(Gender.male, 'Josef', 'Hynek', 'Allen')\nconst chicago = new City('Chicago', States.illinois)\nconst birthDate = new DateTime(new Date(1910, 4, 1));\nconst father = new People(Gender.male, 'Joseph')\nconst cigarFactory = new Company(undefined, undefined, ['cigar'])\nfather.events.add(new BirthEvent(father, undefined, Countries.cs))\nfather.events.add(new OccupationEvent(father, OccupationRole.worker, cigarFactory, new BeforeTime(birthDate), Countries.cs))\nconst mother = new People(Gender.female, 'Bertha')\nmother.events.add(new BirthEvent(mother, undefined, Countries.cs))\nhynek.events.add(new BirthEvent(hynek, birthDate, chicago, father, mother))\nconst craneTech = new School(SchoolType.highSchool, 'craneTech')\nhynek.events.add(new StudyEvent(hynek, craneTech, new BeforeTime(new DateTime(new Date(1927, 1, 1)))))\n\n// The options\nconst user = new User('fr');\nconst language = languages[user.locale];\nconst lang = new Translator(user.locale, messages_fr, grammar_fr);\nlang.add('craneTech', 'Lycée technique Crane');\n\nconst orgOptions = {\n  origin: true,\n  name: {short: true, long: true},\n  description: OrganizationDescriptionOptions.inline,\n  types: {army: {}, company: {products: true}}\n};\nconst timeOptions = TimeRenderFormat.fullDate;\nconst peopleOptions = PeopleNameFormat.full;\nconst options: HTMLDocRenderOptions = {\n  title: {\n    name: peopleOptions.name\n  },\n  events: {\n    birth: {\n      verb: true,\n      who: peopleOptions,\n      time: timeOptions,\n      people: PeopleNameFormat.lastName,\n      parent: {\n        people: peopleOptions,\n        occupation: {\n          who: peopleOptions,\n          time: timeOptions,\n          verb: false,\n          type: true,\n          org: orgOptions,\n          role: true\n        }\n      }\n    },\n    occupation: {\n      who: peopleOptions,\n      time: timeOptions,\n      verb: true,\n      type: true,\n      org: orgOptions,\n      role: true\n    },\n    foundation: {\n      verb: true,\n      who: peopleOptions,\n      founders: {\n        occupation: {\n          who: peopleOptions,\n          org: orgOptions,\n          role: false,\n          time: timeOptions,\n          type: false,\n          verb: false\n        },\n        organization: orgOptions,\n        people: PeopleNameFormat.lastName\n      },\n      organization: orgOptions,\n      time: timeOptions\n    },\n    study: {\n      who: peopleOptions,\n      org: orgOptions,\n      role: false,\n      time: timeOptions,\n      type: false,\n      verb: true\n    }\n  }\n};\n\n// The rendering\nconst docRenderer = new HTMLDocRenderer(lang);\nconst contentHTML = docRenderer.render(hynek, options);\n```\nwill return in `contentHTML` the HTML code:\n\n```html\n\u003ch1\u003eJosef Allen Hynek\u003c/h1\u003e\n\u003cp\u003eHynek naît le dimanche 1 mai 1910 à Chicago (Illinois, États-Unis), fils de Joseph (tchécoslovaque)Joseph est ouvrier chez une société produisant des cigares et Bertha (tchécoslovaque).\u003c/p\u003e\n\u003cp\u003eIl étudie au Lycée technique Crane.\u003c/p\u003e\u003c/div\u003e\n```\n\nChange the parameters of the `Translator` to a `en` locale and to use \n`messages_en`, and `grammar_en` and change the custom translation to:\n```js\nlang.add('craneTech', 'Crane Tech high school');\n```\nthen you will get instead:\n\n```html\n\u003ch1\u003eJosef Allen Hynek\u003c/h1\u003e\n\u003cp\u003eHynek was born on Sunday, May 1, 1910 at Chicago (Illinois, USA), son of Joseph (czechoslovak)Joseph is worker for a company that sells cigars and Bertha (czechoslovak).\u003c/p\u003e\n\u003cp\u003eHe studies at the Crane Tech high school.\u003c/p\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frr0%2Ffacts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frr0%2Ffacts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frr0%2Ffacts/lists"}