0.0.7 • Published 4 years ago

json-seq v0.0.7

Weekly downloads
50
License
MIT
Repository
github
Last release
4 years ago

json-seq

Tools for working with json-seq (RFC 7464)

Stream Options

Both of the Stream types are instance of stream.Transform and pass through all stream.Transform options.

They additionally support charCodeStart and charCodeEnd parameters which can be used to override the default RFC 7464 record start and end characters.

ParseStream

import jsonSeq from 'json-seq';

const parseStream = new jsonSeq.ParseStream();
parseStream.on('data', record => {
  console.log('Value of "foo"', record.foo);
});
parseStream.on('invalid', string => {
  console.log('Invalid record encountered. Record string: ', string);
});
parseStream.on('truncated', string => {
  console.log('Truncated record encountered. Record string: ', string);
});

parseStream.write('{"foo": "bar"}\n');

StringifyStream

import jsonSeq from 'json-seq';

const stringifyStream = new jsonSeq.StringifyStream();
stringifyStream.pipe(process.stdout);

stringifyStream.write({foo: "bar"});
0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

5 years ago

0.0.1

5 years ago