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

@meteora-digital/filters

v3.0.2

Published

This will act as our filtering engine. We will pass in filters, Then call apply(). An xhr request will be sent in the form of URL parameters, the response will be accessed via the on('success', (response) => {}) method.

Downloads

92

Readme

Filters

A class to make URL Paramter XHR Requests super easy

Note: version 2.0.0 includes breaking changes since the previous version 1.0.0

Note: version 1.0.0 includes breaking changes since the previous beta version 0.1.1

Installation

npm i @meteora-digital/filters
yarn add @meteora-digital/filters

Usage

<select name="colours" id="colours">
    <option value="red">red</option>
    <option value="blue">blue</option>
    <option value="green">green</option>
    <option value="purple">purple</option>
    <option value="yellow">yellow</option>
</select>
import FiltersController from '@meteora-digital/filters';

const Filter = new FiltersController('/my/endpoint');
const select = document.querySelector('select');

Filter.on('success', (response) => {
  // do something with the response
})

select.addEventListener('change', () => {
  Filter.set(select.name, select.value);
  Filter.apply();
});

Arguments

| Argument | Type | Description | |--------|------|-------------| | api | string | This is the URL that will be used in the ajax call |

Methods

First argument should either be an object or a string. The second argument will only be used if the first argument is a string. The second argument can either be a string or an array of strings.

set()

This will remove any current values in this parameter and set it to a specific value in the value object.

Filter.set({
  colour: ['purple', 'red', 'blue'],
});

Filter.set('colour', ['purple', 'red', 'blue']);

add()

Add more values to the filters object

Filter.add({
  colour: 'green',
});

Filter.add('colour', 'green');

remove()

Remove data from the filters object

Filter.remove({
  colour: 'red',
});

Filter.remove('colour', 'red');

clear()

Remove all data from the filters object

Filter.clear();

apply()

Make the XHR Request to load new content

Filter.apply();

updateURL()

Replace the history state and update the URL to a string

Filter.updateURL(Filter.api.segmentURL);

Events

Each method has it's own event that is fired when the method is called. These can be accessed using the on() method

on()

Filter.on('success', (response) => {
  // do something with the response
});

Filter.on('change', (value) => {
  // do something when the filters changes
});

License

MIT