@signalk/streams 5.0.6 → 5.1.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/simple.js +21 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalk/streams",
3
- "version": "5.0.6",
3
+ "version": "5.1.1",
4
4
  "description": "Utilities for handling streams of Signal K data",
5
5
  "main": "index.js",
6
6
  "scripts": {
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
  }