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"]