![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@cucumber/gherkin-streams
Advanced tools
@cucumber/gherkin-streams is an npm package that provides a way to parse Gherkin documents (commonly used in BDD - Behavior Driven Development) into streams. This allows for efficient processing of Gherkin syntax in a streaming fashion, which can be useful for large files or real-time processing.
Parsing Gherkin Documents
This feature allows you to parse Gherkin documents from file paths and process them as streams. The example demonstrates reading a Gherkin file and writing the parsed output to a JSON file.
const { fromPaths } = require('@cucumber/gherkin-streams');
const { pipeline } = require('stream');
const fs = require('fs');
const gherkinStream = fromPaths(['./path/to/feature/file.feature']);
const outputStream = fs.createWriteStream('./output.json');
pipeline(
gherkinStream,
outputStream,
(err) => {
if (err) {
console.error('Pipeline failed.', err);
} else {
console.log('Pipeline succeeded.');
}
}
);
Streaming Gherkin from Strings
This feature allows you to parse Gherkin documents from strings and process them as streams. The example demonstrates creating a Gherkin stream from a string and outputting the parsed data.
const { fromSources } = require('@cucumber/gherkin-streams');
const { pipeline } = require('stream');
const { Readable } = require('stream');
const gherkinSource = `Feature: Example feature
Scenario: Example scenario
Given an example step`;
const gherkinStream = fromSources([{ data: gherkinSource, uri: 'example.feature' }]);
const outputStream = new Readable({ read() {} });
pipeline(
gherkinStream,
outputStream,
(err) => {
if (err) {
console.error('Pipeline failed.', err);
} else {
console.log('Pipeline succeeded.');
}
}
);
outputStream.on('data', (chunk) => {
console.log(chunk.toString());
});
The 'cucumber' package is a comprehensive tool for running Cucumber tests in JavaScript. It includes Gherkin parsing capabilities but is more focused on executing BDD tests. Unlike @cucumber/gherkin-streams, it is not optimized for streaming large Gherkin documents.
The 'gherkin' package is a lower-level library for parsing Gherkin syntax. It provides a more direct way to parse Gherkin documents but does not offer the streaming capabilities that @cucumber/gherkin-streams does.
This module contains utilities to use the Gherkin library with streams.
gherkin-streams
has 3 peer dependencies: @cucumber/gherkin
, @cucumber/messages
and @cucumber/message-streams
.
You need to have @cucumber/gherkin
and@cucumber/message-streams
in your dependencies,
@cucumber/messages
is actually installed automatically with @cucumber/gherkin
.
npm install @cucumber/gherkin-streams @cucumber/gherkin @cucumber/message-streams
const { GherkinStreams } = require('@cucumber/gherkin-streams')
const options = {
includeSource: true,
includeGherkinDocument: true,
includePickles: true,
}
const stream = GherkinStreams.fromPaths(['features/hello.feature'])
// Pipe the stream to another stream that can read messages.
stream.pipe(...)
relativeTo
You can include relativeTo
option to avoid emitting longer or absolute URIs, instead making them only relative to the current working directory (or whatever makes sense for your use case):
const { GherkinStreams } = require('@cucumber/gherkin-streams')
// imagine `discoverPaths()` is a function that returns absolute paths
const paths = discoverPaths();
const options = {
includeSource: true,
includeGherkinDocument: true,
includePickles: true,
relativeTo: process.cwd()
}
const stream = GherkinStreams.fromPaths(paths)
// Pipe the stream to another stream that can read messages.
stream.pipe(...)
[5.0.1] - 2022-03-31
FAQs
Streams for reading Gherkin parser output
The npm package @cucumber/gherkin-streams receives a total of 631,882 weekly downloads. As such, @cucumber/gherkin-streams popularity was classified as popular.
We found that @cucumber/gherkin-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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.