Skip to content

Commit

Permalink
Release message-streams v2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cukebot committed May 30, 2021
1 parent ba98440 commit 4b63eed
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 31 deletions.
2 changes: 1 addition & 1 deletion fake-cucumber/javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@cucumber/gherkin-streams": "^2.0.2",
"@cucumber/gherkin-utils": "^5.1.0",
"@cucumber/messages": "^16.0.1",
"@cucumber/message-streams": "^2.0.0",
"@cucumber/message-streams": "^2.1.0",
"@cucumber/tag-expressions": "^3.0.1",
"@types/stack-utils": "2.0.0",
"commander": "7.2.0",
Expand Down
2 changes: 1 addition & 1 deletion gherkin-streams/javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"dependencies": {
"@cucumber/messages": "^16.0.1",
"@cucumber/message-streams": "^2.0.0",
"@cucumber/message-streams": "^2.1.0",
"@cucumber/gherkin": "^19.0.3",
"commander": "7.2.0",
"source-map-support": "0.5.19"
Expand Down
2 changes: 1 addition & 1 deletion gherkin-utils/javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"devDependencies": {
"@cucumber/gherkin": "^19.0.3",
"@cucumber/gherkin-streams": "^2.0.2",
"@cucumber/message-streams": "^2.0.0",
"@cucumber/message-streams": "^2.1.0",
"@types/glob": "7.1.3",
"@types/mocha": "8.2.2",
"@types/node": "15.6.1",
Expand Down
2 changes: 1 addition & 1 deletion gherkin/javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"dependencies": {
"@cucumber/messages": "^16.0.1",
"@cucumber/message-streams": "^2.0.0"
"@cucumber/message-streams": "^2.1.0"
},
"directories": {
"test": "test"
Expand Down
2 changes: 1 addition & 1 deletion html-formatter/javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@babel/core": "7.14.3",
"@cucumber/gherkin-streams": "^2.0.2",
"@cucumber/gherkin-utils": "^5.1.0",
"@cucumber/message-streams": "^2.0.0",
"@cucumber/message-streams": "^2.1.0",
"@cucumber/query": "^10.0.0",
"@cucumber/react": "^16.1.0",
"@types/mocha": "8.2.2",
Expand Down
2 changes: 1 addition & 1 deletion json-to-messages/javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@cucumber/gherkin-streams": "^2.0.2",
"@cucumber/gherkin-utils": "^5.1.0",
"@cucumber/messages": "^16.0.1",
"@cucumber/message-streams": "^2.0.0",
"@cucumber/message-streams": "^2.1.0",
"commander": "7.2.0",
"glob": "7.1.7",
"source-map-support": "0.5.19"
Expand Down
11 changes: 10 additions & 1 deletion message-streams/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

## [2.1.0] - 2021-05-30

### Added

* The `NdjsonToMessageStream` constructor accepts an optional function for parsing
a line, which may return null if a line is ignored. This can be used to improve performance
by ignoring certain lines.

## [2.0.0] - 2021-05-17

### Changed
Expand All @@ -28,7 +36,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
* First release

<!-- Releases -->
[Unreleased]: https://github.com/cucumber/cucumber/compare/message-streams/v2.0.0...main
[Unreleased]: https://github.com/cucumber/cucumber/compare/message-streams/v2.1.0...main
[2.1.0]: https://github.com/cucumber/cucumber/releases/tag/message-streams/v2.0.0
[2.0.0]: https://github.com/cucumber/cucumber/releases/tag/message-streams/v1.0.0
[1.0.0]: https://github.com/cucumber/cucumber/releases/tag/message-streams/v1.0.0

Expand Down
4 changes: 2 additions & 2 deletions message-streams/javascript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cucumber/message-streams",
"version": "2.0.0",
"version": "2.1.0",
"description": "Streams for reading/writing messages",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand All @@ -19,7 +19,7 @@
},
"devDependencies": {
"@types/mocha": "8.2.2",
"@types/node": "15.3.1",
"@types/node": "15.6.1",
"mocha": "8.4.0",
"typescript": "4.3.2"
},
Expand Down
15 changes: 11 additions & 4 deletions message-streams/javascript/src/NdjsonToMessageStream.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { Transform, TransformCallback } from 'stream'
import { parseEnvelope } from '@cucumber/messages'
import { Envelope, parseEnvelope } from '@cucumber/messages'

/**
* Transforms an NDJSON stream to a stream of message objects
*/
export default class NdjsonToMessageStream extends Transform {
private buffer: string

constructor() {
/**
* Create a new stream
*
* @param parseLine a function that parses a line. This function may ignore a line by returning null.
*/
constructor(private readonly parseLine: (line: string) => Envelope | null = parseEnvelope) {
super({ writableObjectMode: false, readableObjectMode: true })
}

Expand All @@ -21,8 +26,10 @@ export default class NdjsonToMessageStream extends Transform {
for (const line of lines) {
if (line.trim().length > 0) {
try {
const envelope = parseEnvelope(line)
this.push(envelope)
const envelope = this.parseLine(line)
if (envelope !== null) {
this.push(envelope)
}
} catch (err) {
err.message =
err.message +
Expand Down
48 changes: 31 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion react/javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@cucumber/fake-cucumber": "^12.0.2",
"@cucumber/gherkin": "^19.0.3",
"@cucumber/gherkin-streams": "^2.0.2",
"@cucumber/message-streams": "^2.0.0",
"@cucumber/message-streams": "^2.1.0",
"@storybook/addon-actions": "6.2.9",
"@storybook/addon-links": "6.2.9",
"@storybook/builder-webpack5": "6.2.9",
Expand Down

0 comments on commit 4b63eed

Please sign in to comment.