@signalk/streams 5.0.5 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/canboatjs.js CHANGED
@@ -56,9 +56,6 @@ CanboatJs.prototype._transform = function (chunk, encoding, done) {
56
56
  } else {
57
57
  this.app.emit('canboatjs:unparsed:object', chunk)
58
58
  }
59
- if (chunk.fromFile) {
60
- this.app.emit('canboatjs:rawoutput', chunk.data)
61
- }
62
59
  } else {
63
60
  const pgnData = this.fromPgn.parse(chunk)
64
61
  if (pgnData) {
@@ -67,7 +64,6 @@ CanboatJs.prototype._transform = function (chunk, encoding, done) {
67
64
  } else {
68
65
  this.app.emit('canboatjs:unparsed:data', chunk)
69
66
  }
70
- this.app.emit('canboatjs:rawoutput', chunk)
71
67
  }
72
68
  done()
73
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalk/streams",
3
- "version": "5.0.5",
3
+ "version": "5.1.0",
4
4
  "description": "Utilities for handling streams of Signal K data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/serialport.js CHANGED
@@ -148,34 +148,44 @@ SerialStream.prototype.start = function () {
148
148
  )
149
149
 
150
150
  let pendingWrites = 0
151
- const stdOutEvent = this.options.toStdout
152
- if (stdOutEvent) {
153
- ;(isArray(stdOutEvent) ? stdOutEvent : [stdOutEvent]).forEach((event) => {
154
- const onDrain = () => {
155
- pendingWrites--
151
+ const stdOutEvents = isArray(this.options.toStdout)
152
+ ? this.options.toStdout
153
+ : [this.options.toStdout]
154
+ const standardOutEventName = `serial-${this.options.subOptions.providerId}-toStdout`
155
+ stdOutEvents.push(standardOutEventName)
156
+
157
+ stdOutEvents.forEach((event) => {
158
+ const onDrain = () => {
159
+ pendingWrites--
160
+ }
161
+
162
+ that.options.app.on(event, (d) => {
163
+ if (pendingWrites > that.maxPendingWrites) {
164
+ that.debug('Buffer overflow, not writing:' + d)
165
+ return
156
166
  }
157
-
158
- that.options.app.on(event, (d) => {
159
- if (pendingWrites > that.maxPendingWrites) {
160
- that.debug('Buffer overflow, not writing:' + d)
161
- return
162
- }
163
- that.debug('Writing:' + d)
164
- if (isBuffer(d)) {
165
- that.serial.write(d)
166
- } else {
167
- that.serial.write(d + '\r\n')
168
- }
169
- setImmediate(() => {
170
- that.options.app.emit('connectionwrite', {
171
- providerId: that.options.providerId
172
- })
167
+ that.debug('Writing:' + d)
168
+ if (isBuffer(d)) {
169
+ that.serial.write(d)
170
+ } else {
171
+ that.serial.write(d + '\r\n')
172
+ }
173
+ setImmediate(() => {
174
+ that.options.app.emit('connectionwrite', {
175
+ providerId: that.options.providerId
173
176
  })
174
- pendingWrites++
175
- that.serial.drain(onDrain)
176
177
  })
178
+ pendingWrites++
179
+ that.serial.drain(onDrain)
177
180
  })
178
- }
181
+ })
182
+
183
+ this.options.app.emitPropertyValue('serialport', {
184
+ id: this.options.providerId,
185
+ eventNames: {
186
+ toStdout: standardOutEventName
187
+ }
188
+ })
179
189
  }
180
190
 
181
191
  SerialStream.prototype.end = function () {
package/simple.js CHANGED
@@ -93,6 +93,25 @@ function Simple(options) {
93
93
  getLogger(options.app, options.logging, discriminatorByDataType[dataType]),
94
94
  dataTypeMapping[mappingType](options)
95
95
  )
96
+
97
+ const dataReceivedEventName = `${options.subOptions.providerId}-received`
98
+
99
+ const spy = new Transform({
100
+ transform(chunk, encoding, callback) {
101
+ options.app.emit(dataReceivedEventName, chunk)
102
+ callback(null, chunk)
103
+ }
104
+ })
105
+ pipeline.splice(pipeline.length - 1, 0, spy)
106
+
107
+ options.subOptions.app.emitPropertyValue('pipedprovider', {
108
+ id: options.subOptions.providerId,
109
+ type: mappingType,
110
+ eventNames: {
111
+ received: dataReceivedEventName
112
+ }
113
+ })
114
+
96
115
  if (options.subOptions.overrideTimestamp) {
97
116
  pipeline.push(
98
117
  new Transform({
@@ -162,7 +181,8 @@ const dataTypeMapping = {
162
181
  if (options.type === 'FileStream') {
163
182
  result.unshift(
164
183
  new Throttle({
165
- rate: options.subOptions.throttleRate || 1000
184
+ rate: options.subOptions.throttleRate || 1000,
185
+ chunksize: options.subOptions.throttleRate || 1000
166
186
  })
167
187
  )
168
188
  }