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

seleto

v1.2.1

Published

HTML DOM selector and manipulator.

Downloads

24

Readme

Seleto

Seleto is a lightning-fast, lightweight DOM selector; and it is highly extensible.

##Why Seleto? One may be tempted to ask 'why seleto?' when we have the likes of jQuery, Qwery and zepto. The answer is as simple as seleto itself; I wanted a DOM selector that has the selection capabilities of the mentioned libraries but does not come with all the pletora of unwanted utilities that fused into them that we must ship with our works whether they are wanted or not. Ok, with that out of the way, let us see what seleto can do.

Well, if you have ever used(is there anyone who hasn't?) jQuery, using seleto will come natural. While seleto works like jQuery, do not expect everything that works on jQuery to work in seleto. I mean, while would anyone wants to make another jQuery?

Installation

  npm install seleto

Test

    npm test

List of seleto's supported selectors

The following are the selectors/operations supported by seleto:

  • Id: $('#Id')

  • Class: $('.class')

  • Element: $('p')

  • Attribute:$('[type]')

  • Pseudos: $(':radio'), others are :<type> where <type> could be checkbox, text etc. or 'checked' for radios and checkboxes.

  • Pseudo_Pseudo: $('checkbox:checked')

  • Attribute_Pseudo: $('[data-validations]:text')

  • Attribute_Value: $('[type=text]')

  • Class_Class: $('.tabular.row')

  • Element_Attribute: $('img[source-path]')

  • Element_Pseudo: $('input:text')

  • Element_Class: $('div.wrapper')

  • Id_Class: $('#content.main')

  • Pseudo_Attribute: $(':text[data-validations]')

  • Pseudo_Attribute_Value: $(':text[name=userid]')

  • Element_Attribute_Pseudo: $('input[data-validations]:text')

  • Element_Attribute_Value: $('input[name=institution]')

  • Attribute_Value_Pseudo: $('[type=checkbox]:checked')

  • Element_Pseudo_Pseudo: $('input:checkbox:checked')

  • Element_Attribute_Value_Pseudo: $('input[type=radio]:checked')

  • Attribute_Value_Attribute_Value: $('[type=text][name=username]')

  • Element_Attribute_Value_Attribute_Value: $('input[type=text][name=username]')

Any of the above could be used in various forms such as with comma (,) for combined selection such as $('selector, selector, selector,...') or space for subsets such as $('selector selector, selector selector selector,..., ...') where selector is any of the listed supported selectors. For instance, see:

var selected = $('form.testform, div.content, span em a.myanchor');
var anotherOne = $('form.testform input:text, form.testform input:checkbox, form.testform select[name=city] option[value=Lagos]'); 
/*Of course I'm being unnecessarily verbose here*/

List of seleto's interfaces that work similar to equivalent in jQuery

  • find
  • filter
  • each
  • not
  • is
  • append
  • prepend
  • appendTo
  • before
  • after
  • clone
  • empty
  • html
  • val
  • attr
  • addClass
  • removeClass
  • remove
  • children
  • wrap
  • wrapAll
  • text
  • size
  • css
  • data
  • hasClass
  • toggleClass

The following are interfaces peculiar to seleto

  • el: It returns the raw HTML Element at the passed index or null otherwise. This is not zero-based. So, to get the first element in a list liList of li we can use liList.el(1) where liList is a seleto instance. The equivalent in jQuery is liList.get(0) since it is zero-based in jQuery.

  • nth: nth returns the matched element at the nth position in a collection of matches as an instance of seleto. This is also non-zero based so using the ealier example, liList.nth(1) returns the first matched element as seleto instance.

  • prop: prop allows the setting/getting of element properties such as the checked properties of checkbox and radio or the selected property of the select element.

  • even: even returns the matches of elements whose position in the matched collection is even as seleto instance.

  • odd: odd returns the matches of elements whose position in the matched collection is odd as seleto instance.

  • first: first returns the element on the head of the matched collection as seleto instance.

  • last: first returns the element at the bottom of the matched collection as seleto instance.

Events in seleto

All like in jQuery

  • on: Used to subscribe to events, for instance, button.on('event', callback); or delegated form.on('event','button.submit',callback); event could be any of click, change, keyup, keydown, keypress etc.

  • off: Used to unsubscribe to events, for instance, button.off('event', callback); or button.off(); - this removes all events on button.

  • trigger: trigger helps us manually trigger/fire events on elements, for instance, we can trigger the click event on button like so: button.trigger('click').

There are also shortcuts like button.click(callback), el.change(callback) and can be triggered like so: button.click(), el.change().

Thanks for now.