A tnetstrings parser for javascript (browser or node)
CoffeeScript JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
src
test
.gitignore
LICENSE
Makefile
README.md
index.js
package.json

README.md

tnetstrings.js

tnetstrings is a serialization format similar to JSON, but optimized for communication over streams. This is a serialization library for javascript, usable both in the browser and with CommonJS.

Usage

The interface to tnetstrings.js is the variable TNETS, which is exposed as a global variable in the browser, and as require('tnetstrings').TNETS in CommonJS. It is API-compatible with the JSON object, as so:

TNETS.stringify('Hello, World!') // => "13:Hello, World!,"
TNETS.parse('13:Hello, World!,') // => "Hello, World!"

In addition, TNETS exposes the method parseChunk, which returns the value and the remaining part of the string.

TNETS.parseChunk('13:Hello, World!,also some other stuff') // ["Hello, World!", "also some other stuff"]

Enjoy!