
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@sergdudko/objectstream
Advanced tools
Creates a stream to convert json from string or convert json to string.
A powerful and efficient Node.js library for streaming JSON processing. Transform JSON strings to objects and objects to JSON strings with support for custom separators, multiple encodings, and high-performance streaming operations.
npm install @sergdudko/objectstream
import { Parser, Stringifer } from '@sergdudko/objectstream';
// String to Object conversion
const parser = new Parser();
parser.on('data', (obj) => {
console.log('Parsed object:', obj);
});
parser.write('{"name":"John","age":30}');
parser.end();
// Object to String conversion
const stringifer = new Stringifer();
stringifer.on('data', (jsonString) => {
console.log('JSON string:', jsonString.toString());
});
stringifer.write({ name: 'John', age: 30 });
stringifer.end();
const { Parser, Stringifer } = require('@sergdudko/objectstream');
// Or using default export
const objectstream = require('@sergdudko/objectstream');
const { Parser, Stringifer } = objectstream.default;
import { Parser, Stringifer } from '@sergdudko/objectstream';
interface User {
name: string;
age: number;
}
const parser = new Parser();
parser.on('data', (user: User) => {
console.log(`User: ${user.name}, Age: ${user.age}`);
});
Transform stream that converts JSON strings to JavaScript objects.
new Parser(start?: string, middle?: string, end?: string)
start (optional): First separator character (default: none)middle (optional): Middle separator character (default: none)end (optional): End separator character (default: none)setEncoding(encoding): Set input encoding (utf8, utf-8, base64, latin1, binary, hex)data: Emitted when an object is parsederror: Emitted when parsing failsend: Emitted when stream endsfinish: Emitted when stream finishesTransform stream that converts JavaScript objects to JSON strings.
new Stringifer(start?: string, middle?: string, end?: string)
start (optional): First separator character (default: none)middle (optional): Middle separator character (default: none)end (optional): End separator character (default: none)setEncoding(encoding): Set output encoding (utf8, utf-8, base64, latin1, binary, hex)data: Emitted when JSON string is generatederror: Emitted when stringification failsend: Emitted when stream endsfinish: Emitted when stream finishesimport { Parser, Stringifer } from '@sergdudko/objectstream';
const parser = new Parser();
const stringifer = new Stringifer();
// Parse JSON string
parser.on('data', (obj) => {
console.log('Parsed:', obj);
});
parser.write('{"message":"Hello World"}');
parser.end();
// Stringify object
stringifer.on('data', (data) => {
console.log('Stringified:', data.toString());
});
stringifer.write({ message: 'Hello World' });
stringifer.end();
import { Parser, Stringifer } from '@sergdudko/objectstream';
// Process JSON array with custom separators
const parser = new Parser('[', ',', ']');
const stringifer = new Stringifer('[', ',', ']');
stringifer.on('data', (data) => {
console.log('JSON Array chunk:', data.toString());
});
// Write multiple objects
stringifer.write({ id: 1, name: 'Alice' });
stringifer.write({ id: 2, name: 'Bob' });
stringifer.write({ id: 3, name: 'Charlie' });
stringifer.end(); // Output: [{"id":1,"name":"Alice"},{"id":2,"name":"Bob"},{"id":3,"name":"Charlie"}]
import { Parser, Stringifer } from '@sergdudko/objectstream';
// Base64 encoding
const stringifer = new Stringifer();
stringifer.setEncoding('base64');
stringifer.on('data', (data) => {
console.log('Base64 JSON:', data); // Base64 encoded JSON string
});
stringifer.write({ encoded: true });
stringifer.end();
// Parse Base64 encoded JSON
const parser = new Parser();
parser.setEncoding('base64');
parser.on('data', (obj) => {
console.log('Decoded object:', obj);
});
// Write base64 encoded JSON
parser.write(Buffer.from('{"decoded":true}').toString('base64'));
parser.end();
import { Parser, Stringifer } from '@sergdudko/objectstream';
import { Transform } from 'stream';
// Create a processing pipeline
const parser = new Parser();
const processor = new Transform({
objectMode: true,
transform(obj, encoding, callback) {
// Process each object
obj.processed = true;
obj.timestamp = Date.now();
callback(null, obj);
}
});
const stringifer = new Stringifer();
// Pipe the streams together
parser
.pipe(processor)
.pipe(stringifer)
.on('data', (data) => {
console.log('Processed JSON:', data.toString());
});
// Input data
parser.write('{"name":"test"}');
parser.end();
import { Parser, Stringifer } from '@sergdudko/objectstream';
const parser = new Parser();
parser.on('data', (obj) => {
console.log('Valid object:', obj);
});
parser.on('error', (errors) => {
console.error('Parsing errors:', errors);
});
// Valid JSON
parser.write('{"valid":true}');
// Invalid JSON
parser.write('{"invalid":}');
parser.end();
| Encoding | Input | Output | Description |
|---|---|---|---|
utf8 (default) | ✅ | ✅ | Standard UTF-8 text |
utf-8 | ✅ | ✅ | Alias for utf8 |
base64 | ✅ | ✅ | Base64 encoded data |
latin1 | ✅ | ✅ | Latin-1 encoding |
binary | ✅ | ✅ | Binary data encoding |
hex | ✅ | ✅ | Hexadecimal encoding |
ObjectStream is optimized for high-performance streaming operations:
The library includes comprehensive TypeScript tests:
npm test
Test coverage includes:
# Install dependencies
npm install
# Run tests
npm test
# Build dual package (ESM + CJS)
npm run build
# Lint code
npm run lint
dist/
├── esm/ # ES Modules build
├── cjs/ # CommonJS build
└── types/ # Shared TypeScript definitions
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)MIT License - see LICENSE file for details.
If ObjectStream helps you build amazing applications, consider supporting its development:
Your support helps maintain and improve Redux Cluster for the entire community!
Made with ❤️ by Siarhei Dudko
FAQs
Creates a stream to convert json from string or convert json to string.
We found that @sergdudko/objectstream demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.