npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@eeue56/coed

v0.4.0

Published

Write HTML in pure TS

Readme

coed

Coed is a small library intended to be used on small TypeScript projects. It contains an Elm-inspired model-view-update loop, complete with relative type-safety and side effects.

Part of the Hiraeth collection.

Installation

npm install --save @eeue56/coed

Usage

API docs

Like Elm, everything is built around functions. There's no JSX to be seen - writing html is done via functions that take three arguments: events, attributes, and children. There's also html.text which simply takes a string to be rendered.

You should break your program down into logical sections: two types, Model to represent the data used by the view functions to render, Msg to represent interactions and state changes. Then you need a view function of the type Model -> HtmlNode<Msg>, and an update function of the type Msg -> Model -> (?Msg -> void) -> Model. These will be passed to html.program. You will need a root element in your index.html file which you pass to html.program, too.

For example:

import { HtmlNode, div, on, style_, text } from "@eeue56/coed";
import * as coed from "@eeue56/coed";

type FlipName = { kind: "FlipName" };
function FlipName(): Msg {
    return {
        kind: "FlipName",
    };
}

type Msg = FlipName;
type Model = { name: string };

function update(msg: Msg, model: Model): Model {
    switch (msg.kind) {
        case "FlipName":
            if (model.name === "Noah") {
                return { name: "Ianto" };
            } else {
                return { name: "Noah" };
            }
    }
}

function view(model: Model): HtmlNode<Msg> {
    return div(
        [on("click", () => FlipName())],
        [style_("color", model.name === "Noah" ? "green" : "red")],
        [text(model.name)],
    );
}

function main() {
    const root = document.getElementById("root");
    if (root === null) return;

    const program = coed.program({
        root: root,
        initialModel: { name: "Noah" },
        view: view,
        update: update,
    });
}

main();

You can send data to program at a later point, for example:

function main() {
    const root = document.getElementById('root');

    const program = coed.program({
        root: root
        initialModel: { name: "Noah" },
        view: view,
        update: update,
    });

    setTimeout(() => {
        program.send(FlipName())
    }, 3000);
}

Or via the optional argument send in the update function:

function update(msg: Msg, model: Model, send: (msg: Msg) => void): Model {
    switch (msg.kind) {
        case "FlipName":
            setTimeout(() => {
                send(FlipName());
            }, 3000);

            if (model.name === "Noah") {
                return { name: "Ianto" };
            } else {
                return { name: "Noah" };
            }
    }
}

Hydration

There is also hydration support, via using render with hydrate. Check out the hydration folder for an example.

Name

Coed is the Welsh word for trees, forest, wood. For English speakers it'd be pronounced similar to "coyed".