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

@stenway/tbl

v1.1.1

Published

Serialize and deserialize TBL documents

Downloads

27

Readme

TBL

About TBL

TBL is a data table format based on SML - the Simple Markup Language. TBL is a modern and robust alternative to CSV. It has only a minimal set of rules and solves the main problems of CSV (watch this video for more details on that). It's human friendly and can produce documents that are beautifully formatted and readable, even without specific tools, just opened in a text editor. Here is an example TBL document:

Table
  Meta
    Title       "My Table"
    Description "This is a description of my table"		
  End
  FirstName      LastName  Age PlaceOfBirth
  William        Smith     30  Boston
  Olivia         Jones     27  "San Francisco"
  Lucas          Brown     -   Chicago          # Age missing
  "James Elijah" Wilson    20  "New York City"
  Elizabeth      Miller                         # Data missing
  Victoria       Davis     22  Austin
End

It has support for meta data, can differentiate between null values and empty values, and can contain comments. TBL doesn't need to bother about encoding and decoding anymore, because it relies on ReliableTXT, which takes care of that aspect (see also the NPM package reliabletxt).

A TBL document represents a single table. If you need to embed multiple tables into one document, TBLS comes into play:

Tables
  Table
    Column1 Column2
    Value1  Value2
  End
  Table
    ColumnA ColumnB
    ValueA  ValueB
  End
End

Find out what can be done with TBL and TBLS on the official YouTube channel from Stenway and get started with videos like:

About this package

This package provides functionality to handle the parsing and serialization of TBL and TBLS documents. It also provides functionality to encode and decode the binary version of TBL, which is called BinaryTBL. The package works both in the browser and Node.js, because it does not require environment specific functionality. If you want to read and write TBL files using Node.js's file system module, you can use the tbl-io package. The tbl-browser package on the other hand offers functionality to easily provide TBL documents as downloadable files.

Getting started

We first have to install the Stenway TBL package with the npm install command.

npm install @stenway/tbl

Then import the TblDocument class and create a new TblDocument object by calling the static parse method:

import { TblDocument } from "@stenway/tbl"
const document = TblDocument.parse("Table\nColumn1 Column2\nValue1 Value2\nEnd")
console.log(document)

Add a new row with the addRow method like this:

document.addRow(["ValueA", "ValueB"])

More documentation about the other classes, methods and properties will follow.

BinaryTBL

BinaryTBL is the binary representation of TBL documents. It's based on BinarySML. You can encode a document to BinaryTBL with the toBinaryTbl method and decode it with the static method fromBinaryTbl:

const document = TblDocument.parse(`Table\nColumn1 Column2\nValue1 Value2\nEnd`)
const bytes = document.toBinaryTbl()
const decodedDocument = SmlDocument.fromBinaryTbl(bytes)