()
| 214 | } |
| 215 | |
| 216 | export async function objectTransformFromReadable () { |
| 217 | const source = Readable.from([ |
| 218 | { temp: -2.2, unit: 'F' }, |
| 219 | { temp: -40, unit: 'F' }, |
| 220 | { temp: 212, unit: 'F' }, |
| 221 | { temp: 22, unit: 'C' } |
| 222 | ]) |
| 223 | const conv = objectTransform(async (record) => { |
| 224 | if (record.unit === 'F') { |
| 225 | record = { temp: ((record.temp - 32) * 5) / 9, unit: 'C' } |
| 226 | } |
| 227 | return record |
| 228 | }) |
| 229 | source.pipe(conv) |
| 230 | const out = await collectObjects(conv) |
| 231 | deepEq(out.map((r) => Math.round(r.temp)), [-19, -40, 100, 22]) |
| 232 | ok(out.every((r) => r.unit === 'C')) |
| 233 | } |
| 234 | |
| 235 | export async function transformerReusableFactory () { |
| 236 | const Th = transformer(function (chunk, _enc, cb) { |
nothing calls this directly
no test coverage detected