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

vexdb

v3.1.1

Published

A simple tool for accessing the VexDB

Downloads

41

Readme

VexDB

Build Status codecov npm

vexdb is a wrapper for VexDB.

Features

Installation

Install this package with yarn:

yarn add vexdb

or, if you want to use npm:

npm i vexdb

API Primer

GET

Retrieves data from an endpoint with the specified parameters. These parameters can include any that can be specified to VexDB, as well as final values in the response object.

Normally, vexdb limits responses to 5000 items per request. vexdb will make enough requests to ensure that all applicable matches are returned

// Get all events in StarStruck
var vexdb = require("vexdb");
vexdb.get("events", { season: "StarStruck" }).then(console.log);

// Get all teams from California
vexdb
  .get("teams", {
    region: "California",
  })
  .then(console.log);

Size

This works basically identically to .get(), but returns the number of items that fit this result.

// Get the number of all teams in California
vexdb.size("teams", { region: "California" }).then(console.log);

// All examples from .get() above would work here...

Depending on the parameters specified, size() may or may not send nodata requests. In order to minimize bandwidth, you'll want to only include parameters that can be passed directly to VexDB

Defaults

In many cases, you'll want to share headers and parameters across requests. This can be done using vexdb.constants.header and vexdb.constants.param, respectively:

vexdb.constants.param({
  region: "California",
});

vexdb.constants.header({
  "User-Agent": "<custom user agent string>",
});

Warning: Because of the Cross Origin Policy, setting headers using vexdb.constants.header may cause the browser to automatically block requests to https://api.vexdb.io. It is not reccomended to use headers in the browser.

Caching

Since VexDB only updates every 4 minutes, this module will prevent repeat requests by resolving them with the previous value immediately. You can control this behavior with vexdb.cache

Note: vexdb uses my own keya module to handle cache. In Node, caching will take place using sqlite, while in the browser, caches will be stored first in IndexedDB

Update the Time To Live for new caches

vexdb.cache.setTTL(60 * 1000);

See if a cache is present

vexdb.cache
  .has("teams", {
    region: "South Carolina",
  })
  .then(console.log); // Boolean

Directly resolve a cached value

vexdb.cache.resolve("skills", { region: "Utah" }).then(console.log); // The resolved value, or undefined if the cache isn't present

Clear the cache

vexdb.cache.clear().then(() => console.log("Cache has been cleared"));

Live

This module also supports basic live features. Specify an endpoint and parameters (passed through to get()) and recieve updates on new items that fit that criteria

vexdb
  .live("matches", {
    scored: 1,
    sku: "RE-VRC-17-3805",
  })
  .on("item", console.log);

Note that the item event will trigger for every result on the inital poll. This means that every item that fits the parameters will be passed to item. If you do not want this to be the case, specify prefetch: true in your listed parameters

// Only new matches will trigger item
vexdb
  .live("matches", {
    scored: 1,
    sku: "RE-VRC-17-3805",
    prefetch: true,
  })
  .on("item", console.log);

Events

fetch

  • newItems Object[]

Emitted on a successful fetch

prefetch

  • results Object[]

Emitted when a prefetch has been completed

item

  • item Object

Emitted for each new item

close

Emitted for each new item


API

close(): undefined Stop new polls

params(newParams: Object): Object Override request parameters for future requests. Note: this does not change the current index of results

current(): Object[] Returns the current cache of results