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

stack-element

v0.0.9

Published

Modular DOM elements that incrementally construct via stack middleware.

Downloads

29

Readme

Stack Element

(WIP / ALPHA)

Usage

npm install stack-element

(requires browser supporting new custom elements spec, ie: Chrome 54+)

var stack = require('stack-core')
require('stack-element')(stack) 
//^ Extends your existing stack with these new commands.

//Define your own custom elements: 
stack.on('element/my-thingy', (state, next) => {
  //state.element is now a special object containing the custom
  //DOM element 'my-thingy', a base template (plus rendering feature), a set
  //of it's own commands, and a basic API. 
  state.element.html('<p>Test</p>')
  state.element.addStyle(`color { blue; }`)
  next(null, state)
})

stack.on('element/my-thingy', (state, next) => {
  state.element.append('<p>A-OK</p>')
  state.element.addStyle(`background-color { red; }`)
  next(null, state)
})

//Fire the listeners defined above: 
stack.fire('element/my-thingy')
//After reaching the bottom of the stack, the element will render the changes to it's template to the DOM. 

The element should exist in the DOM.

  <my-thingy></my-thingy>
  <!-- turns into: -->
  <my-thingy>
    <p>Test</p>
    <p>A-OK</p>
  </my-thingy>

Your stack element listner has access to the entire state object of the application so it can use that data. Stack elements can modify state, but isn't encouraged; the idea is that your stack-element listeners should modify the supplied element (state.element). Treating the parent state object as 'read only' and simply tapping into it for the purpose of rendering stuff to the DOM.

You can also take advantage of the set of built-in commands the element has:

stack.on('/element/my-thingy/click', (state, next) => {
  console.log(state.element.event)
  //Do something here in response to the click. 
  next(null, state)
})

You can also define your own commands.

stack.on('/element/my-thingy/magic-animation', (state, next) => {
  //Make the element dance. 
  next(null, state)
})

stack.fire('/element/my-thingy/magic-animation')

The API is the same as stack, just that we prepend the word '/element/' on each command.

on(string, callback)

Prepend the string with 'element:' and then the name of your element. The element name must have a dash. Callback will run, in the order that it is definied, when fired. In your callback function, call next(null, state) to pass the state to the next object, if you don't do this the stack will finish.

fire(string, callback)

Runs each of the element's listeners (ie- stack.on's) in order.

There is also a special command to initialize all of your stack elements.

stack.fire('/element/init/yourprefix') //ie: any elements with the name my-thingy can be initialized with /element/init/my

Supplying a default template

You can supply a default template by including it within your element.

Testing

Run npm test to run the integration test. It will spawn a server on port 8080.
If the server doesn't exit cleanly (common when tests fail), use the following (Linux) command to kill it / test again:

kill `lsof -t -i:8080`; npm test

Compatible with stack-core #494e3e0e6de536e113d70f7c37b2ef1956e6c3e0 (noteful because stack-core is not an explicit dep, however it is required to be passed in as a param; hence we can pinpoint potential breaking changes based on the expected stack version indicated above)