3.1.25 • Published 1 month ago

@sergdudko/objectstream v3.1.25

Weekly downloads
38
License
MIT
Repository
github
Last release
1 month ago

@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 npm NpmLicense GitHub last commit GitHub release

  • Based on native methods of NodeJS

INSTALL

 npm i @sergdudko/objectstream --save

DOCS

See docs

SUPPORTED ENCODING

Streamincoming streamoutgoing stream
Stringiferutf8 (object mode)utf8, base64, latin1, binary, hex
Parserutf8, base64, latin1, binary, hexutf8 (object mode)

USE

// REQUIRE OR IMPORT CLASS

const 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

OLDER VERSIONS

LICENSE

MIT

3.1.25

1 month ago

3.1.24

1 month ago

3.1.23

1 month ago

3.1.22

2 months ago

3.1.21

2 months ago

3.1.20

2 months ago

3.1.19

2 months ago

3.1.18

2 months ago

3.1.17

2 months ago

3.1.16

2 months ago

3.1.15

2 months ago

3.1.14

3 months ago

3.1.13

3 months ago

3.1.12

3 months ago

3.1.11

3 months ago

3.1.10

3 months ago

3.1.9

3 months ago

3.1.3

7 months ago

3.1.7

6 months ago

3.1.6

6 months ago

3.1.5

6 months ago

3.1.4

6 months ago

3.1.2

1 year ago

3.1.1

2 years ago

3.1.0

2 years ago

3.0.0

3 years ago

2.0.5

4 years ago

2.0.3

4 years ago

2.0.4

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.7.7

4 years ago

1.7.6

4 years ago

1.7.5

4 years ago

1.7.4

4 years ago

1.7.3

4 years ago

1.7.2

4 years ago

1.7.1

4 years ago

1.7.0

4 years ago

1.6.0

4 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago