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 🙏

© 2026 – Pkg Stats / Ryan Hefner

itemsorter

v0.1.9

Published

Components to display and filter objects

Readme

Itemsorter

React component to display and filter object arrays

Usage

Install it by running npm install itemsorterr --save. Then to use it:

import { ItemSorter } from 'itemsorter';

Examples

Simple display

Given an object like so:

const mockPlants = [
    { species: "Fiddle Leaf Fig", height: 150, indoor: true, price: 49.99, careLevel: "Moderate" },
    { species: "Snake Plant", height: 80, indoor: true, price: 24.99, careLevel: "Low" },
    { species: "Monstera", height: 120, indoor: true, price: 59.99, careLevel: "Easy" },
    { species: "Peace Lily", height: 90, indoor: true, price: 29.99, careLevel: "Moderate" },
    { species: "Spider Plant", height: 40, indoor: true, price: 14.99, careLevel: "Low" },
    { species: "Aloe Vera", height: 50, indoor: true, price: 19.99, careLevel: "Easy" },
    { species: "Cactus", height: 30, indoor: false, price: 12.99, careLevel: "Low" },
    { species: "Bamboo Palm", height: 180, indoor: true, price: 69.99, careLevel: "Moderate" },
    { species: "Rubber Plant", height: 160, indoor: true, price: 39.99, careLevel: "Moderate" },
    { species: "ZZ Plant", height: 100, indoor: true, price: 34.99, careLevel: "Low" },
    { species: "Golden Pothos", height: 60, indoor: true, price: 15.99, careLevel: "Easy" }
];

The most simple usage is:

<ItemSorter items={mockPlants}/>

Which would load the component with default behavior and css like so:

Default example

Optional Parameters

The component offers a variety of optional parameters:

rangeFields

An array of strings which must be the keys of numerical values, like so:

rangeFields={["price", "height"]}

Makes it so rather than toggles, the filter displays a range selector, like so:

rangeField example

orderFields

An object of key:function pairs that can order the fields of the objects, like so:

  const orderFunction = (a:string, b:string) =>{
    const sizeOrder = ["XS", "S", "M", "L", "XL"];
    if(sizeOrder.indexOf(a) < sizeOrder.indexOf(b)){
      return -1;
    }else if (sizeOrder.indexOf(b) < sizeOrder.indexOf(a)){
      return 1;
    }else{
      return 0;
    }
  }
orderFields={{"size" : orderFunction}}

The values will be sorted in the filter like so:

sorted properties

explicitFields

An array of strings, referring to different attributes of the object

explicitFields = {["size", "price", "brand", "imgUrl"]}

The fields not in the array will be ignored for both the grid and the filter

imageUrl

A string which ought to be a url field in the object, to be shown at the top of the cards in the grid:

imageUrl = "imgUrl"

Will proceed to display as so:

cards with images

textSearch

Boolean, will enable a search field at the top of the filter that triggers on every property of each object:

textSearch = {true}

parseOutput

An object of key:function pairs that will parse every entry of the key name through the function associated for example:

const addEuro = (price:number) =>{
    return price + "€";
}

parseOutput = {{"price" : addEuro}}

Would add a € after the content of every "price" field

cardFunction

A function to be fired on click evvent forr cards in the grid. Takes as argument the item itself:

const cardFunction = (item : any) => {
    console.log(item);
}
cardFunction = {cardFunction}

Would log the contents of the item in the console.

Styling

The component exposes a variety of CSS classes to the developer, which can be easily overriden:

sidebarClassName="sorter-custom-sidebar"
containerClassName="sorter-custom-container"
sectionClassName="sorter-custom-section"
inputClassName="sorter-custom-input"
gridClassName="sorter-custom-grid"
cardClassName="sorter-custom-card"
datapointClassName="sorter-custom-datapoint"
checkboxClassName="sorter-custom-checkbox"
gridThumbnailClassName="sorter-custom-grid-thumbnail"

The presence of any of these will assign that class to the node and override the default css styling for it.