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

domf

v0.0.3

Published

#### on_ Add eventlistener.

Downloads

3

Readme

Usage

on_

Add eventlistener.

[HTML]

<div id="foo-top" class="foo-class">
  <form name="foo-form">
  <input type="text" name="foo-input-text" value="foo">
  <input type="button" name="foo-input-button" value="this is foo button">
  </form>
</div>

[LiveScript]

query "input[name='foo-input-button']" document
|> on_ \click, -> @value = "button pushed"

[LiveScript] (With no lambda using glad-functions. Equivalent to the below. )

query "input[name='foo-input-button']" document
|> (withl lazy set, \value, "button pushed", _ ) >> (apply on_ \click)

parent

Get parent node (up to 1 hierarchy).

[HTML]

<div id="foo-top-layer">
  ...
  <div id="foo-second-layer">
    ...
    <div id="foo-third-layer">
      ...
    </div>
  </div>
</div>

[LiveScript]

query \#foo-third-layer document
|> parent #=> elem(#foo-second-layer)

parents

Get parent nodes (up to the "document" as root, over "html" element.)

[HTML]

<div id="foo-top-layer">
  ...
  <div id="foo-second-layer">
    ...
    <div id="foo-third-layer">
      ...
    </div>
  </div>
</div>

[LiveScript]

query \#foo-third-layer document
|> parents #=> [elem(#foo-second-layer), elem(#foo-top-layer), ... document]

children

Get child nodes.

[HTML]

<div id="foo-top" class="foo-class">
  <div id="foo-second" class="foo-class-second">
  foo-second-content
  </div>
  <div id="foo-second-next" class="foo-class-second foo-class-sub">
  foo-second-next-content
  </div>
</div>

[LiveScript]

query \#foo-top document
|> children #=> [elem(#foo-second), elem(#foo-second-next), ...]

classes

Get classes of the element.

[HTML]

<div id="foo-top" class="foo-class">
  <div id="foo-second" class="foo-class-second">
  foo-second-content
  </div>
  <div id="foo-second-next" class="foo-class-second foo-class-sub">
  foo-second-next-content
  </div>
</div>

[LiveScript]

query \#foo-second-next document
|> classes #=> [class(foo-class-second),class(foo-class-sub)]

has_class

Detect if element has the class,or not.

[HTML]

<div id="foo-top" class="foo-class">
  ...
</div>

[LiveScript]

query \#foo-top document
|> has_class \foo-class #=> true

query \#foo-top document
|> has_class \foo-class-not #=> false

add_class

Add class value to the element.

[HTML]

<div id="foo-top" class="foo-class">
  ...
</div>

[LiveScript]

query \#foo-top document
|> add_class \bar-class

remove_class

Remove class value from the element.

[HTML]

<div id="foo-top" class="foo-class">
  ...
</div>

[LiveScript]

query \#foo-top document
|> remove_class \foo-class

query

Get the first element on which matches the selector.

[HTML]

<div id="foo-top" class="foo-class">
  ...
</div>

[LiveScript]

query \#foo-top document #=> elem(#foo-top)

query_all

Get all of elements on which matches the selector.

[HTML]

<div id="foo-top" class="foo-class">
  <div id="foo-second" class="foo-class-second">
  foo-second-content
  </div>
  <div id="foo-second-next" class="foo-class-second foo-class-sub">
  foo-second-next-content
  </div>
</div>

[LiveScript]

query_all \.foo-class-second  document
#=> [elem(#foo-second), elem(#foo-second-next)]

create

Create the HTML element.

[LiveScript]

element = create \div document

[HTML]

<div id="foo-top" class="foo-class">
  <div id="foo-second" class="foo-class-second">
  foo-second-content
  </div>
</div>

[LiveScript]

create \div
|> append_to (query \#foo-top document)

#<div id="foo-top" class="foo-class">
#  <div id="foo-second" class="foo-class-second">
#  foo-second-content
#  </div>
#  <div></div>
#</div>

attr

Get the attribute value.

[HTML]

<div id="foo-top" class="foo-class">
  ...
</div>

[LiveScript]

query \#foo-top document
|> attr \class #=> foo-class

set_attr

Set value to the attribute.

[HTML]

<div id="foo-top" class="foo-class">
  ...
</div>

[LiveScript]

query \#foo-top document
|> set_attr \rel \rel-var

#<div id="foo-top" class="foo-class" rel="rel-var">
#  ...
#</div>

style

Get style value.

[HTML]

<h1 style="color:#000;">
...
</h1>

[LiveScript]

query \h1 document
|> style #=> color:#000;

set_style

Set style value.

[HTML]

<h1 style="color:#000;">
...
</h1>

[LiveScript]

query \h1 document
|> set_style \text-decoration \underline
#=>
#<h1 style="color:#000;text-decoration:underline; ">
#...
#</h1>

append_to

Add the element into the other element.

[HTML]

<div id="foo-top" class="foo-class">
  <div id="foo-second" class="foo-class-second">
  foo-second-content
  </div>
</div>

[LiveScript]

create \div
|> append_to (query \#foo-top document)

#<div id="foo-top" class="foo-class">
#  <div id="foo-second" class="foo-class-second">
#  foo-second-content
#  </div>
#  <div></div>
#</div>

append

Add the other element in the element itself.

[HTML]

<div id="foo-top" class="foo-top">
  <div id="foo-second" class="foo-class-second">
  foo-second-content
  </div>
</div>

[LiveScript]

query \#foo-class document
|> append (create \p document)

#<div id="foo-top" class="foo-class">
#  <div id="foo-second" class="foo-class-second">
#  foo-second-content
#  </div>
#  <p></p>
#</div>

select

Give all text in the text box selected.

[HTML]

<div id="foo-top-text">
  <form name="foo-form">
  <input type="text" name="foo-input-text" value="foo">
  <input type="button" name="foo-input-button" value="this is foo button">
  </form>
</div>

[LiveScript]

query "input[name='foo-input-text']" document
|> select

#The text "foo" that is in the text box "foo-input-text", goes to be selected

focus

Give focus to the element.

[HTML]

<div id="foo-top-text">
  <form name="foo-form">
  <input type="text" name="foo-input-text" value="foo">
  <input type="button" name="foo-input-button" value="this is foo button">
  </form>
</div>

[LiveScript]

query "input[name='foo-input-text']" document
|> focus

blur

Remove focus from the element.

[HTML]

<div id="foo-top-text">
  <form name="foo-form">
  <input type="text" name="foo-input-text" value="foo">
  <input type="button" name="foo-input-button" value="this is foo button">
  </form>
</div>

[LiveScript]

query "input[name='foo-input-text']" document
|> blur

text

Get the text content of the element.

[HTML]

<div id="foo-top" class="foo-class">
  <div id="foo-second" class="foo-class-second">
  foo-second-content
  </div>
  <div id="foo-second-next" class="foo-class-second foo-class-sub">
  foo-second-next-content
  </div>
</div>

[LiveScript]

query \#foo-second document
|> text #=> foo-second-content

set_text

Set the text content into the element.

[HTML]

<div id="foo-top" class="foo-class">
  <div id="foo-second" class="foo-class-second">
  foo-second-content
  </div>
</div>

[LiveScript]

query \#foo-second document
|> set_text "This text is added by bar"

#<div id="foo-top" class="foo-class">
#  <div id="foo-second" class="foo-class-second">
#  This text is added by bar
#  </div>
#</div>

html

Get the HTML content of the element( not includes the element itself.)

[HTML]

<div id="foo-top" class="foo-class">
  <div id="foo-second" class="foo-class-second">
  foo-second-content
  </div>
</div>

[LiveScript]

query \#foo-top document
|> html #=> <div id="foo-second" class="foo-class-second">
        #  foo-second-content
        #  </div>

set_html

Set the HTML content into the element.

[HTML]

<div id="foo-top" class="foo-class">
  <div id="foo-second" class="foo-class-second">
  foo-second-content
  </div>
</div>

[LiveScript]

query \#foo-top document
|> set_html "<p>this is a paragraph</p>"

#<div id="foo-top" class="foo-class">
#  <p>this is a paragraph</p>
#</div>

outer_html

Get the HTML content of the element( includes the element itself.)

[HTML]

<div id="foo-top" class="foo-class">
  <div id="foo-second" class="foo-class-second">
  foo-second-content
  </div>
</div>

[LiveScript]

query \#foo-top document
|> outer_html #=> <div id="foo-top" class="foo-class">
                #  <div id="foo-second" class="foo-class-second">
                #  foo-second-content
                #  </div>
                #</div>

set_outer_html

Replace the HTML content of the element( includes the element itself.)

[HTML]

<div id="foo-top" class="foo-class">
  <div id="foo-second" class="foo-class-second">
  foo-second-content
  </div>
</div>

[LiveScript]

query \#foo-top document
|> set_outer_html "<div id="foo">this is the content of the element</div>"

#<div id="foo">this is the content of the element</div>