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

rigel-tools

v1.1.9

Published

**Rigel** is a JavaScript library for transforming data tables by table declaration. It provides a concise, declarative table language to support a range of data transformation tasks.

Downloads

36

Readme

Rigel.js

Rigel is a JavaScript library for transforming data tables by table declaration. It provides a concise, declarative table language to support a range of data transformation tasks.

Install

npm install rigel-tools

Usage

Demo

To try demo, use npm run test.

Basic usage

import * as rigel from "rigel-tools";
let spec = {
  data: [
    {
      name: "crime",
      values: [
        { state: "Alabama", year: 2004, crime: 4029.3 },
        { state: "Alabama", year: 2005, crime: 3900 },
        { state: "Alaska", crime: 3370.9, year: 2004 },
        { state: "Alaska", crime: 3615, year: 2005 },
      ],
    }
  ],
  target_table: [
    "(crime.state), (crime.year) => (crime.crime)",
  ],
};
var result = rigel.transform(spec);
console.log(rigel.prettyPrint(result)); // shape the result in readable form

//Output
[
  [
    [ null, 2004, 2005 ],
    [ 'Alabama', 4029.3, 3900 ],
    [ 'Alaska', 3370.9, 3615 ]
  ]
]

API

transform(spec: object)

Function

Transform the input raw tables into given forms according to specifications in the argument.

Argument

A valid argument of transform is an object containing keys including data and target_table, indicating the raw tables and specifications of target tables respectively. Details of the values corresponding to these keys are provided as follows.

data

A valid value for data field is an array consisting of objects representing raw tables. Each object should have a name field representing the table name and a values field representing the table contents.

target_table

A valid value for target_table field is a string indicating the specifications of target tables. The pattern of a specification is (row), (column) => (cell), where row, column and cell are expressions containing attribute(s) that will be mapped to the row, column and cell part of the target table. For example, when attribute state is mapped to row, year is mapped to column and crime is mapped to cell, the specification can be written as (state), (year) => (crime).

Output

The output of transform is a 3-dimensional array. Specifically, the output of transform is an array consisting of target tables, with each target table an 2-dimensional array. The element can be null if the corresponding cell is empty or an object representing the contents of the corresponding cell. The object has a value field indicating the real value in the corresponding cell and a source field indicating the source attribute that the real value originally belongs to.

prettyPrint(target: object)

Function

Print the output of transform in readable form.

Argument

An object with the same form as the output of transform.