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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wmdigi/dom

v2.1.12

Published

A lightweight DOM manipulation and state management library with jQuery-like syntax.

Downloads

609

Readme

@wmdigi/dom

A lightweight DOM manipulation and state management library with jQuery-like syntax.

Installation

npm install @wmdigi/dom
yarn add @wmdigi/dom
bun add @wmdigi/dom

Usage

import { $ } from "@wmdigi/dom";

// DOM Manipulation
$(".button").addClass("active");
$("#main").hide();
$('input[type="text"]').val("Hello");

// Store Management
$.store.user = { name: "John", age: 30 };
$.store.user.name = "Jane"; // Updates only name

// Subscribe to changes
$.store.user.subscribe((user) => {
	console.log("User updated:", user);
});

$.store.user.name.subscribe((name) => {
	console.log("Name changed to:", name);
});

// Local Storage Store
$.local.theme = "dark"; // Automatically persists to localStorage
console.log($.local.theme); // Reads from localStorage

// Chaining
$(".card").addClass("highlight").attr("data-active", "true").show();

// Event handling
$(".submit-button").on("click", (e) => {
	console.log("Button clicked at:", e.clientX, e.clientY);
});

// DOM Ready
$.ready(() => {
	console.log("DOM is ready");
});

// Creating elements
$.create('<div class="new">Content</div>').addClass("active");

// Timeout utility with cleanup
const clear = $.timeout(() => {
	console.log("Delayed execution");
}, 1000);

// Optional: Cancel timeout
clear();

API

DOM Selection

  • $(selector) - Select elements using CSS selector
  • $(element) - Wrap DOM element
  • $(elements) - Wrap array of DOM elements

Store Management

  • $.store - Global state store
  • $.local - localStorage-backed store
  • .subscribe(callback) - Subscribe to state changes

DOM Methods

  • .first - Get first element
  • .array - Get array of elements
  • .val([value]) - Get/set input value
  • .text([content]) - Get/set text content
  • .html([content]) - Get/set HTML content
  • .data([key], [value]) - Get/set data attributes
  • .addClass(...classes) - Add classes
  • .removeClass(...classes) - Remove classes
  • .toggleClass(class) - Toggle class
  • .hasClass(class) - Check if element has class
  • .attr(name, [value]) - Get/set attribute
  • .on(event, callback) - Add event listener
  • .hide() - Hide elements
  • .show() - Show elements

Utility Methods

  • $.ready(callback) - DOM ready handler
  • $.create(html) - Create element from HTML
  • $.timeout(callback, ms) - Execute callback after delay with cleanup

Development

# Clone and setup
git clone https://github.com/wmdigi/dom.git
cd dom
bun install

# Build
bun run build

Publishing

# Patch version (1.0.0 -> 1.0.1)
bun pub

# Minor version (1.0.0 -> 1.1.0)
bun pub minor

# Major version (1.0.0 -> 2.0.0)
bun pub major

The publish script automatically:

  1. Builds the library
  2. Commits changes
  3. Bumps version
  4. Pushes to git with tags
  5. Publishes to npm

License

MIT

Contributing

Pull requests welcome. For major changes, please open an issue first.

Credits

Created by Wonder Makers - making the web simpler, one library at a time.