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 🙏

© 2026 – Pkg Stats / Ryan Hefner

cupofjoe

v0.2.1

Published

Build generic nested structures with a Teacup-like syntax

Readme

☕ CupOfJoe ☕

Table of Contents generated with DocToc

Work in Progress

Motivation

  • Provide a straightforward way to leverage CoffeeScript syntax to build templates for languages like HTML
  • without the magic involved in earlier approaches
  • building on generic structures
  • that are adaptable to a number of usages
  • for example, to output a particular flavor of HTML
  • own syntaxes may be defined by subclassing CupOfJoe

Sample Applications

  • https://github.com/loveencounterflow/datom#cup-of-datom

Notes

  • Three steps:

    • structure building
    • structure expansion
    • structure formatting
  • good strategy to rather build one or more dedicated structure builders ('crammers') than to put too much logic into structure formatting

  • structure expansion will elide all nulls and undefineds

  • may not use async functions, promises; everything is synchronous

  • basic idea is building a list of nested lists

  • any argument to a call to cram() may be a function which will be called w/out arguments; if that function returns w/out having cram()med anything, its return value will be crammed unless it is null or undefined (Note: might allow nulls in the future)

  • do not write

    # (A)
      c.cram 'p', ->
    # ^^^^^^ 1
        c.cram null, "It is very ", ( c.cram 'em', "convenient" ), " to write"
    #   ^^^^^^ 3                      ^^^^^^ 2

    do write

    # (B)
      c.cram 'p', ->
    # ^^^^^^ 1
        c.cram null, "It is very ", ( -> c.cram 'em', "convenient" ), " to write"
    #   ^^^^^^ 2                      ^^^^^^ 3

    This is because in order to call a function, its arguments must first be evaluated, so calling order is (as indicated by the numbers in (A)) not in the order the function calls appear in the text (maybe a good argument [pun intended] in favor of Reverse Polish Notation).

(Almost) A Two-Dimensional Syntax (in a way)

cupofjoe          = new ( require 'cupofjoe' ).Cupofjoe()
{ cram, expand }  = cupofjoe.export()

cram 'two', 'three', 'four'
expand()
# => [ [ 'two', 'three', 'four', ], ]
cupofjoe          = new ( require 'cupofjoe' ).Cupofjoe()
{ cram, expand }  = cupofjoe.export()
cram 'two', ->
  cram 'three'
  cram 'four'

expand()
# => [ [ 'two', 'three', 'four', ], ]

Building Structures with Derived Crammers

cupofjoe          = new ( require 'cupofjoe' ).Cupofjoe { flatten: true, }
{ cram, expand }  = cupofjoe.export()

h = ( tagname, content... ) ->
  return cram content...      if ( not tagname? ) or ( tagname is 'text' )
  return cram "<#{tagname}/>" if content.length is 0
  return cram "<#{tagname}>", content..., "</#{tagname}>"

h 'paper', ->
  h 'article', ->
    h 'title', "Some Thoughts on Nested Data Structures"
    h 'par', ->
      h 'text',   "An interesting "
      h 'em',     "fact"
      h 'text',   " about CupOfJoe is that you "
      h 'em',     "can"
      h 'text',   " nest with both sequences and function calls."
  h 'conclusion', ->
    h 'text',   "With CupOfJoe, you don't need brackets."

html = expand().join ''

Output (reformatted for readability):

<paper>
  <article>
    <title>Some Thoughts on Nested Data Structures</title>
    <par>
      An interesting <em>fact</em> about CupOfJoe is that you
      <em>can</em> nest with both sequences and function calls.
      </par>
    </article>
  <conclusion>With CupOfJoe, you don't need brackets.</conclusion>
  </paper>

Legacy

         Markaby
            ⇓
         CoffeeKup
            ⇓
  CoffeeCup    DryKup  =>  kup
            ⇓
          Teacup
            ⇓
     CoffeNode-Teacup
            ⇓
         CupOfJoe
  • kup

    • https://github.com/snd/kup
    • forget underpowered template languages - build HTML with the full power of coffeescript
  • DryKup

    • https://github.com/mark-hahn/drykup
    • A CoffeScript html generator compatible with CoffeeKup but without the magic.