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

@briannorman9/eli-utils

v1.1.0

Published

Utility functions for web experiments with ELI (Experimentation Local Interface)

Downloads

31

Readme

@briannorman9/eli-utils

Utility functions for web experiments with ELI (Experimentation Local Interface).

Installation

npm install @briannorman9/eli-utils

Usage

Import the utils in your ELI variant code:

import utils from '@eli/utils';

Note: ELI's import system automatically resolves @eli/utils to @briannorman9/eli-utils from your project's node_modules.

API

DOM Utilities

waitForElement(selector)

Wait for the first element matching the selector to appear in the DOM. Note: This only matches the first element. Use waitForElements() to match all elements.

utils.waitForElement('#myElement').then(element => {
  console.log('Element found:', element);
});

waitForElements(selector, context)

Wait for all elements matching the selector to appear in the DOM. Note: This matches all elements. Use waitForElement() to match only the first element.

utils.waitForElements('.product-card').then(elements => {
  elements.forEach(card => card.style.border = '2px solid red');
});

waitUntil(condition, interval)

Wait until a condition function returns true.

utils.waitUntil(() => document.readyState === 'complete');

select(selector, context)

Select a single element (returns immediately, does not wait).

const button = utils.select('#myButton');

observeSelector(selector, callback, options)

Observe mutations on the first element matching the selector. The callback is called every time the element is mutated (attributes, children, text, etc.). Note: This only observes the first matching element. Use observeSelectors() to observe all elements.

Mutation types:

  • 'childList' - Watch for child nodes being added/removed (default: true)
  • 'attributes' - Watch for attribute changes (default: true)
  • 'characterData' - Watch for text content changes (default: false)
  • 'subtree' - Watch all descendants, not just direct children (default: true)
  • 'attributeOldValue' - Include old attribute value in mutation record (default: false)
  • 'characterDataOldValue' - Include old text value in mutation record (default: false)
  • 'attributeFilter' - Array of attribute names to observe (only these attributes will trigger)
// Observe attribute changes on a button
const stopObserving = utils.observeSelector('#myButton', (element, mutation) => {
  console.log('Button mutated:', mutation.type);
  if (mutation.type === 'attributes') {
    console.log('Attribute changed:', mutation.attributeName);
  }
}, {
  mutations: ['attributes'],
  attributeFilter: ['class', 'disabled']
});

// Observe when children are added/removed
utils.observeSelector('.product-list', (element, mutation) => {
  if (mutation.type === 'childList') {
    console.log('Children changed:', mutation.addedNodes.length, 'added');
  }
}, {
  mutations: ['childList', 'subtree']
});

observeSelectors(selector, callback, options)

Observe mutations on all elements matching the selector. The callback is called every time any matching element is mutated. Note: This observes all matching elements. Use observeSelector() to observe only the first element.

// Observe all product cards for attribute changes
const stopObserving = utils.observeSelectors('.product-card', (element, mutation) => {
  if (mutation.type === 'attributes' && mutation.attributeName === 'data-price') {
    console.log('Price changed on:', element);
  }
}, {
  mutations: ['attributes'],
  attributeFilter: ['data-price', 'class']
});

Class Manipulation

addClass(element, className)

Add a class to an element.

utils.addClass('#myButton', 'active');

removeClass(element, className)

Remove a class from an element.

utils.removeClass('#myButton', 'inactive');

toggleClass(element, className)

Toggle a class on an element.

utils.toggleClass('#myButton', 'active');

hasClass(element, className)

Check if an element has a class.

if (utils.hasClass('#myButton', 'active')) {
  console.log('Button is active');
}

Event Handling

on(element, event, handler)

Add an event listener.

utils.on('#myButton', 'click', () => console.log('Clicked!'));

off(element, event, handler)

Remove an event listener.

utils.off('#myButton', 'click', handler);

delegate(parent, selector, event, handler)

Event delegation - attach event to parent, handle on children.

utils.delegate('#container', '.button', 'click', (e) => {
  console.log('Button clicked:', e.target);
});

triggerEvent(eventName, data, target)

Trigger a custom event.

utils.triggerEvent('experimentLoaded', { variant: 'v1' });

Cookies

getCookie(name)

Get a cookie value by name.

const userId = utils.getCookie('userId');

setCookie(name, value, days, path)

Set a cookie.

utils.setCookie('userId', '12345', 30);

URL Utilities

getQueryParam(name, url)

Get a URL query parameter value.

const campaign = utils.getQueryParam('campaign');

Viewport Utilities

getViewport()

Get the viewport dimensions.

const { width, height } = utils.getViewport();

isInViewport(element, threshold)

Check if element is in viewport.

if (utils.isInViewport('#myElement')) {
  console.log('Element is visible');
}

scrollIntoView(element, options)

Scroll element into view.

utils.scrollIntoView('#myElement', { behavior: 'smooth', block: 'center' });

License

MIT