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

khufu

v0.5.2

Published

A template language for incremental-dom or DSL for javascript views

Readme

Khufu

| | | |--------------|-------------------------------------------| |Documentation | http://tailhook.github.io/khufu/ | |Demo | http://tailhook.github.io/khufu/demo.html | |Status | beta ¹ |

At a glance, Khufu is a template-engine for incremental-dom.

But more characteristically I call it is a domain-specific language (DSL) for view-driven single-page applications.

The boring list of features:

  • Nice, compact, indentation-based syntax, designed for readability
  • Rich-enough subset of javascript is allowed right in the template
  • Styles in the same file as view (HTML), properly namespaced
  • Avoids separate code to compose redux stores (kinda auto-generates it)
  • Supports webpack hot module replacement (aka hot reload)

[1] More verbose status: I feel that the language itself (the syntax) is 90% complete (thanks to it's predecessor). There are ugly edge cases of the compiler here and there. And the server-side render is not implemented yet. Otherwise, the project is small enough to just work.

Installation

npm install [email protected] --save-dev
npm install [email protected] --save

Why?

  1. JSX is ugly. Mixing javascript and HTML is ugly
  2. Conversely, I want to mix CSS with HTML and enough dynamic features ²
  3. I'm tired of composing views and stores independently ³

[2] Indentation-based syntax is a bonus. [3] Sure, the model proposed here doesn't work for everyone.

So What Is It?

It's mostly a DSL around HTML, that looks a lot like just a template language similar to Jade, that compiles into Incremental DOM. Additionally Khufu:

  1. Reuses incremental dom diffing algorithm to diff redux or flux-like stores
  2. Allows to write styles in the same file which are properly namespaced without long ugly prefixed like in BEM

So What is "View-Driven"?

It means when you design an application you build a single powerful view. And all server-side data are fetched when a user enters some subview and is disposed when user leaves the view (of course, data can be prefetched and cached, but that's optimization orthogonal to what we're discussing here).

For example:


    import {search, set_query} from 'myapp/search'
    import {image, load} from 'myapp/util/image_loading'
    import {select} from 'myapp/action_creators'

    view main():
      <div>
        store @results = search
        <form>
          <input type="text" placeholder="search">
            link {change, keyup} set_query(this.value) -> @results

        if @results.current_text:
          if @results.loading:
            <div.loading>
              "Loading..."
          else:
            <div.results>
            for item of @results.items:
              <div.result>
                store @icon_loaded = image | load(item.img)
                if @icon_loaded.done:
                    <img src=item.img>
                else:
                    <div.icon-loading>
                <div.title>
                    item.title

This example displays a search box. When some search query is typed into the input box, search request is sent to the server immediately. This displays "Loading..." stub and replaces the stub with the results when they are loaded from a server. There is also the code to download images asynchronously.

Some explanations:

  1. Nesting of elements is denoted by indentation, hence no closing tags
  2. div.cls is shortcut for <div class="cls">
  3. store denotes a redux store
  4. link allows to bind events to an action (or an action creator)

The store thing might need a more comprehensive explanation:

  1. Stores are lexically scoped
  2. More so, on each loop iteration we get new scope
  3. Diffing algorithm of incremental-dom drops unused stores automatically
  4. They provide lifecycle hooks, so can dispose resources properly
  5. Store is prefixed by @ to get nice property access syntax

[4] Sure, you can delay requests by adding RxJS or redux-saga or any other middleware to the store [5] Yes, we attach resources (such as network requests) to stores, using middleware [6] Otherwise would need to call getState() each time. We also cache the result of the method for subsequent attribute access

Isn't it Like Good Old HTML?

Right. You do a Khufu view, add events and everything works. Just like you have been doing HTML page and add jQuery plugins to make that work.

There are few crucial improvements, however:

  1. All your variables are properly namespaced (and styles too). So there is no global identifiers which prevent composing and reusing things
  2. This plays well with javascript module system (every template is a module, imports work, and so on)
  3. The updates of fragments are much better using virtual DOM

You can also think of each view function being a component similar to what you find in react or angular. Have I said that syntax is much more readable?