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

protobuf-table

v1.2.3

Published

A dynamic protobuf implementation for structured table data

Downloads

4

Readme

protobuf-table

A dynamic protobuf implementation for structured table data

software by mappazzo

Basic tests and compression protocol tested and working. Detailed documentation under development... Stay tuned

Purpose

License

This software is 'Beerware'

"THE BEER-WARE LICENSE" (Revision 42): Mappazzo wrote this file. As long as you retain this notice you can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. Cheers, Kelly Norris

Basic Usage

Structure your table data as object with an array of headers 'header' and an array of 'data'. Each 'data' entry array can be an object with keys corresponding to each name in the header or an array. You can also include metadata information in a 'meta' object.

Example 'Table' structure (with data as an Array):

var table = {
  meta: {
    filename: 'exampleTable',
    owner: 'mappazzo',
    link: 'www.mappazzo.com',
    comment: 'basic table example'
  },
  header: [
    { name: 'location', type: 'string' },
    { name: 'total', type: 'uint' },
    { name: 'latitude', type: 'float' },
    { name: 'longitude', type: 'float' },
    { name: 'reading', type: 'int' }
  ],
  data: [
    ['east street', 34324, -42.559355, 172.60347, -889],
    ['work', 7344, -41.546799, 172.50742, 4],
    ['big tree', 9327924, -41.79346, 173.04213, 32]
  ]
}

You can encode this data as follows:

pbTable.encodeTable(table, function (err, buffer) {
    if(err) return console.log(err)
    console.log('success, buffer is:' + buffer.length + 'bytes')
})

or..  pbTable.encode((table, function (err, buffer) { } )

And decode the resulting buffer as follows:

pbTable.decodeTable(buffer, function (err, table) {
    if(err) return console.log(err)
    console.log('success, restored data:', table)
})

or...  pbTable.decode((table, function (err, buffer) { } )

Each 'row' of data can also be a verbose object

data: [
  { location: 'east street', total: 34324, latitude: -42.559355, .... },
  { location: 'work', .... },
  ...
]

If data is stored as verbose objects then we use:

pbTable.encodeVerbose(buffer, callback (err, buffer) { } )

and...   pbTable.decodeVerbose(buffer, callback (err, buffer) { } )

We can also add additional data to an existing buffer

pbTable.add(buffer, data, callback (err, buffer) { } )
...
pbTable.addTable(buffer, data, callback(err, buffer) { } )
pbTable.addVerbose(buffer, data, callback (err, buffer) { } )

Data extraction

We can get an individual row of our data directly from the buffer. We provide the buffer and a 'request'. The request represents the 'table row numbers' that you want returned and can be a single an integer or an Array of integers.

pbTable.get(buffer, request, callback(err, data) { } )
...
pbTable.getTable(buffer, request, callback(err, data) { } )
pbTable.getVerbose(buffer, request, callback(err, data) { } )

Compressing data

We can making use of Proto Buffers integer compression by transforming structured data via offset, multiplication and sequencing.

Transform your 'float' and 'int' data using inbuilt data transformation

header: [
  {
    name: 'latitude',
    type: 'int',
    transform: {
      offset: -42.2454,
      decimals: 4,
      sequence: true
    }  
  },
  {
    name: 'longitude',
    type: 'int',
    transform: {
      offset: 173.9302,
      multip: 10000,
    }  
  },
  ...
]

more examples and documentation coming......

Installation

For packaging with NPM and ES6

npm install --save protobuf-table

and then:

include pbTable from 'protobuf-table'

Stand alone

var pbTable = require('./dist/pbTable-min.js')

Building and Testing

Build

npm run build

Build and test

npm run test