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

flextablejs

v0.3.0

Published

FlexTable (flextablejs) is a JavaScript library that provides a class with a simple API to work with tables (headers, rows, columns, sort, format) facilitating the analysis and data manipulation.

Downloads

3

Readme

FlexTable (flextablejs)

JavaScript License Coverage Tests

FlexTable (flextablejs) is a JavaScript library that provides a class with a simple API to work with tables (headers, rows, columns, sort, format) facilitating the analysis and data manipulation.

Online tools: Build Status Coverage Status Ebert Inline Docs

This library is commonly used with CSV Types to parse text files with fields delimited by a character (like CSV). FlexTable is compatible with the data structure produced by CSV Types. Every values-headers definition can be converted to a FlexTable. If the CSV file follow the types specs, multiple tables can be created from a single CSV file.

Gitlab repo    Docs    NPM package

Table of Contents

  1. Description
  2. Installation
  3. Examples
  4. TODO
  5. Test & Coverage
  6. New features
  7. Author
  8. ChangeLog
  9. License

Description

FlexTable (flextablejs) is a JavaScript library that provides a class with a simple API to work with tables (headers, rows, columns, sort, format) facilitating the analysis and data manipulation.

Installation

npm i flextablejs -S

Or from the repo:

npm i "http://github.com/Group4Layers/flextable.git"

It has been tested with node >= 6, but it is widely used in Firefox and Chrome with building tools like webpack.

This library is commonly used with CSV Types to parse text files with fields delimited by a character (like CSV). FlexTable is compatible with the data structure produced by CSV Types. Every values-headers definition can be converted to a FlexTable. If the CSV file follow the types specs, multiple tables can be created from a single CSV file.

Examples

The best way to learn something is to see how it behaves.

Starting from an empty table

const FlexTable = require('flextable').FlexTable;
let table = new FlexTable();

table.setColumn('device type', ['CPU', 'GPU', 'FPGA']);
table.setColumn('speedup', [1, 8.43, 2.3]);

table.appendRow(['Xeon Phi', 3.5]);

// get the indices and set values manually
let idx = table.idx;
// update the Xeon Phi
table.values[3][idx['speedup']] = 3.455;

// change the header name
table.headers[idx['speedup']] = 'S(t)';
delete table.idx; // remove the indices to force update

// convert a column (rounding)
table.setColumn('S(t)', value => Number(value.toFixed(2)))

let results = table.format('markdown');

console.log(results):

| device type | S(t) |
|-------------|------|
| CPU         |    1 |
| GPU         |  8.4 |
| FPGA        |  2.3 |
| Xeon Phi    |  3.5 |

Importing the data from a CSV with headers

#device type,S(t)
CPU,1
GPU,8.43
FPGA,2.3
Xeon Phi,3.455
const CSV = require('csv-types').CSV;
const FlexTable = require('flextable').FlexTable;

let parsed = new CSV().parse(`#device type,S(t)
CPU,1
GPU,8.43
FPGA,2.3
Xeon Phi,3.455
`);

let table = new FlexTable(parsed);

// convert a column (lower case, hyphen)
table.setColumn('device type', value => value.toLowerCase().replace(/ /g, '-'));

let results = table.format('md');

console.log(results):

| device type | S(t) |
|-------------|------|
| CPU         |    1 |
| GPU         |  8.4 |
| FPGA        |  2.3 |
| Xeon Phi    |  3.5 |

Until the README is completed and improved with real examples, we encourage you to read the source code documentation. It has examples of use: Docs.

TODO

  • [ ] Write multiple examples showing the library.
  • [ ] Perform more tests and increase the code coverage.
  • [ ] Improve the documentation of the source code.
  • [ ] Show real use cases.

New features

You can request new features for this library by opening new issues. If we find it useful (or there are at least 2 users interested in a proposal) we can implement it. Also, we accept pull requests with bugfixes or new features.

Test & Coverage

npm test
npm run coverage

Test covered:

  FlexTable
    Rows
      ✓ append rows at the end
      ✓ insert rows at the middle
      ✓ insert rows at the beginning
      ✓ remove rows at the beginning
      ✓ remove rows at the middle
      ✓ remove rows at the end
      ✓ replace rows at the beginning
      ✓ replace rows at the middle
      ✓ replace rows at the end
      ✓ remove rows by a custom function (not true leaves unchanged)
      ✓ remove rows by a custom function (true removes)
      ✓ modify rows by a custom function (null leaves unchanged)
      ✓ modify rows by a custom function (not null modifies the row)
    Columns
      ✓ setHeadersIndex
      ✓ setColumn triggers setHeadersIndex
      ✓ setColumn can remove a column that exists
      ✓ setColumn cannot remove a column that doesn't exist
      ✓ setColumns can remove columns
      ✓ setColumn can replace a column that exists
      ✓ setColumn can add a column that doesn't exist
      ✓ setColumns can replace and add columns
      ✓ setColumn can use a custom function to modify values (cast)
      ✓ setColumn can use a custom function to insert values (based on the row)
    Create
      ✓ create an empty table, append a row and insert a row
      ✓ create an empty table and append rows
      ✓ create an empty table without headers and with rows throws
      ✓ create a table with rows
    Sort
      ✓ can sort rows using mapchains and sorters (<num, skip)
      ✓ can sort rows using mapchains and sorters (>num, skip, <num)
      ✓ can sort rows using mapchains and sorters (custom funcs)
    Format
      ✓ as markdown (default fmt)
      ✓ as markdown (custom fmt)
      ✓ as markdown (by column fmt)
      ✓ as markdown (escaping)
      ✓ as csv (default fmt)
      ✓ as csv (custom fmt)
      ✓ as csv (by column fmt)
      ✓ as csv (escaping)
    clone
      ✓ supports cloning (not shared references)


  39 passing (72ms)

Author

nozalr [email protected] (Group4Layers®).

ChangeLog

GitHub/Gitlab readers (repo, no docs): CHANGELOG.md.

License

ExImageInfo source code is released under the MIT License.

GitHub/Gitlab readers (repo, no docs): LICENSE.md.