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

jamon

v0.1.0

Published

Another DOM library

Downloads

24

Readme

Jamón Build Status Coverage Status

Lightweight ES6 DOM library

Usage

Use $(selector) or Jamon.get(selector) to select a single element:

$("div");
$(".menu");
$("#Header");

Use $$(selector) or Jamon.getAll(selector) to select multiple elements:

$$("a > span");
$$(".menu");
$$("#section-1, #section2");

Jamón only registers the globals $() and $$() if they are unused.

API

Working with Jamón instances

Jamón extends the built-in Array so instances behave just like regular arrays. You can use all array prototype methods like forEach, map, push, join, etc, or iterate with for...of loops.

items()

Provides an Iterable that yields each element wrapped in a Jamón instance

Classes

addClass(className)

Adds a class name or a list of space-separated class names to the element(s).

removeClass(className)

Removes a class name or a list of space-separated class names from the element(s).

toggleClass(className)

Toggles a class name or each class name of a space-separated list on the element(s).

show()

Shows the element(s) by adding the hidden class name.

hide()

Hides the element(s) by removing the hidden class name.

toggle()

Toggles the element(s) by toggling the hidden class name.

For show(), hide() and toggle() to work you need to include the following line in your CSS:

.hidden { display: none !important; }

You can customize this class name by changing the value of Jamon.hiddenClassName.

Attributes

val([value])

Gets the value of the first element or sets the value of each element.

html([value])

Gets the html content of the first element or sets the html content of each element.

text([value])

Gets the text content of the first element or sets the text content of each element.

prop(property [, value])

Gets the value of a property of the first element or sets the value of a property of each element.

attr(attribute [, value])

Gets the value of an attribute of the first element or sets the value of an attribute of each element.

data(attribute [, value])

Gets the value of the data attribute for the first element or sets the data attribute value for each element.

Styling

css(property [, value])

Gets the computed value of the CSS property for the first element or sets the value of the CSS property for each element.

Dimensions

width()

Gets the width of the first element.

height()

Gets the height of the first element.

Positioning

offset()

Gets the offset position of the first element relative to the offset parent.

position()

Gets the absolute position of the first element or sets the position of each element relative to the page.

DOM Traversal

findOne(selector)

Finds the first descendant that matches the selector in any of the elements.

findAll(selector)

Finds all descendants that match the selector in each element.

parent()

Gets the parent element of each element.

closest(selector)

Gets the closest parent matching the selector of each element.

children()

Gets the children elements of each element.

Manipulation

These methods only work with one subject and one target i.e. the first element in the collection.

prepend(subject)

Prepends another element or string to the element.

prependTo(target)

Prepends the first element to another element.

append(subject)

Appends another element or string to the element.

appendTo(target)

Appends the element to another element.

before(subject)

Inserts another element or string before the element.

insertBefore(target)

Inserts the element before another element.

after(subject)

Inserts another element or string after the element.

insertAfter(target)

Inserts the element after another element.

replaceWith(subject)

Replaces the element with another element.

replace(target)

Replaces another element with the element.

clone(deep)

Clones each element in the collection.

remove()

Removes each element from the DOM.

Events

on(events, [,selector] , listener)

Adds the listener for each of the events to each element. Provide an optional selector string for event delegation.

off(events [,selector] , listener)

Removes the standard or delegated event listeners from the elements.

trigger(event [, data])

Triggers an event on each element. The additional event data can be accessed in the event.detail property. Supported native events: mouse, focus and keyboard events.

Utilities

Jamon.get(selector|element)

Creates a new Jamón collection with only one element.

Jamon.getAll(selector|iterable)

Creates a new Jamón collection with multiple elements.

Jamon.create(tagName)

Creates a new HTML element.

Jamon.hiddenClassName

Overrides the default class name hidden used for hiding elements.