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

javascript-data-set

v1.0.7

Published

powerfull recordset class, supporting sorting, filtering, subsets, loading data from json, array and html markup

Downloads

33

Readme

Data-set

A powerfull dataset class

Features:

  • load data from array, json or html markup
  • sort per multiple columns
  • complex filters (text, numerical and RegExp)
  • define your own filters
  • filter per multiple columns
  • pagination
  • framework agnostic (except for the html markup loader that uses jQuery)
  • Unit Tested

data-set has 3 main components, the core, the filters and the data loaders. Filters and data loaders are optional and don't need to be included

Getting Started

  1. npm install javascript-data-set or download the latest version

  2. include either dist/data-set-complete.min.js

  3. use it ...

Example Usage

Take a look at our jsfiddle page and play with it

Data Loader

The data loader is actually a factory that will return a properly configured and populated dataset

Json

The json loader can load data from a Json object or string. I will configure the dataset columns based on the object properties The Json should contain an array of objects

var dataset, data;
data = [ { col1: 1, col2: 2 }, { col1: 3, col2: 4 } ];
dataset = new Francodacosta.DataSet.Loader.Json(JSON.stringify(data)).load();

Array

The json loader can load data from an array. Optionally you can specify if the first row contains column information The array array should contain one array per row,

var d, data, firstRowHeaders;
data = [['col1', 'col2'], [1, 2], [3, 4]];
dataset = new Francodacosta.DataSet.Loader.Array(data, firstRowHeaders = true).load();
// in this case the first row (['col1', 'col2']) will be discarded and used as column names

Markup

This will load data from an HTML table

    <table>
        <thead>
            <tr>
                <!-- it data-name attribute is present, then it will be used for the column name -->
                <th data-name="col1">Column 1</th>
                <th>Col1</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>1</td>
                <td>2</td>
            </tr>
            <tr>
                <td>3</td>
                <td>4</td>
            </tr>
        </tbody>
    </table>

You can load data from this table in the following way

// Please note that this loader requires jQuery
dataset = new window.Francodacosta.DataSet.Loader.Markup('table').load();

Sorting

You can sort by any column and you can specify multiple columns

// sort colum 1 ascending and then by column 2 descending
dataset.setSorting('column 1');
dataset.setSorting('column 2', 'DESC');

// remove all sorting specifications
dataset.clearSorting();

data = dataset.getData()

Filters

A filter is just a function that accepts two arguments, the value and the searchTerm and returns true if a match is found

The filter is executed for each row

For your convenience a set of standard filters are included

Text Filter

window.Francodacosta.DataSet.Filter.Text.

  • match() returns true if there is an exact match
  • beginsWith() returns true if the value starts with searchTerm
  • endsWith() returns true if the value ends with searchTerm
  • contains returns true if the value contains searchTerm
  • regularExpression if you need more flexibility you can write your own regular expression
Number Filter

window.Francodacosta.DataSet.Filter.Number.

  • equal()
  • notEqual()
  • greaterThan()
  • greaterThanOrEqualTo()
  • lessThan()
  • lessThanOrEqualTo()

You can add more than one filter, in this case an and search will be performed