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

ndom

v1.0.2

Published

A DOM wrapper with IntelliSense.

Downloads

29

Readme

ndom

A DOM wrapper with IntelliSense.

Installation

npm install --save ndom

The UMD build is in the dist directory.

Short story

Why not any of the others? Because I like this syntax more, actual property getters for every get operation. The collection of elements extends a real Array object so you get all the methods of the Array prototype. Small code. Only necessary functions, maybe even missing some.

const ndom = require('ndom');

ndom('body').html = '<div id="div1">DIV IN BODY</div>';
ndom('#div1').html = '<a>l1</a><a>l2</a><a>l3</a>';

console.log(ndom('#div1').width, ndom('#div1').size.width === ndom('#div1').width);
console.log(ndom('#div1 a').html);

ndom('#div1 a').forEach((a, i) => {
    console.log(a);
    ndom(a).html += ' - <b>' + i + '</b>';
});

ndom('#div1 a').on('click', e => console.log('CLICK', e));
ndom('#div1 a').once('click', (e, node) => console.log('CLICK ONCE', node, e));
ndom('#div1 a').on('click', function(e) {
    console.log('Binds to: ', this);
});

// etc...

Long story

Classes

ndom

ndom(selector, [parent])

| Param | Type | | --- | --- | | selector | * | | [parent] | * |

ndom.match(el, selector) ⇒ boolean

| Param | Type | | --- | --- | | el | * | | selector | * |

ndom.onLoad(callback) ⇒ ndom

| Param | Type | | --- | --- | | callback | function |

ndom.onReady(callback) ⇒ ndom

| Param | Type | | --- | --- | | callback | function |

Collection ⇐ Array

Kind: global class
Extends: Array

collection.node ⇒ HTMLElement

collection.parent ⇒ Collection

collection.size ⇒ Object

collection.width ⇒ number

collection.height ⇒ number

collection.outerSize ⇒ Object

collection.offset ⇒ Object

collection.offsetParent ⇒ Collection

collection.offsetViewport ⇒ ClientRect

collection.position ⇒ Object

collection.left ⇒ number

collection.top ⇒ number

collection.html ⇒ string

collection.outerHtml ⇒ string

collection.text ⇒ string

collection.class ⇒ string

collection.classes ⇒ Array

collection.children ⇒ Collection

collection.length ⇒ number

collection.html

| Param | Type | | --- | --- | | html | string |

collection.text

| Param | Type | | --- | --- | | text | string |

collection.query(selector) ⇒ Collection

| Param | Type | | --- | --- | | selector | string | Collection | HTMLElement | * |

collection.queryParents(selector) ⇒ Collection

| Param | Type | | --- | --- | | selector | string | Collection | HTMLElement | * |

collection.contains(child) ⇒ boolean

| Param | Type | | --- | --- | | child | string | Collection | HTMLElement | * |

collection.clone() ⇒ Collection

collection.getAttr(name) ⇒ string | null

| Param | Type | | --- | --- | | name | string |

collection.hasClass(name) ⇒ boolean

| Param | Type | | --- | --- | | name | string |

collection.setAttr(name, value) ⇒ Collection

| Param | Type | | --- | --- | | name | string | | value | * |

collection.addClass(name) ⇒ Collection

| Param | Type | | --- | --- | | name | string |

collection.removeClass(name) ⇒ Collection

| Param | Type | | --- | --- | | name | string |

collection.setHtml(html) ⇒ Collection

| Param | Type | | --- | --- | | html | string |

collection.setText(text) ⇒ Collection

| Param | Type | | --- | --- | | text | string |

collection.serialize([asObject]) ⇒ string | object

| Param | Type | | --- | --- | | [asObject] | boolean |

collection.append(children) ⇒ Collection

| Param | Type | | --- | --- | | children | Collection | HTMLElement | Array | * |

collection.prepend(children) ⇒ Collection

| Param | Type | | --- | --- | | children | Collection | HTMLElement | * |

collection.remove() ⇒ Collection

collection.replace(html) ⇒ Collection

| Param | Type | | --- | --- | | html | string | Collection | HTMLElement | * |

collection.insertAfter(html) ⇒ Collection

| Param | Type | | --- | --- | | html | string | Collection | HTMLElement | * |

collection.insertBefore(html) ⇒ Collection

| Param | Type | | --- | --- | | html | string | Collection | HTMLElement | * |

collection.empty() ⇒ Collection

collection.on(type, [selector], handler) ⇒ Collection

| Param | Type | | --- | --- | | type | string | | [selector] | string | function | | handler | function |

collection.once(type, [selector], handler) ⇒ Collection

| Param | Type | | --- | --- | | type | string | | [selector] | string | function | | handler | function |

collection.off(type, [selector], handler) ⇒ Collection

| Param | Type | | --- | --- | | type | string | | [selector] | string | function | | handler | function |

collection.emit(eventName) ⇒ Collection

| Param | Type | | --- | --- | | eventName | string |

collection.dispatch(event) ⇒ Collection

| Param | Type | | --- | --- | | event | Event | * |

Collection.wrap(collection, ndom, window) ⇒ Collection

| Param | Type | | --- | --- | | collection | Array | Collection | NodeList | | ndom | ndom | | window | Window |

TODO

Test test test.