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

uce-mixins

v0.6.1

Published

A set of utilities for uce

Readme

uce-mixins

Provides an events and state mixins to enhance uce lib.

Example

import { css, define } from "https://unpkg.com/uce?module";
import { events, mixin, state } from "https://unpkg.com/uce-mixins?module";

define("my-loader", mixin(events, {
  props: {
    loading: false,
  },
  handleEvent() {
    this.emit("catch", "You caught me!");
  },
  render() {
    const { loading } = this;

    this.html`
      <p onclick=${this}>
        ${loading ? "Decreasing..." : ""}
      </p>
    `;
  },
}));

/**
 * == events mixin
 *
 * Bound all methods and provides some useful like:
 *
 * - emit method
 * - events attribute
 *
 * == state mixin
 *
 * Works similarly React's state/setState.
 */
define("my-counter", mixin(events, state, {
  style(el) {
    return css`
      ${el} span {
        font-size: 2em;
        display: inline-block;
        text-align: center;
        width: 4rem;
      }
      ${el} button {
        background-color: seagreen;
        border: none;
        border-radius: 10px;
        color: white;
        font-size: 2em;
        height: 64px;
        width: 64px;
      }
    `;
  },
  state: {
    count: 0,
    loading: false,
  },
  /** 
   * If events is an array, the bound method is handleEvent.
   * 
   * Ex.: 
   * 
   * define("my-counter", mixin(events, state, {{
   *   ...
   *   events: ["click button:nth-child(1)"],
   *   handleEvent() {
   *     this.setState((s) => ({ count: s.count - 1 }));
   *   },
   *   ...
   * });
   */
  events: {
    /**
     * The syntax is the same as Backbone View Events.
     * https://backbonejs.org/#View-events
     */
    "click button:nth-child(1)": "dec",
    /**
     * An anonymous function can be passed instead the name of method.
     */
    "click button:nth-child(3)": function () {
      this.setState((s) => ({ count: s.count + 1 }));
    },
    /**
     * If query is not defined, event listeners
     * will be added to this custom element.
     *
     * PS: this is not necessary as you can use the
     * auto-attach feature from uce... But, if you
     * would like to use another method name, this
     * can become handy.
     */
    "catch": "handleCatch",
  },
  // Could be `onCatch` too (uce auto-attach handler).
  handleCatch(evt) {
    alert(evt.detail);
  },
  async dec() {
    if (this.state.loading) return;

    this.setState({ loading: true }, console.log);

    await new Promise((resolve) => {
      setTimeout(() => {
        this.setState(
          (s) => ({ count: s.count - 1, loading: false }),
          console.log
        );
        resolve();
      }, 1000);
    });
  },
  render() {
    const { count, loading } = this.state;

    this.html`
      <button>-</button>
      <span>${count}</span>
      <button>+</button>
      <my-loader .loading=${loading} />
    `;
  },
}));

Result: https://codepen.io/djalmajr/pen/vYGjWrG