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

@kirinnee/domex

v0.0.11

Published

Extend DOM prototype to have a few utility methods.

Downloads

20

Readme

DOMEx

Extend DOM prototype to have a few utility methods.

Getting Started

Install via NPM

$ npm i @kirinnee/domex

or

Install via Yarn

$ yarn add @kirinnee/domex --prefer-offline

Using in browser

Attach scripts in dist/ folder

<script src="./dist/domex.min.js"></script>

Usage

DOMEx evil-ly extends prototype of HTMLElement and all its sub-classes. This gives us a variety of slightly useful method. Do note that DOMEx is only cross-platform is DOM4 Polyfill is installed.

Append

function Append(elements: HTMLElement|HTMLElement[]|string|string[]):HTMLElement

Appends the HTMLElement or text to the end of the target element.

let x = document.querySelector("#some-node");
//Append Element
x.Append(document.createElement("a"));
//Append Text
x.Append("HEY <div> HI! </div>");

Prepend

function Prepend(elements: HTMLElement|HTMLElement[]|string|string[]):HTMLElement

Prepends the HTMLElement or text to the start of the target element.

let x = document.querySelector("#some-node");
//Append Element
x.Prepend(document.createElement("a"));
//Append Text
x.Prepend("HEY <div> HI");

Add Class

function AddClass(cls: string|string[]):HTMLElement

Adds a or an array of classes to the element.

//Add single class "blue-class"
x.AddClass("blue-class");
//Add multiple classes
x.AddClass(["blue-class","red-class","green-class"]);

Remove Class

function RemoveClass(cls:string|string[]):HTMLElement

Removes a or an array of classes to the element.

//Remove 1 class
x.RemoveClass('blue-class');
//Remove multiple classes
x.RemoveClass(["blue-class","red-class","green-class"]);

Setting Attribute

function Attr(attr:string, value:string):HTMLElement

Adds or change an attribute of the element

x.Attr('id','complex-identifier');

Accessing Attribute

function Attr(attr:string):string

Access the value of certain attribute

let id:string = x.Attr('id');

Setting Styles

function Style(attr:string, value:string): HTMLElement

Set the style of certain attribute

x.Style('color','blue');

Getting Styles

function Style(attr:string): string

Access the value of the style

let color:string = x.Style('color');

Setting the ID of the element

function Id(value:string): HTMLElement

Sets or changes the ID of the target element

x.Id("complex-identifier");

Access the ID of the element

function Id(): string

Gets the value of the ID of the element

let id = x.Id();

Adding Click Listener

Click(listener: ClickListener): HTMLElement;

Adds a click listener to the element

//Display which mouse button was use to click
x.Click( (button:number, e:MouseEvent) => console.log(button));

Adding Wheel Listener

WheelDown(listener: WheelListener): HTMLElement

WheelUp(listener: WheelListner): HTMLElement

//print to console how much has the user wheel-down
x.WheelDown((delta:number, e:WheelEvent) => console.log(delta));
//print to console how much has the user wheel-up
x.WheelUp((delta:number, e:WheelEvent) => console.log(delta));

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

License

This project is licensed under MIT - see the LICENSE.md file for details