Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@cucumber/message-streams
Advanced tools
@cucumber/message-streams is a package that provides utilities for working with Cucumber messages in a streaming fashion. It allows you to read, write, and transform Cucumber messages using streams, which can be useful for processing large sets of test results or integrating with other tools.
Reading Cucumber Messages from a Stream
This feature allows you to read Cucumber messages from a NDJSON (Newline Delimited JSON) stream. The code sample demonstrates how to create a readable stream from a file and pipe it through the NdjsonToMessageStream to process each message.
const { NdjsonToMessageStream } = require('@cucumber/message-streams');
const fs = require('fs');
const inputStream = fs.createReadStream('cucumber.ndjson');
const messageStream = new NdjsonToMessageStream();
inputStream.pipe(messageStream).on('data', (message) => {
console.log(message);
});
Writing Cucumber Messages to a Stream
This feature allows you to write Cucumber messages to a NDJSON stream. The code sample demonstrates how to create a writable stream to a file and use the MessageToNdjsonStream to write a Cucumber message to the file.
const { MessageToNdjsonStream } = require('@cucumber/message-streams');
const fs = require('fs');
const outputStream = fs.createWriteStream('output.ndjson');
const messageStream = new MessageToNdjsonStream();
messageStream.pipe(outputStream);
messageStream.write({
type: 'TestRunStarted',
timestamp: new Date().toISOString()
});
messageStream.end();
Transforming Cucumber Messages
This feature allows you to transform Cucumber messages as they are read from a stream and written to another stream. The code sample demonstrates how to create a transform stream that adds a custom property to each message and then pipes the messages through the transformation.
const { Transform } = require('stream');
const { NdjsonToMessageStream, MessageToNdjsonStream } = require('@cucumber/message-streams');
const fs = require('fs');
const inputStream = fs.createReadStream('cucumber.ndjson');
const outputStream = fs.createWriteStream('transformed.ndjson');
const transformStream = new Transform({
objectMode: true,
transform(message, encoding, callback) {
// Example transformation: add a custom property
message.customProperty = 'customValue';
callback(null, message);
}
});
inputStream
.pipe(new NdjsonToMessageStream())
.pipe(transformStream)
.pipe(new MessageToNdjsonStream())
.pipe(outputStream);
stream-json is a package for processing large JSON files in a streaming fashion. It provides tools for parsing, transforming, and stringifying JSON data using streams. Compared to @cucumber/message-streams, stream-json is more general-purpose and not specifically tailored to Cucumber messages.
JSONStream is a package that provides streaming JSON parsing and stringifying. It is useful for working with large JSON datasets and can be used to process JSON data in a memory-efficient way. Like stream-json, JSONStream is a general-purpose tool and does not have specific support for Cucumber messages.
event-stream is a toolkit for working with streams in Node.js. It provides a variety of utilities for creating, transforming, and consuming streams. While it is not specifically designed for JSON or Cucumber messages, it can be used in conjunction with other packages to achieve similar functionality.
This module contains stream utilities to read/write Cucumber Message objects to/from streams.
FAQs
Streams for reading/writing messages
The npm package @cucumber/message-streams receives a total of 954,996 weekly downloads. As such, @cucumber/message-streams popularity was classified as popular.
We found that @cucumber/message-streams demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.