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 🙏

© 2025 – Pkg Stats / Ryan Hefner

tiny-olap

v0.2.4

Published

OLAP functionality for use with data visualizations. Aggregating and grouping data along key dimensions.

Downloads

19

Readme

tiny-olap

OLAP functionality for use with data visualizations. Aggregate, filter, and grouping data along key dimensions and measures. This is a light weight olap lib. Probably one of the simplest api's currently available. Inspired by moment and numeral js libraries libraries.

Installation

npm install -s tiny-olap

Getting Started

Given the following sample for the proceeding examples:

  var data = [
	 {"country": "us", "date": "2012-02-03", "gender": "m", "pageviews": 10, "signups": 2, "paid": 3}
	,{"country": "ca", "date": "2012-02-03", "gender": "m", "pageviews": 20, "signups": 1, "paid": 5}
	,{"country": "mx", "date": "2012-02-03", "gender": "m", "pageviews": 6, "signups": 0, "paid": 1}
	,{"country": "mx", "date": "2012-02-03", "gender": "f", "pageviews": 2, "signups": 1, "paid": 0}
	,{"country": "mx", "date": "2012-02-03", "gender": "m", "pageviews": 6, "signups": 0, "paid": 1}
	,{"country": "mx", "date": "2012-02-03", "gender": "m", "pageviews": 6, "signups": 0, "paid": 1}
	,{"country": "mx", "date": "2012-02-03", "gender": "m", "pageviews": 6, "signups": 0, "paid": 1}
  ]

Group and Aggregate


var TinyOlap = require('tiny-olap');
var olap = new TinyOlap(data);

var result = olap.query()
		.group('country')
		.measure({name: 'pageviews', formula: 'pageviews', agg: 'sum'})
		.run();

Group by Multiple Dimensions


var TinyOlap = require('tiny-olap');
var olap = new TinyOlap(data);

var result = olap.query()
		.group(['country', 'gender'])
		.measure({name: 'pageviews', formula: 'pageviews', agg: 'sum'})
		.run();

Measure

Measure objects must be supplied in order for tiny-olap to aggregate a column.

  • name (required) - output column name
  • formula (required) - function|string - Either a function that takes a row object or string pointing to the original column name
  • agg (required) - sum|avg|count|min|max - Aggregation function

Filtering Data

Filter takes an array of 2 dimensional arrays. The first element refers is the data column name and the second is the value to filter on.


var TinyOlap = require('tiny-olap');
var olap = new TinyOlap(data);

var result = olap.query()
		.group(['country', 'gender'])
		.measure({name: 'pageviews', formula: 'pageviews', agg: 'sum'})
		.filter([ ['country', 'us'], ['country', 'mx'] ] )
		.run();

Ordering Data

Ordering accepts an array of columns to order by and optional corresponding array of order directions.


var TinyOlap = require('tiny-olap');
var olap = new TinyOlap(data);

var result = olap.query()
		.group(['country', 'gender'])
		.measure({name: 'pageviews', formula: 'pageviews', agg: 'sum'})
		.filter([ ['country', 'us'], ['country', 'mx'] ] )
		.order(['country', 'gender'], ['asc', 'desc'])
		.run();

Unindexed Data

When each row is an array instead of an object tiny-olap requires a header parameter in order to work properly.

var data = [
	 ["us", "2012-02-03", 10, 2, 3]
	,["ca", "2012-02-03", 20, 1, 5]
	,["mx", "2012-02-03", 6, 0, 1]
	,["us", "2012-02-04", 5, 2, 3]
	,["ca", "2012-02-04", 10, 6, 5]
	,["mx", "2012-02-04", 10, 3, 5]
]

var TinyOlap = require('tiny-olap');

// pass in headers paramenter 
var olap = new TinyOlap(data, ["country", "date", 
		"pageviews", "signups", "paid"]);

// You can use tiny-olap like normal from here.