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

fepp

v2.1.0

Published

<dl> <dt><a href="#newElement">newElement([tagName], [...classList])</a> ⇒ <code><a href="#element">element</a></code></dt> <dd><p>Creates an instance of Element.</p> </dd> <dt><a href="#newDocument">newDocument()</a> ⇒ <code><a href="#document">document<

Downloads

5

Readme

Functions

Typedefs

newElement([tagName], [...classList]) ⇒ element

Creates an instance of Element.

Kind: global function

| Param | Type | Default | Description | | --- | --- | --- | --- | | [tagName] | string | "div" | The tag type. | | [...classList] | string | | Class to apply to element. |

newDocument() ⇒ document

Creates an instance of Document. Ran once at setup, creating the exported document variable

Kind: global function

document : external:document

The document class from jsdom.

Kind: global typedef
See: document

document.setTitle(title) ⇒ string

Sets the title of the document.

Kind: instance method of document
Returns: string - The HTML DOM string of the title element that was put in the document

| Param | Type | Description | | --- | --- | --- | | title | string | Title to apply to the document. |

document.clearDocument() ⇒ document

Replaces the main document with a new one.

Kind: instance method of document

document.addJs(function, [...arguments]) ⇒ Element

Add a JavaScript snippet to the rendered document. The snippets will only be ran at client. The function must be anonymous where the arguments are the arguments provided in this call. Objects will be JSON stringified while all other argumnets will be stringified with their .toString() method.

Kind: instance method of document

| Param | Type | | --- | --- | | function | function | | [...arguments] | any |

Example (Log "Hello World" to the console)

document.addJs(() => console.log("Hello World"));

Example (Pass local server-side variables)

const num = 5;
document.addJs(n => console.log(n), num);

document.addCss(styles) ⇒ document

Add a CSS snippet to the rendered document. If styles is a string, it will be added to the stylesheet as it is If styles is an object, it will be handled as if every key is a selector with the value as an object where every key is a property with the value as a value.

Kind: instance method of document

| Param | Type | | --- | --- | | styles | object | string |

Example (Usage with string)

element.addCss(`
 h1 {
  font-size: 2em;
  border-radius: 5px;
 }
`);
 

Example (Usage with object)

element.addCss({
 "h1": {
  "font-size": "2em",
  "border-radius": "5px"
 }
});

document.renderJs([minify]) ⇒ string | Promise.<string>

Renders all JavaScript added to the document.

Kind: instance method of document
Returns: string | Promise.<string> - the JS code. Returns a {Promise} if minify is true

| Param | Type | Default | Description | | --- | --- | --- | --- | | [minify] | bool | false | If the code should be minified |

document.renderCss([minify]) ⇒ string

Renders all CSS added to the document.

Kind: instance method of document
Returns: string - the CSS code

| Param | Type | Default | Description | | --- | --- | --- | --- | | [minify] | bool | false | If the code should be minified |

document.render() ⇒ string

Applies all styles and scripts and returns the HTML string of the document.

Kind: instance method of document
Returns: string - the HTML page

element : external:element

The element class from jsdom.

Kind: global typedef
See

element.addClass(...classList) ⇒ Element

Identical to Element.classList.add but returns the {Element}

Kind: instance method of element
See: Element.classList.add

| Param | Type | Description | | --- | --- | --- | | ...classList | string | Class to apply to element. |

element.setClass(...classList) ⇒ Element

Adds one or more classes to the element after removing all previous classes.

Kind: instance method of element

| Param | Type | Description | | --- | --- | --- | | ...classList | string | Class to apply to element. |

element.removeClass(...classList) ⇒ Element

Identical to Element.classList.remove but returns the {Element}

Kind: instance method of element
See: Element.classList.remove

| Param | Type | Description | | --- | --- | --- | | ...classList | string | Class to remove from element. |

element.setHTML(html) ⇒ Element

Identical to Element.innerHTML = html but returns the {Element}

Kind: instance method of element
See: Element.innerHTML = html

| Param | Type | Description | | --- | --- | --- | | html | string | HTML markup to set as the innerHTML of the element |

element.addAttribute(name, [value]) ⇒ Element

Identical to Element.setAttribute but returns the {Element}

Kind: instance method of element
See: Element.setAttribute

| Param | Type | Default | | --- | --- | --- | | name | string | | | [value] | string | "&quot;&quot;" |

element.setId(id) ⇒ Element

Identical to Element.id = id but returns the {Element}

Kind: instance method of element
See: Element.id = id

| Param | Type | | --- | --- | | id | string |

element.setSrc(src) ⇒ Element

Identical to Element.src = src but returns the {Element} and also more reliable

Kind: instance method of element
See: Element.src = src

| Param | Type | | --- | --- | | src | string |

element.setType(type) ⇒ Element

Identical to Element.type = type but returns the {Element} and also more reliable

Kind: instance method of element
See: Element.type = type

| Param | Type | | --- | --- | | type | string |

element.setValue(value) ⇒ Element

Identical to Element.value = value but returns the {Element} and also more reliable

Kind: instance method of element
See: Element.value = value

| Param | Type | | --- | --- | | value | string |

element.Append(...elements) ⇒ Element

Identical to Element.append but returns the {Element}

Kind: instance method of element
See: Element.append

| Param | Type | | --- | --- | | ...elements | Element |

element.Prepend(...elements) ⇒ Element

Identical to Element.prepend but returns the {Element}

Kind: instance method of element
See: Element.prepend

| Param | Type | | --- | --- | | ...elements | Element |

element.addJs(function, [...arguments]) ⇒ Element

Add a JavaScript snippet to the rendered document. The snippets will only be ran at client. The function must be anonymous where the first argument is the element and the rest is the arguments provided in this call. Objects will be JSON stringified while all other argumnets will be stringified with their .toString() method.

Kind: instance method of element

| Param | Type | | --- | --- | | function | function | | [...arguments] | any |

Example (Log the elements inner text to the console)

element.addJs((el) => console.log(el.innerText));

Example (Pass local server-side variables)

const num = 5;
element.addJs((el, n) => el.innerHTML = n, num);

element.addCss(styles) ⇒ Element

Add a CSS snippet to the rendered document. If styles is a string, it will be put inside of a declaration block selecting the element If styles is an object, it will be handled as if every key is a property with the value as a value.

Kind: instance method of element

| Param | Type | | --- | --- | | styles | object | string |

Example (Usage with string)

element.addCss(`
 font-size: 2em;
 border-radius: 5px;
`);
 

Example (Usage with object)

element.addCss({
 "font-size": "2em",
 "border-radius": "5px"
});