question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there any technical reason this hasn’t been implemented as a stream.Duplex? The first thing I wanted to do after downloading this module was device.pipe(protocol).pipe(application), just wondering if there are any technical reasons why this isn’t the case before I take a crack at converting it over.

My use case:

var hid = require('node-hid'),
    Protocol = require('./Protocol'),
    protocol = module.exports = new Protocol(),
    devices = hid.devices();

devices
    .filter(function (device) {
        // filter devices down to those that match our interest
        return device.vendorId === Protocol.VENDOR
            && device.productId === Protocol.PRODUCT;
    })
    .map(function (device) {
        // map HID event emitter objects over devices
        return new hid.HID(device.path);
    })
    .forEach(function (device) {
        // pipe device data into protocol transformer
        device.pipe(protocol);
    });

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
todbotcommented, Feb 22, 2017

Hi @bathos, Yes, if you want to do a PR with the README warning, that would be awesome. I know nothing of stream.Duplex yet but I’d be amenable to adding it. node-hid’s was written before existed I think and I have no objection to adding to its API to make it work in a more modern way.

0reactions
bminercommented, Apr 6, 2017

I’m all for improving docs, but maybe we should change node-hid to implement the Duplex stream?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating Duplex streams in Node.js - LogRocket Blog
Duplex streams, on the other hand, are a mixture of both the readable and writable streams where both streams are independent of each...
Read more >
Stream | Node.js v19.3.0 Documentation
Duplex and Transform streams are both Writable and Readable . Applications that are either writing data to or consuming data from a stream...
Read more >
How to create a Duplex stream in nodejs? - Stack Overflow
The nodejs Duplex stream requires the implementer to specify both a write and a read method: import stream from 'stream'; const duplex =...
Read more >
Watch Duplex | Prime Video - Amazon.com
HD. A tempestuous tenant drives couple Ben Stiller and Drew Barrymore to the point of murder in this dark comedy. Directors: Danny DeVito....
Read more >
duplex-stream in javascript - liveBook · Manning
The great thing about duplex streams is they can sit in the middle of pipes. A simpler way to do this is to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found