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

vquery

v5.0.1

Published

A simple, light-weight, vanilla JS wrapper for jQuery-like syntax.

Downloads

29

Readme

vQuery is a simple, light-weight, vanilla JS wrapper for jQuery-like syntax.

Install Using NPM

npm install --save vquery
import v from 'vquery'

v(selector, element, or string).method(props);

Install Using The Browser

Download it from the repository, or you can use a CDN.

<script src="v.min.js"></script>

API

The methods below work like they do with jQuery, except they are just wrappers around document.querySelectorAll, and the associated vanilla JS dom manipulation functions.

Like jQuery and many other similar libraries, most of the methods can be chained.

Below are a few methods available. For the complete API documentation, visit the vQuery website.

Node retrieval

  • .nodes (Alias: .ns)
v('.class-thing').nodes
->  [
    <div class="class-thing">One</div>, 
    <div class="class-thing">Two</div>, 
    <div class="class-thing"><span id="three">Three</span></div>
    ]
  • .node (Alias: .n)
v('.class-thing').node;
-> <div class="class-thing">One</div>
  • .nonElement (Alias: .ne)
v('This string is not an element').nonElement;
-> "This string is not an element"
  • .get(index)
v('.class-thing').get(1).n;
-> <div class="class-thing">Two</div>
  • .find(CSS selector|Element)
v('.class-thing').get(2).find('#three').node
-> <span id="three">Three</span>
  • .length
v('.class-thing').length
-> 2
  • .click(function)
v('body > div.pre-render').click(myCleverClickEvent);
  • .children(CSS selector)

  • Returns an array of child nodes, or filters child nodes if a CSS selector parameter is passed to it.

  • .allChildren(CSS selector)

  • Like .children(), it returns an array of child nodes, but instead of returning just the first level of children, it deeply recurses every child node and returns an array of every element under the selected node at all levels of children.

  • .attr(object|string|Key, Value)

  • Pass an object of camel cased attribute keys, or a key/value pair of strings to set attribute(s). Calling the method without a parameter will return an object of the selected element's attributes.

  • .css(object)

  • Pass an object of camel cased style keys, or pass no parameter to return the computed style of the selected element.

  • .ajax(POST|GET, URL, options.data|options.chain)

    • AJAX request method returning a Promise. Set options.chain to true to pass the data through vQuery's context.
v().ajax('GET', 'https://myawesome.net/api/request/').then((data)=>{
  // Do something with the data.
}).catch((err)=>{
  // Do something with the error.
});
v().ajax('GET', 'https://myawesome.net/api/request/', {chain: true}).then((data)=>{
  console.log(data.nodes);
-> {...}
  console.log(data.type());
-> 'object'
}).catch((err)=>{
  // Do something with the error.
});
  • .mixin(object)
    • This method allows you to pass vQuery's returned result to another library. The mixin should be at the end of the method chain.
    • Example using Lodash:
v([]).mixin({_:_}).isArray();
-> true
  • Example using jQuery:
v(':header').mixin({$:$})
-> [<h3 id=​"install-using-npm">​Install Using NPM​</h3>​, <h3 id=​"install-using-the-browser">​Install Using The Browser​</h3>​, <h3 id=​"experiment-with-vquery-now">​Experiment with vQuery Now​</h3>​, <h3 id=​"breaking-changes-in-4-3-0">​Breaking changes in 4.3.0​</h3>​,...]