Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/siarheidudko/objectstream
Creates a stream to convert json from string or convert json to stream. The stream is based on the incoming object stream.
https://github.com/siarheidudko/objectstream
json json-parser json-stream jsonparser jsonstream nodejs objectstream stream transform
Last synced: about 16 hours ago
JSON representation
Creates a stream to convert json from string or convert json to stream. The stream is based on the incoming object stream.
- Host: GitHub
- URL: https://github.com/siarheidudko/objectstream
- Owner: siarheidudko
- License: mit
- Created: 2019-07-24T13:12:51.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-11-02T02:17:48.000Z (6 days ago)
- Last Synced: 2024-11-02T02:18:28.556Z (6 days ago)
- Topics: json, json-parser, json-stream, jsonparser, jsonstream, nodejs, objectstream, stream, transform
- Language: JavaScript
- Homepage: https://siarheidudko.github.io/objectstream/
- Size: 1.59 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# @sergdudko/objectstream
Revolutionize Your JSON Handling with Streamlined Efficiency: Seamlessly Convert JSON from String or Transform JSON to Drain with this Powerful Stream Creation Tool. Harness the Power of Object Streams for Swift and Seamless Data Processing!
[![npm](https://img.shields.io/npm/v/@sergdudko/objectstream.svg)](https://www.npmjs.com/package/@sergdudko/objectstream)
[![npm](https://img.shields.io/npm/dy/@sergdudko/objectstream.svg)](https://www.npmjs.com/package/@sergdudko/objectstream)
[![NpmLicense](https://img.shields.io/npm/l/@sergdudko/objectstream.svg)](https://www.npmjs.com/package/@sergdudko/objectstream)
![GitHub last commit](https://img.shields.io/github/last-commit/siarheidudko/objectstream.svg)
![GitHub release](https://img.shields.io/github/release/siarheidudko/objectstream.svg)- Based on native methods of NodeJS
## INSTALL
```bash
npm i @sergdudko/objectstream --save
```## DOCS
[See docs](https://siarheidudko.github.io/objectstream/index.html)
## SUPPORTED ENCODING
| Stream | incoming stream | outgoing stream |
| ---------- | --------------------------------- | --------------------------------- |
| Stringifer | utf8 (object mode) | utf8, base64, latin1, binary, hex |
| Parser | utf8, base64, latin1, binary, hex | utf8 (object mode) |## USE
```js
// REQUIRE OR IMPORT CLASSconst Stringifer = require("@sergdudko/objectstream").Stringifer;
const Parser = require("@sergdudko/objectstream").Parser;
// or use import
import { Stringifer, Parser } from "@sergdudko/objectstream";// CREATE STREAM
const firstSeparator = "[";
const middleSeparator = ",";
const endSeparator = "]";
const stringToObject = new Parser(
firstSeparator,
middleSeparator,
endSeparator
);
const objectToString = new Stringifer(
firstSeparator,
middleSeparator,
endSeparator
);// EVENTS
stringToObject.on("data", (e) => {
// e - is Object
});
stringToObject.on("error", (d) => {
// e - Array of Error
});
stringToObject.on("end", () => {
// end event
});
stringToObject.on("finish", () => {
// finish event
});
objectToString.on("data", (e) => {
// e - is Buffer (deault, if you need a string use setEncoding)
});
objectToString.on("error", (d) => {
// e - Array of Error
});
objectToString.on("end", () => {
// end event
});
objectToString.on("finish", () => {
// finish event
});// CHANGE ENCODING
stringToObject.setEncoding("latin1");
objectToString.setEncoding("latin1");// WRITE DATA (example for utf8)
stringToObject.write('{"boolean":true}');
objectToString.write({ boolean: true });// PIPE
stringToObject.pipe(objectToString);
```## EXAMPLE
[see test directory](https://github.com/siarheidudko/objectstream/tree/master/test)
## OLDER VERSIONS
- [v2.0.5](https://www.npmjs.com/package/@sergdudko/objectstream/v/2.0.5) - supported Node 8
## LICENSE
MIT